Skip to content

Commit 55e7960

Browse files
committed
updated gernerating training data section in readme
1 parent a9e9b2c commit 55e7960

File tree

3 files changed

+7
-25
lines changed

3 files changed

+7
-25
lines changed

Diff for: README.md

+3-25
Original file line numberDiff line numberDiff line change
@@ -125,35 +125,13 @@ LabelImg supports two formats, PascalVOC and Yolo. For this tutorial, make sure
125125

126126
### 4. Generating Training data
127127

128-
With the images labeled, we need to create TFRecords that can be served as input data for training the object detector. To create the TFRecords, we will use two scripts from [Dat Tran’s raccoon detector](https://github.com/datitran/raccoon_dataset). Namely, the xml_to_csv.py and generate_tfrecord.py files.
129-
130-
After downloading both scripts, we first change the main method in the xml_to_csv file to transform the created xml files to csv correctly.
131-
132-
```python
133-
# Old:
134-
def main():
135-
image_path = os.path.join(os.getcwd(), 'annotations')
136-
xml_df = xml_to_csv(image_path)
137-
xml_df.to_csv('raccoon_labels.csv', index=None)
138-
print('Successfully converted xml to csv.')
139-
# New:
140-
def main():
141-
for folder in ['train', 'test']:
142-
image_path = os.path.join(os.getcwd(), ('images/' + folder))
143-
xml_df = xml_to_csv(image_path)
144-
xml_df.to_csv(('images/'+folder+'_labels.csv'), index=None)
145-
print('Successfully converted xml to csv.')
146-
```
147-
148-
Now we can transform our xml files to csvs by opening the command line and typing:
128+
With the images labeled, we need to create TFRecords that can be served as input data for training the object detector. To create the TFRecords, we will first convert the XML label files created with LabelImg to one CSV file using the [xml_to_csv.py script](xml_to_csv.py).
149129

150130
```bash
151131
python xml_to_csv.py
152132
```
153133

154-
The above command creates two files in the images directory. One called test_labels.csv and another one called train_labels.csv.
155-
156-
Next, open the generate_tfrecord.py file and replace the labelmap inside the class_text_to_int method with your own label map.
134+
The above command creates two files in the images directory. One is called test_labels.csv, and another one is called train_labels.csv. Next, we'll convert the CSV files into TFRecords files. For this, open the [generate_tfrecord.py file](generate_tfrecord.py) and replace the labelmap inside the class_text_to_int method with your own label map.
157135

158136
Old:
159137
```python
@@ -184,7 +162,7 @@ def class_text_to_int(row_label):
184162
return None
185163
```
186164

187-
Now the TFRecords can be generated by typing:
165+
Now the TFRecord files can be generated by typing:
188166

189167
```bash
190168
python generate_tfrecord.py --csv_input=images/train_labels.csv --image_dir=images/train --output_path=train.record

Diff for: generate_tfrecord.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#based on https://github.com/datitran/raccoon_dataset/blob/master/generate_tfrecord.py
2+
13
from __future__ import division
24
from __future__ import print_function
35
from __future__ import absolute_import

Diff for: xml_to_csv.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# based on https://github.com/datitran/raccoon_dataset/blob/master/xml_to_csv.py
2+
13
import os
24
import glob
35
import pandas as pd

0 commit comments

Comments
 (0)