Hi all,
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.
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.
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
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:
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'))
Thanks, that is a useful response. the documentation for the predict() method is available here: https://developers.arcgis.com/python/latest/api-reference/arcgis.learn.toc.html#arcgis.learn.CycleGA...
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