forked from fundamentalvision/Deformable-DETR
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbib_num.py
More file actions
26 lines (18 loc) · 708 Bytes
/
Copy pathbib_num.py
File metadata and controls
26 lines (18 loc) · 708 Bytes
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
import random
import shutil,os
random.seed(42)
#Generate 706 random numbers between -- and --
randomlist = random.sample(range(1, 8706), 706)
count =1
img_dir = '/content/Deformable-DETR/ReID/ReID_train/train_image/'
txt_dir = '/content/Deformable-DETR/ReID/ReID_train/train_gt/'
dest_folder ='/content/Deformable-DETR/ReID/ReID_train/val/'
dest_txt_folder ='/content/Deformable-DETR/ReID/ReID_train/val_gt/'
for imgfile in os.listdir(img_dir):
if imgfile.endswith('.jpg'):
if count in randomlist:
img_path =os.path.join(img_dir, imgfile)
shutil.move(img_path, dest_folder)
file_path = os.path.join(txt_dir, imgfile[:-3]+'txt')
shutil.move(file_path, dest_txt_folder)
count +=1