VectorSpaceLab / OmniGen

OmniGen: Unified Image Generation. https://arxiv.org/pdf/2409.11340
MIT License
2.57k stars 190 forks source link

Demo: save generated images #38

Closed rubendax closed 6 days ago

rubendax commented 2 weeks ago

Changes:

Tested these changes on a Linux machine with A6000 GPU.

EDIT 2024-11-05:

staoxiao commented 2 weeks ago

Thank you for your contribution. However, I'm not sure if users want to save all the images.

rubendax commented 2 weeks ago

That's fair. To be honest, when I first tried the Gradio demo, I did not see any way to download the generated image in the interface, which is why I added this. I see now that it is possible to download an image by clicking in the upper right corner of the generated image in the UI.

That being said, automatic image saving is fairly common in image generation apps, and it can be helpful in the case that the Gradio interface has an error, which can sometimes occur during a long generation. However, this is more of a personal preference than a necessary feature.

~I have now commented-out the automatic image saving in this branch, just in case you still want to incorporate the spelling/grammar edits.~

Thanks so much for your work on this incredible project. OmniGen is truly a paradigm shift in image generation.

vootox commented 1 week ago

Thank you rubendax, I'd been searching specifically for how to enable this ability and found it here.

I appreciate the ability to save to a folder of choice, downloading each time to the browser's default download folder was becoming cluttered. Although the PNG files are much larger, having this convenience is worth the option for me.

Also, since I didn't know how to use GitHub correctly to use the 'branch' I manually swapped app.py for this pull request to my installation. My guess is that's not the way to do it!

As a hobbyist, OmniGen is already a much-appreciated part of my toolkit; this is only my 2nd day of using it.

PS: In hindsight, I was too hasty. I see some functionality missing now. But by adding instead only the following lines it 'appears' all the functionality is back, possibly? Time wil tell!

`from datetime import datetime

img = output[0]

os.makedirs('outputs', exist_ok=True)

timestamp = datetime.now().strftime("%Y%m%d-%H%M%S") output_path = os.path.join('outputs', f'{timestamp}.png')

img.save(output_path)

return img`

rubendax commented 1 week ago

@vootox You should clone my branch called demo-save_outputs. This has the auto-saving functionality enabled and is otherwise up-to-date with all the improvements from upstream VectorSpaceLab:main (at least as of today 2024-11-05).

git clone -b demo-save_outputs https://github.com/rubendax/OmniGen
rubendax commented 1 week ago

I have added a checkbox to the UI to allow the user to toggle on or off saving all generated images as .png files to ./outputs. In this branch, rubendax:main, this functionality is toggled off (unchecked) by default. save_generated_images

vootox commented 1 week ago

@vootox You should clone my branch called demo-save_outputs. This has the auto-saving functionality enabled and is otherwise up-to-date with all the improvements from upstream VectorSpaceLab:main (at least as of today 2024-11-05).

git clone -b demo-save_outputs https://github.com/rubendax/OmniGen

Thank you @rubendax, I have this installed and running, I like this a lot. Now, I'm wondering if there could be a script for batch processing images... just kidding, but it would be nice!

staoxiao commented 1 week ago

@rubendax, thanks for your code! I think it is reasonable to let the user choose whether to save all the images or not, and I will merge this PR into the main branch tomorrow.