Browse Source

update get_voc.sh

5.0
Glenn Jocher 4 years ago
parent
commit
11ba5294dd
1 changed files with 19 additions and 18 deletions
  1. +19
    -18
      data/get_voc.sh

+ 19
- 18
data/get_voc.sh View File

# handle optional download dir # handle optional download dir
if [ -z "$1" ] if [ -z "$1" ]
then then
# navigate to ~/data
echo "navigating to ../data/ ..."
mkdir -p ../data
cd ../data/
# navigate to ~/tmp
echo "navigating to ../tmp/ ..."
mkdir -p ../tmp
cd ../tmp/
else else
# check if is valid directory # check if is valid directory
if [ ! -d $1 ]; then if [ ! -d $1 ]; then
# handle optional download dir # handle optional download dir
if [ -z "$1" ] if [ -z "$1" ]
then then
# navigate to ~/data
echo "navigating to ../data/ ..."
mkdir -p ../data
cd ../data/
# navigate to ~/tmp
echo "navigating to ../tmp/ ..."
mkdir -p ../tmp
cd ../tmp/
else else
# check if is valid directory # check if is valid directory
if [ ! -d $1 ]; then if [ ! -d $1 ]; then


echo "Completed in" $runtime "seconds" echo "Completed in" $runtime "seconds"


cd ../data
cd ../tmp
echo "Spliting dataset..." echo "Spliting dataset..."
python3 - "$@" <<END python3 - "$@" <<END
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
os.system('mkdir ../VOC/labels/val') os.system('mkdir ../VOC/labels/val')


import os import os
print(os.path.exists('../data/train.txt'))
f = open('../data/train.txt', 'r')
print(os.path.exists('../tmp/train.txt'))
f = open('../tmp/train.txt', 'r')
lines = f.readlines() lines = f.readlines()


for line in lines: for line in lines:
if (os.path.exists("../" + line[:-1])): if (os.path.exists("../" + line[:-1])):
os.system("cp ../"+ line[:-1] + " ../VOC/images/train") os.system("cp ../"+ line[:-1] + " ../VOC/images/train")
print(os.path.exists('../data/train.txt'))
f = open('../data/train.txt', 'r')
print(os.path.exists('../tmp/train.txt'))
f = open('../tmp/train.txt', 'r')
lines = f.readlines() lines = f.readlines()


for line in lines: for line in lines:
if (os.path.exists("../" + line[:-1])): if (os.path.exists("../" + line[:-1])):
os.system("cp ../"+ line[:-1] + " ../VOC/labels/train") os.system("cp ../"+ line[:-1] + " ../VOC/labels/train")


print(os.path.exists('../data/2007_test.txt'))
f = open('../data/2007_test.txt', 'r')
print(os.path.exists('../tmp/2007_test.txt'))
f = open('../tmp/2007_test.txt', 'r')
lines = f.readlines() lines = f.readlines()


for line in lines: for line in lines:
if (os.path.exists("../" + line[:-1])): if (os.path.exists("../" + line[:-1])):
os.system("cp ../"+ line[:-1] + " ../VOC/images/val") os.system("cp ../"+ line[:-1] + " ../VOC/images/val")


print(os.path.exists('../data/2007_test.txt'))
f = open('../data/2007_test.txt', 'r')
print(os.path.exists('../tmp/2007_test.txt'))
f = open('../tmp/2007_test.txt', 'r')
lines = f.readlines() lines = f.readlines()


for line in lines: for line in lines:


END END


rm -rf ../data
rm -rf ../tmp # remove temporary directory
echo "VOC download done."

Loading…
Cancel
Save