Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stanford dogs dataset upload #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Stanford Dogs Dataset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Stanford Dogs Dataset

## Get the Dataset

```
Download the dataset from http://vision.stanford.edu/aditya86/ImageNetDogs/
```

## Extract the annotations from .tar file

```
Run annotations.py to get the annotations from the tar file

Run the following command in the annotations folder to convert the annotations to .xml format
find . -type f -exec mv '{}' '{}'.xml \;

```

## Make the annotations compatible to the corresponding images

```

Run upload.py to make the annotations of bounding box compatable to upload. It includes pre-processing of folder/filenames of the annotations matching as the images.

```
10 changes: 10 additions & 0 deletions Stanford Dogs Dataset/annotations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import tarfile
my_tar = tarfile.open('annotation.tar')
my_tar.extractall('./annotations') # specify which folder to extract to
my_tar.close()


import tarfile
my_tar = tarfile.open('images.tar')
my_tar.extractall('./images') # specify which folder to extract to
my_tar.close()
19 changes: 19 additions & 0 deletions Stanford Dogs Dataset/upload.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import xml.etree.ElementTree as ET


import os
directory = 'annotations/Annotation'
for filename in os.listdir(directory):
f = os.path.join(directory, filename)
for files in os.listdir(f):
f1 = os.path.join(f,files)
mytree = ET.parse(f)
myroot = mytree.getroot()
classname = ''
for files in myroot.iter('folder'):
files.text = ''
for file in myroot.iter('filename'):
classname = file.text
file.text = classname + '.jpg'

mytree.write(f1)