<?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: Save predicted images using cyclegan.predict() in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/save-predicted-images-using-cyclegan-predict/m-p/1588181#M73776</link>
    <description>&lt;P&gt;Thanks, that is a useful response. the documentation for the predict() method is available here:&amp;nbsp;&lt;A href="https://developers.arcgis.com/python/latest/api-reference/arcgis.learn.toc.html#arcgis.learn.CycleGAN.predict" target="_blank"&gt;https://developers.arcgis.com/python/latest/api-reference/arcgis.learn.toc.html#arcgis.learn.CycleGAN.predict&lt;/A&gt;&lt;/P&gt;&lt;P&gt;It seems the only arguments this function takes are the input image path and convert_to. I am not sure what another option would be to have the image returned in a way I could save it&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Feb 2025 20:30:35 GMT</pubDate>
    <dc:creator>NathanHeuver</dc:creator>
    <dc:date>2025-02-21T20:30:35Z</dc:date>
    <item>
      <title>Save predicted images using cyclegan.predict()</title>
      <link>https://community.esri.com/t5/python-questions/save-predicted-images-using-cyclegan-predict/m-p/1585830#M73749</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;Having trained a cyclegan model using my data, I am now trying to batch generate images based off of validation data that I can use for analysis. A problem I am encountering is that the cyclegan.predict() function only prints a predicted image and nothing is returned. I am able to save an image using my python IDE (VS code), but there doesn't seem to be a way that I can have the predicted image returned in a format that I can save by specifying an output directory. Is there some other way to batch-save predicted images using a cyclegan model? Please see my attached screenshot to see what I am trying to do.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="NathanHeuver_0-1739663828329.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/125474iE6A1E91C1A80A283/image-size/medium?v=v2&amp;amp;px=400" role="button" title="NathanHeuver_0-1739663828329.png" alt="NathanHeuver_0-1739663828329.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Feb 2025 23:57:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/save-predicted-images-using-cyclegan-predict/m-p/1585830#M73749</guid>
      <dc:creator>NathanHeuver</dc:creator>
      <dc:date>2025-02-15T23:57:34Z</dc:date>
    </item>
    <item>
      <title>Re: Save predicted images using cyclegan.predict()</title>
      <link>https://community.esri.com/t5/python-questions/save-predicted-images-using-cyclegan-predict/m-p/1586022#M73753</link>
      <description>&lt;P&gt;I am not totally sure what predict method you're using in your script. There seem to be some that operate with co-routines and others that use multiprocessing depending on your base model.&lt;/P&gt;&lt;P&gt;Because you're getting a NoneType error, you are likely not capturing the predict output properly and are operating on a void method instead of the file that it generated&lt;/P&gt;&lt;P&gt;It seems like what's happening here is that the `.predict()` call is sending a byte stream to stdout (print) and returning none. There might be a parameter that changes this behavior in the function parameters, but without access to that I can't tell. You could try capturing that with a BytesIO object or just a Path object passed to open() if the predict method allows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from pathlib import Path
out_path = Path('./output.jpg')
in_path = Path('./input')

# I don't know what function this actually is, just look for some output
# stream or file object that is passed to the function, it'll look like 
# print('Message', file=SupportsWrite[bytes])
cyclegan.predict(str(in_path), convert_to='A', file=out_path.open('wb'))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2025 13:19:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/save-predicted-images-using-cyclegan-predict/m-p/1586022#M73753</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2025-02-17T13:19:25Z</dc:date>
    </item>
    <item>
      <title>Re: Save predicted images using cyclegan.predict()</title>
      <link>https://community.esri.com/t5/python-questions/save-predicted-images-using-cyclegan-predict/m-p/1588181#M73776</link>
      <description>&lt;P&gt;Thanks, that is a useful response. the documentation for the predict() method is available here:&amp;nbsp;&lt;A href="https://developers.arcgis.com/python/latest/api-reference/arcgis.learn.toc.html#arcgis.learn.CycleGAN.predict" target="_blank"&gt;https://developers.arcgis.com/python/latest/api-reference/arcgis.learn.toc.html#arcgis.learn.CycleGAN.predict&lt;/A&gt;&lt;/P&gt;&lt;P&gt;It seems the only arguments this function takes are the input image path and convert_to. I am not sure what another option would be to have the image returned in a way I could save it&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Feb 2025 20:30:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/save-predicted-images-using-cyclegan-predict/m-p/1588181#M73776</guid>
      <dc:creator>NathanHeuver</dc:creator>
      <dc:date>2025-02-21T20:30:35Z</dc:date>
    </item>
  </channel>
</rss>

