mirror of
https://github.com/aladdinpersson/Machine-Learning-Collection.git
synced 2026-04-10 12:33:44 +00:00
Initial commit
This commit is contained in:
22
ML/Pytorch/object_detection/YOLO/data/generate_csv.py
Executable file
22
ML/Pytorch/object_detection/YOLO/data/generate_csv.py
Executable file
@@ -0,0 +1,22 @@
|
||||
import os
|
||||
import csv
|
||||
|
||||
read_train = open("train.txt", "r").readlines()
|
||||
|
||||
with open("train.csv", mode="w", newline="") as train_file:
|
||||
for line in read_train:
|
||||
image_file = line.split("/")[-1].replace("\n", "")
|
||||
text_file = image_file.replace(".jpg", ".txt")
|
||||
data = [image_file, text_file]
|
||||
writer = csv.writer(train_file)
|
||||
writer.writerow(data)
|
||||
|
||||
read_train = open("test.txt", "r").readlines()
|
||||
|
||||
with open("test.csv", mode="w", newline="") as train_file:
|
||||
for line in read_train:
|
||||
image_file = line.split("/")[-1].replace("\n", "")
|
||||
text_file = image_file.replace(".jpg", ".txt")
|
||||
data = [image_file, text_file]
|
||||
writer = csv.writer(train_file)
|
||||
writer.writerow(data)
|
||||
60
ML/Pytorch/object_detection/YOLO/data/get_data
Executable file
60
ML/Pytorch/object_detection/YOLO/data/get_data
Executable file
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
## DOWNLOAD from JOSEPHS WEBSITE (SLOWER DOWNLOAD)
|
||||
#wget https://pjreddie.com/media/files/VOCtrainval_11-May-2012.tar
|
||||
#wget https://pjreddie.com/media/files/VOCtrainval_06-Nov-2007.tar
|
||||
#wget https://pjreddie.com/media/files/VOCtest_06-Nov-2007.tar
|
||||
|
||||
## OR DOWNLOAD FROM HERE (FASTER DOWNLOAD)
|
||||
# VOC2007 DATASET
|
||||
wget http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtrainval_06-Nov-2007.ta
|
||||
wget http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtest_06-Nov-2007.tar #
|
||||
|
||||
# VOC2012 DATASET
|
||||
wget http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCtrainval_11-May-2012.ta
|
||||
|
||||
# Extract tar files
|
||||
tar xf VOCtrainval_11-May-2012.tar
|
||||
tar xf VOCtrainval_06-Nov-2007.tar
|
||||
tar xf VOCtest_06-Nov-2007.tar
|
||||
|
||||
# Need voc_label.py to clean up data from xml files
|
||||
wget https://pjreddie.com/media/files/voc_label.py
|
||||
|
||||
# Run python file to clean data from xml files
|
||||
python voc_label.py
|
||||
|
||||
# Get train by using train+val from 2007 and 2012
|
||||
# Then we only test on 2007 test set
|
||||
# Unclear from paper what they actually just as a dev set
|
||||
cat 2007_train.txt 2007_val.txt 2012_*.txt > train.txt
|
||||
cp 2007_test.txt test.txt
|
||||
|
||||
# Move txt files we won't be using to clean up a little bit
|
||||
mkdir old_txt_files
|
||||
mv 2007* 2012* old_txt_files/
|
||||
|
||||
python generate_csv.py
|
||||
|
||||
mkdir data
|
||||
mkdir data/images
|
||||
mkdir data/labels
|
||||
|
||||
cp VOCdevkit/*.jpg data/images/
|
||||
cp VOCdevkit/VOC2007/labels/*.txt data/labels/
|
||||
cp VOCdevkit/VOC2012/labels/*.txt data/labels/
|
||||
|
||||
mkdir data
|
||||
mkdir data/images
|
||||
mkdir data/labels
|
||||
|
||||
mv VOCdevkit/VOC2007/JPEGImages/*.jpg data/images/
|
||||
mv VOCdevkit/VOC2012/JPEGImages/*.jpg data/images/
|
||||
mv VOCdevkit/VOC2007/labels/*.txt data/labels/
|
||||
mv VOCdevkit/VOC2012/labels/*.txt data/labels/
|
||||
|
||||
# We don't need VOCdevkit folder anymore, can remove
|
||||
# in order to save some space
|
||||
rm -rf VOCdevkit/
|
||||
mv test.txt old_txt_files/
|
||||
mv train.txt old_txt_files/
|
||||
Reference in New Issue
Block a user