Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support --batch parameter #29

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

SivanMehta
Copy link

@SivanMehta SivanMehta commented Sep 21, 2022

This PR allows passing the --batch parameter on the command line so that more than one image can be generated at once. By default, this is set to 1 to replicate existing functionality when this parameter is not provided.

When using batched generation, output is updated to indicate each file that is generated:

$ python text2image.py --prompt="nothing" --output="test.png" --batch=4

# generator output

saved at test-1.png
saved at test-2.png
saved at test-3.png
saved at test-4.png

I am very open to updated the design of the output if you think that something else would work better.

@SivanMehta
Copy link
Author

SivanMehta commented Sep 21, 2022

I think that #13 would implement this entirely, feel free to close this if that one is merged.

Image.fromarray(img[0]).save(args.output)
print(f"saved at {args.output}")

if(args.batch <= 1):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it not be simpler...


for i in enumerate(img):

    Image.fromarray(img[i]).save("{}_{}".format(i,args.output))

    print("Saved at {}_{}".format(i, args.output))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants