<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Object detection with ArcGIS Python API: invalid argument 0: Sizes of tensors must match except in dimension 0 in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/object-detection-with-arcgis-python-api-invalid/m-p/1050391#M5961</link>
    <description>&lt;P&gt;ok, thanks for clarifying.&lt;/P&gt;&lt;P&gt;I trained the model for 30 epochs. The average precision score is 0.56 for one class. The validation loss trended downwards the first few epochs and increased in between, but overall the loss continued to go down with each epoch.&lt;/P&gt;&lt;P&gt;I did model inference using the predict method on an image (part of training set) and got the result below:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AnushaGTI_0-1619125453559.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/11604i620784CD89356C9F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AnushaGTI_0-1619125453559.png" alt="AnushaGTI_0-1619125453559.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Since the image was from the training data set, I expected that the result would be almost accurate. But, the detected results are very inaccurate. It detected the class everywhere but the actual weld. I don't understand why this is the case. Can you explain what could be the reason?&lt;/P&gt;&lt;P&gt;Also, I trained the model on the same data set using YOLOv3 for 30 epochs. The model accuracy is 0.14, which is much less compared to the SSD.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 22 Apr 2021 21:28:49 GMT</pubDate>
    <dc:creator>AnushaGTI</dc:creator>
    <dc:date>2021-04-22T21:28:49Z</dc:date>
    <item>
      <title>Object detection with ArcGIS Python API: invalid argument 0: Sizes of tensors must match except in dimension 0</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/object-detection-with-arcgis-python-api-invalid/m-p/1040627#M5810</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;For our use case, we are trying to detect a type of pipe join/weld in an image. The input images are all non-georeferenced.&lt;/P&gt;&lt;P&gt;Based on prior recommendations by Esri, we labeled the input images (~900) using the LabelImg tool and the labels get saved as xml documents.&amp;nbsp;I tried to train the model with the input images and the generated labels by following this tutorial: (&lt;A href="https://developers.arcgis.com/python/sample-notebooks/automate-road-surface-investigation-using-deep-learning/" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/python/sample-notebooks/automate-road-surface-investigation-using-deep-learning/&lt;/A&gt;).&lt;/P&gt;&lt;P&gt;One thing to point out.. on the &lt;STRONG&gt;prepare_data(data_path, batch_size=8, chip_size=500, seed=42, dataset_type='PASCAL_VOC_rectangles'),&amp;nbsp;&lt;/STRONG&gt;data_path points to source images and it's annotations. It is not clear from the tutorial if we need to generate and use image chips instead. But it didn't throw any errors.&lt;/P&gt;&lt;P&gt;After downloading SSD model, when I try to call &lt;STRONG&gt;ssd.show_results(thresh=0.2)&lt;/STRONG&gt;, I get the error below:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AnushaGTI_1-1616683491632.jpeg" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/9358iFEDDB3C62BF8D0EA/image-size/large?v=v2&amp;amp;px=999" role="button" title="AnushaGTI_1-1616683491632.jpeg" alt="AnushaGTI_1-1616683491632.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Do we need to export the training data as image chips prior to calling the prepare_data()? Does it have any relation to the error above?&lt;/P&gt;&lt;P&gt;Thanks for any input!&lt;/P&gt;&lt;P&gt;Anusha&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Mar 2021 15:40:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/object-detection-with-arcgis-python-api-invalid/m-p/1040627#M5810</guid>
      <dc:creator>AnushaGTI</dc:creator>
      <dc:date>2021-03-25T15:40:00Z</dc:date>
    </item>
    <item>
      <title>Re: Object detection with ArcGIS Python API: invalid argument 0: Sizes of tensors must match except in dimension 0</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/object-detection-with-arcgis-python-api-invalid/m-p/1040859#M5818</link>
      <description>&lt;P&gt;I am using Pro 2.7.2 with the Deep Learning Framework installed using the esri installer. I was able to complete that road surface investigation sample ok without any problems. It could be a problem with your input data. The prepare data function expects a folder with 2 subfolders called &lt;U&gt;images&lt;/U&gt; and &lt;U&gt;labels&lt;/U&gt;&lt;/P&gt;&lt;P&gt;In the images folders should be all your images eg: &lt;U&gt;Adachi_20170906093835.jpg&lt;/U&gt;&lt;/P&gt;&lt;P&gt;In the labels folder, you should have a corresponding xml label file for each image with the same name eg:&amp;nbsp;&lt;U&gt;Adachi_20170906093835.xml&lt;/U&gt;&lt;/P&gt;&lt;P&gt;Each XML file should have something like the following:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;annotation&amp;gt;
    &amp;lt;folder&amp;gt;Adachi&amp;lt;/folder&amp;gt;
    &amp;lt;filename&amp;gt;Adachi_20170906093835.jpg&amp;lt;/filename&amp;gt;
    &amp;lt;size&amp;gt;
        &amp;lt;width&amp;gt;600&amp;lt;/width&amp;gt;
        &amp;lt;height&amp;gt;600&amp;lt;/height&amp;gt;
    &amp;lt;/size&amp;gt;
    &amp;lt;segmented&amp;gt;0&amp;lt;/segmented&amp;gt;
    &amp;lt;object&amp;gt;
        &amp;lt;name&amp;gt;D20&amp;lt;/name&amp;gt;
        &amp;lt;bndbox&amp;gt;
            &amp;lt;xmin&amp;gt;87&amp;lt;/xmin&amp;gt;
            &amp;lt;ymin&amp;gt;281&amp;lt;/ymin&amp;gt;
            &amp;lt;xmax&amp;gt;226&amp;lt;/xmax&amp;gt;
            &amp;lt;ymax&amp;gt;432&amp;lt;/ymax&amp;gt;
        &amp;lt;/bndbox&amp;gt;
    &amp;lt;/object&amp;gt;
&amp;lt;/annotation&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;Are your XML files the same format as this? What format and width\height are your images?&lt;/P&gt;</description>
      <pubDate>Thu, 25 Mar 2021 22:20:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/object-detection-with-arcgis-python-api-invalid/m-p/1040859#M5818</guid>
      <dc:creator>Tim_McGinnes</dc:creator>
      <dc:date>2021-03-25T22:20:15Z</dc:date>
    </item>
    <item>
      <title>Re: Object detection with ArcGIS Python API: invalid argument 0: Sizes of tensors must match except in dimension 0</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/object-detection-with-arcgis-python-api-invalid/m-p/1041532#M5832</link>
      <description>&lt;P&gt;Yes, there are 2 sub folders for images and labels. The labels xml document has a similar structure to the one above.&lt;/P&gt;&lt;P&gt;All the input images are jpeg's and the width/height measurements are not the same and they vary across images. Does the size (width/height) has to be uniform for all the images?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Mar 2021 14:41:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/object-detection-with-arcgis-python-api-invalid/m-p/1041532#M5832</guid>
      <dc:creator>AnushaGTI</dc:creator>
      <dc:date>2021-03-29T14:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: Object detection with ArcGIS Python API: invalid argument 0: Sizes of tensors must match except in dimension 0</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/object-detection-with-arcgis-python-api-invalid/m-p/1041746#M5834</link>
      <description>&lt;P&gt;Yes I think that in order to batch images together they may have to be the same size. There are a couple of things you could try, if the first one doesn't work try the second:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Add resize_to=500 into prepare_data arguments&lt;/LI&gt;&lt;LI&gt;Set batchsize=1 in prepare_data arguments&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;resize_to -&amp;nbsp;Optional integer. Resize the images to a given size. Works only for “PASCAL_VOC_rectangles”, “Labelled_Tiles” and “superres”. First resizes the image to the given size and then crops images of size equal to chip_size. Note: If resize_to is less than chip_size, the resize_to is used as chip_size.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Mar 2021 21:26:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/object-detection-with-arcgis-python-api-invalid/m-p/1041746#M5834</guid>
      <dc:creator>Tim_McGinnes</dc:creator>
      <dc:date>2021-03-29T21:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: Object detection with ArcGIS Python API: invalid argument 0: Sizes of tensors must match except in dimension 0</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/object-detection-with-arcgis-python-api-invalid/m-p/1044762#M5896</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/196223"&gt;@Tim_McGinnes&lt;/a&gt;&amp;nbsp;. I tried the resize_to&amp;nbsp; argument in the prepare_data function and it worked without any errors. I was able to train the model successfully. When I ran the&amp;nbsp;&lt;STRONG&gt;ssd.show_results(rows=10, thresh=0.2, nms_overlap=0.5)&lt;/STRONG&gt; to detect the weld in the validation set, it returns sample results below:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Ground truth&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Predictions&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AnushaGTI_0-1617814006485.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/10354i9FC698B0A2198F2E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AnushaGTI_0-1617814006485.png" alt="AnushaGTI_0-1617814006485.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AnushaGTI_1-1617814418580.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/10356i07498C48C35CBF8D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AnushaGTI_1-1617814418580.png" alt="AnushaGTI_1-1617814418580.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The prediction result for the top image is close to the ground truth (labeled data), but it is completely off for the bottom image. The labeled image does not have the weld, but the trained model has a false positive.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do we need more training data to improve the model accuracy? We used around 900 images to train the model on 1 class and the model accuracy is 0.54.&lt;/P&gt;&lt;P&gt;Also, I want to point out that in ArcGIS Pro, we export the training data as image chips before training the model. It is not clear from the tutorial if we must use the image chips instead of source images for model training. Can you please clarify on this?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Apr 2021 17:34:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/object-detection-with-arcgis-python-api-invalid/m-p/1044762#M5896</guid>
      <dc:creator>AnushaGTI</dc:creator>
      <dc:date>2021-04-07T17:34:41Z</dc:date>
    </item>
    <item>
      <title>Re: Object detection with ArcGIS Python API: invalid argument 0: Sizes of tensors must match except in dimension 0</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/object-detection-with-arcgis-python-api-invalid/m-p/1044879#M5899</link>
      <description>&lt;P&gt;That's great - glad you got the model working. No, you do not need image chips for this type of project - the training data is just the source images as used in, or exported from, LabelImg.&lt;/P&gt;&lt;P&gt;How many epochs did you train the model for? Is the accuracy still improving? The first thing to try would be to train it a bit longer, paying attention to the accuracy values and loss graphs.&lt;/P&gt;&lt;P&gt;The next thing to try would be to use a different model - both FasterRCNN and YOLOv3 are object detection models and may perform better than SSD. Just take a copy of your notebook and you should only need to change a couple of lines, from memory for FasterRCNN it is something like:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;from arcgis.learn import &lt;STRIKE&gt;SingleShotDetector&lt;/STRIKE&gt; FasterRCNN, prepare_data&lt;/LI&gt;&lt;LI&gt;ssd = &lt;STRIKE&gt;SingleShotDetector&lt;/STRIKE&gt; FasterRCNN(data)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Apr 2021 22:04:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/object-detection-with-arcgis-python-api-invalid/m-p/1044879#M5899</guid>
      <dc:creator>Tim_McGinnes</dc:creator>
      <dc:date>2021-04-07T22:04:28Z</dc:date>
    </item>
    <item>
      <title>Re: Object detection with ArcGIS Python API: invalid argument 0: Sizes of tensors must match except in dimension 0</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/object-detection-with-arcgis-python-api-invalid/m-p/1050391#M5961</link>
      <description>&lt;P&gt;ok, thanks for clarifying.&lt;/P&gt;&lt;P&gt;I trained the model for 30 epochs. The average precision score is 0.56 for one class. The validation loss trended downwards the first few epochs and increased in between, but overall the loss continued to go down with each epoch.&lt;/P&gt;&lt;P&gt;I did model inference using the predict method on an image (part of training set) and got the result below:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AnushaGTI_0-1619125453559.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/11604i620784CD89356C9F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AnushaGTI_0-1619125453559.png" alt="AnushaGTI_0-1619125453559.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Since the image was from the training data set, I expected that the result would be almost accurate. But, the detected results are very inaccurate. It detected the class everywhere but the actual weld. I don't understand why this is the case. Can you explain what could be the reason?&lt;/P&gt;&lt;P&gt;Also, I trained the model on the same data set using YOLOv3 for 30 epochs. The model accuracy is 0.14, which is much less compared to the SSD.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 21:28:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/object-detection-with-arcgis-python-api-invalid/m-p/1050391#M5961</guid>
      <dc:creator>AnushaGTI</dc:creator>
      <dc:date>2021-04-22T21:28:49Z</dc:date>
    </item>
  </channel>
</rss>

