<?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: How to do data augmentation for deep learning model in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-do-data-augmentation-for-deep-learning/m-p/1048576#M5937</link>
    <description>&lt;P&gt;Thank you for your great help. I will do and let you know the result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 18 Apr 2021 21:38:57 GMT</pubDate>
    <dc:creator>lienpham83</dc:creator>
    <dc:date>2021-04-18T21:38:57Z</dc:date>
    <item>
      <title>How to do data augmentation for deep learning model</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-do-data-augmentation-for-deep-learning/m-p/1047948#M5919</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I got training data for my deep learning model by using export training data for deep learning tool in Arcgis Pro. I would like to do data augmentation on this training data. So, my code is&amp;nbsp;&lt;/P&gt;&lt;P&gt;data=arcgis.learn.prepare_data(r'G:\data_training',&lt;BR /&gt;class_mapping={0: 'tree'}, chip_size=640, val_split_pct=0.1, batch_size=2,transforms=True,resize_to=800).&lt;/P&gt;&lt;P&gt;When I run the code, it has error:&lt;/P&gt;&lt;PRE&gt;File &lt;SPAN class="ansi-blue-fg"&gt;C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\learn\_data.py&lt;/SPAN&gt;, in &lt;SPAN class="ansi-green-fg"&gt;prepare_data&lt;/SPAN&gt;:
Line &lt;SPAN class="ansi-blue-fg"&gt;1570&lt;/SPAN&gt;:  data = (data.transform(transforms, **kwargs_transforms)

File &lt;SPAN class="ansi-blue-fg"&gt;C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\fastai\data_block.py&lt;/SPAN&gt;, in &lt;SPAN class="ansi-green-fg"&gt;transform&lt;/SPAN&gt;:
Line &lt;SPAN class="ansi-blue-fg"&gt;504&lt;/SPAN&gt;:   &lt;SPAN class="ansi-blue-fg"&gt;assert&lt;/SPAN&gt; is_listy(tfms) &lt;SPAN class="ansi-magenta-fg"&gt;and&lt;/SPAN&gt; &lt;SPAN class="ansi-cyan-fg"&gt;len&lt;/SPAN&gt;(tfms) == &lt;SPAN class="ansi-blue-fg"&gt;2&lt;/SPAN&gt;, &lt;SPAN class="ansi-yellow-fg"&gt;"&lt;/SPAN&gt;&lt;SPAN class="ansi-yellow-fg"&gt;Please pass a list of two lists of transforms (train and valid).&lt;/SPAN&gt;&lt;SPAN class="ansi-yellow-fg"&gt;"&lt;/SPAN&gt;

&lt;SPAN class="ansi-red-fg"&gt;AssertionError&lt;/SPAN&gt;: Please pass a list of two lists of transforms (train and valid)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Could you please suggest how I can fix this error? Thank you for your help&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 03:22:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-do-data-augmentation-for-deep-learning/m-p/1047948#M5919</guid>
      <dc:creator>lienpham83</dc:creator>
      <dc:date>2021-04-16T03:22:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to do data augmentation for deep learning model</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-do-data-augmentation-for-deep-learning/m-p/1047950#M5920</link>
      <description>&lt;P&gt;&lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.learn.toc.html?highlight=learn%20prepare_data#arcgis.learn.prepare_data" target="_blank" rel="noopener"&gt;arcgis.learn module — arcgis 1.8.5 documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;arcgis.learn.prepare_data(path, class_mapping=None, chip_size=224, val_split_pct=0.1, batch_size=64, transforms=None, collate_fn=&amp;lt;function _bb_pad_collate&amp;gt;, seed=42, dataset_type=None, resize_to=None, working_dir=None, **kwargs)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;The first entry is supposed to be a data path, you passed it a string ( 'data_training' ).&amp;nbsp; If data_training is supposed to be the path, dump the single quotes&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 03:07:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-do-data-augmentation-for-deep-learning/m-p/1047950#M5920</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-04-16T03:07:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to do data augmentation for deep learning model</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-do-data-augmentation-for-deep-learning/m-p/1047953#M5921</link>
      <description>&lt;P&gt;My first entry is a path.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 03:14:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-do-data-augmentation-for-deep-learning/m-p/1047953#M5921</guid>
      <dc:creator>lienpham83</dc:creator>
      <dc:date>2021-04-16T03:14:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to do data augmentation for deep learning model</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-do-data-augmentation-for-deep-learning/m-p/1047954#M5922</link>
      <description>&lt;P&gt;see the single quotes around 'data_training'&lt;/P&gt;&lt;P&gt;that makes this a string&lt;/P&gt;&lt;P&gt;drop the single quotes like so..... data_training ...&lt;/P&gt;&lt;P&gt;If that is indeed the path&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 03:17:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-do-data-augmentation-for-deep-learning/m-p/1047954#M5922</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-04-16T03:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to do data augmentation for deep learning model</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-do-data-augmentation-for-deep-learning/m-p/1047955#M5923</link>
      <description>&lt;P&gt;my code :&lt;/P&gt;&lt;P&gt;data=arcgis.learn.prepare_data(r'G:\data_training',&lt;BR /&gt;class_mapping={0: 'tree'}, chip_size=640, val_split_pct=0.1, batch_size=2,transforms=True,resize_to=800)&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 03:22:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-do-data-augmentation-for-deep-learning/m-p/1047955#M5923</guid>
      <dc:creator>lienpham83</dc:creator>
      <dc:date>2021-04-16T03:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to do data augmentation for deep learning model</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-do-data-augmentation-for-deep-learning/m-p/1047958#M5925</link>
      <description>&lt;P&gt;Ahhh I see from your revision history you fixed this&amp;nbsp;&lt;EM&gt;arcgis.learn.prepare_data('data_training',&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;by adding the raw encoded G:\ to it.&amp;nbsp; Good.&lt;/P&gt;&lt;P&gt;At least that was ruled out&lt;/P&gt;&lt;P&gt;Next&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Optional tuple. Fast.ai transforms for data augmentation of training and validation datasets respectively (We have set good defaults which work for satellite imagery well). If transforms is set to False no transformation will take place and chip_size parameter will also not take effect. If the dataset_type is ‘PointCloud’, use Transform3d class from arcgis.learn.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;For transforms it says it is looking for a tuple.... you entered ... True&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 03:31:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-do-data-augmentation-for-deep-learning/m-p/1047958#M5925</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-04-16T03:31:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to do data augmentation for deep learning model</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-do-data-augmentation-for-deep-learning/m-p/1047959#M5926</link>
      <description>&lt;P&gt;Although I used the code&amp;nbsp; below, it still has the same error as in the originial post&lt;/P&gt;&lt;P&gt;data=arcgis.learn.prepare_data(r'G:\data_training',&lt;BR /&gt;class_mapping={0: 'tree'}, chip_size=640, val_split_pct=0.1, batch_size=2,transforms=True,resize_to=800)&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 03:31:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-do-data-augmentation-for-deep-learning/m-p/1047959#M5926</guid>
      <dc:creator>lienpham83</dc:creator>
      <dc:date>2021-04-16T03:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to do data augmentation for deep learning model</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-do-data-augmentation-for-deep-learning/m-p/1047961#M5927</link>
      <description>&lt;P&gt;see my post... you missed the whole transforms thing&lt;/P&gt;&lt;P&gt;&lt;EM&gt;For transforms it says it is looking for a tuple.... you entered ... True&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 03:48:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-do-data-augmentation-for-deep-learning/m-p/1047961#M5927</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-04-16T03:48:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to do data augmentation for deep learning model</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-do-data-augmentation-for-deep-learning/m-p/1047967#M5928</link>
      <description>&lt;P&gt;tfms:Optional[Tuple[TfmList,TfmList]]. What should be TFmList? Is this the folders contain the train images and validation images?&amp;nbsp; How can I get TfmList?&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 04:09:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-do-data-augmentation-for-deep-learning/m-p/1047967#M5928</guid>
      <dc:creator>lienpham83</dc:creator>
      <dc:date>2021-04-16T04:09:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to do data augmentation for deep learning model</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-do-data-augmentation-for-deep-learning/m-p/1047993#M5929</link>
      <description>&lt;P&gt;Esri use a default set of transforms, but I have not been able to find them documented anywhere. Stated on&lt;SPAN&gt;&amp;nbsp;&lt;A href="https://developers.arcgis.com/python/guide/object-detection/" target="_blank" rel="noopener"&gt;this page&lt;/A&gt;&amp;nbsp;:&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;By default, prepare_data() uses a default set of transforms for data augmentation that work well for satellite imagery. These transforms randomly rotate, scale and flip the images so the model sees a different image each time. Alternatively, users can compose their own transforms using fast.ai transforms for the specific data augmentations they wish to perform.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;You will have to dig into the code to find out what is being done for each model type. The prepare_data function is in&amp;nbsp;C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\learn\_data.py&lt;/P&gt;&lt;P&gt;As an example, for MaskRCNN, this is in the code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    if dataset_type == 'RCNN_Masks':
....
        if transforms is None:
            ranges = (0, 1)
            if _image_space_used == _map_space:
                train_tfms = [
                    crop(size=chip_size, p=1., row_pct=ranges, col_pct=ranges),
                    dihedral_affine(),
                    brightness(change=(0.4, 0.6)),
                    contrast(scale=(1.0, 1.5)),
                    rand_zoom(scale=(1.0, 1.2))
                ]
            else:
                train_tfms = [
                    crop(size=chip_size, p=1., row_pct=ranges, col_pct=ranges),
                    brightness(change=(0.4, 0.6)),
                    contrast(scale=(1.0, 1.5)),
                    rand_zoom(scale=(1.0, 1.2))
                ]
            val_tfms = [crop(size=chip_size, p=1., row_pct=0.5, col_pct=0.5)]
            tfms = (train_tfms, val_tfms)&lt;/LI-CODE&gt;&lt;P&gt;So, it clear from the code that you need a list of training transforms and a list of validation transforms. Then they are combined into a tuple and that is what you put in the prepare_data transforms parameter.&lt;/P&gt;&lt;P&gt;Here is the documentation for the fastai transforms:&amp;nbsp;&lt;A href="https://fastai1.fast.ai/vision.transform.html" target="_blank" rel="noopener"&gt;https://fastai1.fast.ai/vision.transform.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something like this should get you started (the get_transforms function is an easy way, but you can individually create your own transforms also):&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from fastai.vision.transform import get_transforms
tfms=get_transforms(do_flip=True, flip_vert=True, max_rotate=None, max_zoom=1, max_lighting=None, max_warp=None, p_affine=None, p_lighting=None, xtra_tfms=None)
tfms=(tfms1,tfms2)
data=arcgis.learn.prepare_data(r'G:\data_training', class_mapping={0: 'tree'}, chip_size=640, val_split_pct=0.1, batch_size=2,transforms=tfms,resize_to=800)&lt;/LI-CODE&gt;&lt;P&gt;I haven't really played around with transforms much yet, so please let me know how you go.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 06:38:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-do-data-augmentation-for-deep-learning/m-p/1047993#M5929</guid>
      <dc:creator>Tim_McGinnes</dc:creator>
      <dc:date>2021-04-16T06:38:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to do data augmentation for deep learning model</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-do-data-augmentation-for-deep-learning/m-p/1048576#M5937</link>
      <description>&lt;P&gt;Thank you for your great help. I will do and let you know the result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Apr 2021 21:38:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-do-data-augmentation-for-deep-learning/m-p/1048576#M5937</guid>
      <dc:creator>lienpham83</dc:creator>
      <dc:date>2021-04-18T21:38:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to do data augmentation for deep learning model</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-do-data-augmentation-for-deep-learning/m-p/1229100#M7974</link>
      <description>&lt;P&gt;No need of providing a tuple (tfms1,tfms2) for transforms. The get_transforms function itself generates two transformations - One for training and the other for validation respectively. Just pass "transforms=tfms" within prepare_data()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2022 11:02:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-do-data-augmentation-for-deep-learning/m-p/1229100#M7974</guid>
      <dc:creator>Sreebhadra_H_R</dc:creator>
      <dc:date>2022-11-07T11:02:15Z</dc:date>
    </item>
  </channel>
</rss>

