-
Notifications
You must be signed in to change notification settings - Fork 2
/
Split.py
27 lines (20 loc) · 685 Bytes
/
Split.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import os
import random
import shutil
def split_data(category, file_path):
source = file_path + 'train\' + category
filenames = os.listdir(file_path + 'train\' + category)
print (len(filenames))
print ('First Ten Files: ', filenames[0:10])
filenames.sort()
random.seed(256)
random.shuffle(filenames)
print ()
split = 2000
test_filenames = filenames[:split]
print (len(test_filenames))
destination = file_path + 'test\' + category
for name in test_filenames:
ini_path = os.path.join(source, name)
fin_path = os.path.join(destination, name)
shutil.move(ini_path, fin_path)