-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrain_test_dataset_splitter.py
More file actions
29 lines (26 loc) · 1.1 KB
/
Copy pathtrain_test_dataset_splitter.py
File metadata and controls
29 lines (26 loc) · 1.1 KB
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
28
29
import shutil, random, os
dirpath="/Users/yvonneradsmikham/Microsoft/fox-audio/wav/gunshot_other_complete_tfrecord"
destpath="/Users/yvonneradsmikham/Microsoft/fox-audio/wav/gunshot_other_training_60"
other_destpath="/Users/yvonneradsmikham/Microsoft/fox-audio/wav/gunshot_other_test_40"
filenames = random.sample(os.listdir(dirpath), 600)
all_files = os.listdir(dirpath)
for fname in filenames:
srcpath = os.path.join(dirpath, fname)
dest= os.path.join(destpath, fname)
shutil.copyfile(srcpath, dest)
# for filename in all_files:
# for fname in filenames:
# if filename == fname:
# #print("In Training Set")
# continue
# else:
# source = os.path.join(dirpath, filename)
# destination = os.path.join(other_destpath, filename)
# shutil.copyfile(source, destination)
for filename in all_files:
if os.path.exists(os.path.join(destpath, filename)):
continue
else:
source = os.path.join(dirpath, filename)
destination = os.path.join(other_destpath, filename)
shutil.copyfile(source, destination)