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

img2img added + update input descriptions #23

Merged
merged 6 commits into from
Sep 5, 2024
Merged

img2img added + update input descriptions #23

merged 6 commits into from
Sep 5, 2024

Conversation

zsxkib
Copy link
Contributor

@zsxkib zsxkib commented Sep 4, 2024

TLDR: Added image-to-image (img2img) functionality.

• Created img2img pipelines for dev and schnell models
• Integrated img2img into the predict method
• Added logic to detect img2img mode from inputs

• Improved handling of input images and masks for inpainting
• Adjusted image resizing for inpainting

• Updated input descriptions for width, height, and aspect ratio
• Added explanations for when inputs are ignored

• Allowed input images to override aspect ratio and dimensions
• Kept compatibility with existing txt2img feature

• Reused pipeline components to reduce memory use

@zsxkib
Copy link
Contributor Author

zsxkib commented Sep 4, 2024

predict.py Outdated
)
# Override width and height
width, height = resized_width, resized_height
flux_kwargs["image"] = input_image.resize((width, height), Image.LANCZOS)
Copy link
Member

Choose a reason for hiding this comment

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

Resizing creates artifacts, could we crop to the nearest smaller multiple of 16 instead?

- Crop images for img2img and inpaint modes (from center)
- Make dimensions multiples of 16 (round down)
- Avoid resizing artifacts
@zsxkib zsxkib merged commit a889701 into main Sep 5, 2024
2 checks passed
@zsxkib zsxkib deleted the img2img branch September 6, 2024 13:51
@mountainguan
Copy link

mountainguan commented Oct 6, 2024

@zsxkib
Hi,when I use an image of a woman in a bikini as a prompt for img2img generation, I get an NSFW error. However, using the keyword "bikini" directly in text2img generation doesn't trigger the error.

@zsxkib
Copy link
Contributor Author

zsxkib commented Oct 6, 2024

Hey @mountainguan, thanks for bringing this up. What you're seeing is likely due to our safety checker kicking in. You can actually bypass this when using the API by setting disable_safety_checker=True.

Just a heads up though - this safety feature can't be turned off on the website version. If you're curious about how we handle platform safety, check out our docs: Replicate's approach to safety

Let me know if you need any more details!

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.

3 participants