arcgis.learn.prepare_data with labelImg tool

410
1
Jump to solution
04-29-2020 04:01 PM
KrayFreestone
New Contributor

Has anyone had luck using the prepare_data method with data not exported from the Export Training Data tool in ArcGIS Pro? The documentation suggests prepare_data will take PASCAL_VOC_rectangles from other sources. 

I tried doing the following:

prep = prepare_data(path,dataset_type='PASCAL_VOC_rectangles')‍‍‍

but keep getting:

Please check your dataset. 26 images dont have the corresponding label files.‍‍‍

Per the 1.7 release of the Python API, the prepare_data should be able to take XMLs produced from LabelImg. This has not been working for me. 

The path variable is the path to my folder containing two subfolders, labels and images. Labels contains my XMLs and the images contains (you guessed it) my TIFs. I have tried to mimic how these folders are formatted like in the Export Training Data tool does, and I still cannot get it to work. Now I know the the Export Training Data tool creates some extra files beyond these folders, like .emdmap.txt, something else, but even when I delete these files, and run the prepare_data on the folder created from ArcGIS Pro, it works (but it doesn't work for my images and XMLs used through LabelImg). 

Some stuff below for illustration purposes:

 

Folder structure (identical in both)

XML from Export Training Data

<?xml version="1.0"?>
<annotation>
<filename>000000001.tif</filename>
<source>
<annotation>ArcGIS Pro 2.1</annotation>
</source>
<size>
<width>256</width>
<height>256</height>
<depth>3</depth>
</size>
<object>
<name>1</name>
<bndbox>
<xmin>42.44</xmin>
<ymin>128.19</ymin>
<xmax>160.13</xmax>
<ymax>226.85</ymax>
</bndbox>
</object>
</annotation>
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

XML created through LabelImg (1st one I edited to try and match, 2nd one is what it produces raw).

<?xml version="1.0"?>
<annotation>
<filename>outtif_7500_2500.tif</filename>
<source>
<annotation>ArcGIS Pro 2.1</annotation>
</source>
<size>
<width>2500</width>
<height>2500</height>
<depth>3</depth>
</size>
<object>
<name>car</name>
<bndbox>
<xmin>1798</xmin>
<ymin>1724</ymin>
<xmax>1818</xmax>
<ymax>1779</ymax>
</bndbox>
</object>
<object>
<name>car</name>
<bndbox>
<xmin>1305</xmin>
<ymin>1502</ymin>
<xmax>1361</xmax>
<ymax>1525</ymax>
</bndbox>
</object>
<object>
<name>car</name>
<bndbox>
<xmin>1720</xmin>
<ymin>1418</ymin>
<xmax>1746</xmax>
<ymax>1477</ymax>
</bndbox>
</object>
<object>
<name>car</name>
<bndbox>
<xmin>1084</xmin>
<ymin>1092</ymin>
<xmax>1145</xmax>
<ymax>1115</ymax>
</bndbox>
</object>
<object>
<name>car</name>
<bndbox>
<xmin>1670</xmin>
<ymin>727</ymin>
<xmax>1737</xmax>
<ymax>743</ymax>
</bndbox>
</object>
<object>
<name>car</name>
<bndbox>
<xmin>1902</xmin>
<ymin>869</ymin>
<xmax>1963</xmax>
<ymax>884</ymax>
</bndbox>
</object>
</annotation>
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
<annotation>
<folder>images</folder>
<filename>out.tif_2500_5000.tif</filename>
<path>C:\Users\me\Documents\ArcGIS Pro 2.3\DeepLearning\SPLIT\images\out.tif_2500_5000.tif</path>
<source>
<database>Unknown</database>
</source>
<size>
<width>2500</width>
<height>2500</height>
<depth>3</depth>
</size>
<segmented>0</segmented>
<object>
<name>car</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1446</xmin>
<ymin>523</ymin>
<xmax>1493</xmax>
<ymax>557</ymax>
</bndbox>
</object>
<object>
<name>car</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1468</xmin>
<ymin>605</ymin>
<xmax>1537</xmax>
<ymax>651</ymax>
</bndbox>
</object>
<object>
<name>car</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1494</xmin>
<ymin>460</ymin>
<xmax>1543</xmax>
<ymax>504</ymax>
</bndbox>
</object>
<object>
<name>car</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1336</xmin>
<ymin>102</ymin>
<xmax>1390</xmax>
<ymax>141</ymax>
</bndbox>
</object>
</annotation>
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

David Vitale

Vinay Viswambharan

Rohit Singh

Atma Mani

John Yaist

1 Solution

Accepted Solutions
KrayFreestone
New Contributor
EDIT: solved the problem, not entirely sure what the problem was, but I am guessing it is because there was two periods in my filenames (file.01.tif) and I didn't set my save directory to the labels folder before labeling in LabelImg.

View solution in original post

0 Kudos
1 Reply
KrayFreestone
New Contributor
EDIT: solved the problem, not entirely sure what the problem was, but I am guessing it is because there was two periods in my filenames (file.01.tif) and I didn't set my save directory to the labels folder before labeling in LabelImg.

View solution in original post

0 Kudos