Skip to content

Commit fb670fe

Browse files
committed
Add script to copy images from VOC
1 parent 25525d6 commit fb670fe

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

scripts/copy_images.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import os
2+
from shutil import copyfile
3+
4+
5+
lines = [line.strip() for line in open("/home/ubuntu/DATA/darknet/darknet_ori/datasets/train.txt")]
6+
7+
dst = "/home/ubuntu/DATA/darknet/data_folder"
8+
9+
if not os.path.exists(dst):
10+
os.makedirs(dst)
11+
12+
if not os.path.exists(dst + "/JPEGImages"):
13+
os.makedirs(dst + "/JPEGImages")
14+
15+
if not os.path.exists(dst + "/labels"):
16+
os.makedirs(dst + "/labels")
17+
18+
for line in lines:
19+
# os.system('echo ' + ' cp ' + line + ' ' + dst + "/JPEGImages/")
20+
os.system('cp ' + line + ' ' + dst + "/JPEGImages/")
21+
label = line.replace("images", "labels").replace("JPEGImages", "labels").replace(".jpg", ".txt").replace(".JPEG", ".txt")
22+
# os.system('echo ' + ' cp ' + label + ' ' + dst + "/labels/")
23+
os.system('cp ' + label + ' ' + dst + "/labels/")

0 commit comments

Comments
 (0)