mango-torch

byFc mobile

import torch from diffusers import StableDiffusionImg2ImgPipeline from PIL import Image import gradio as gr # Load model once device = "cuda" if torch.cuda.is_available() else "cpu" pipe = StableDiffusionImg2ImgPipeline.from_pretrained( "runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16 if device == "cuda" else torch.float32 ).to(device) # Function to process image def edit_image(input_image, prompt, strength, guidance): if input_image is None: return None image = input_image.convert("RGB").resize((512, 512)) result = pipe( prompt=prompt, image=image, strength=strength, guidance_scale=guidance ) return result.images[0] # UI Layout app = gr.Interface( fn=edit_image, inputs=[ gr.Image(type="pil", label="Upload Image"), gr.Textbox(label="Prompt", placeholder="Describe the edit (e.g. futuristic, anime, cinematic lighting)"), gr.Slider(0.1, 1.0, value=0.6, label="Strength (change level)"), gr.Slider(1, 15, value=7.5, label="Guidance Scale") ], outputs=gr.Image(label="Edited Image"), title="AI Image-to-Image Editor", description="Upload an image and describe how you want it edited." ) # Launch app app.launch()

Landing
Landing

Comments (0)

No comments yet. Be the first!

Landing design preview
Landing: View Intro
Editor: Upload Image
Editor: Enter Prompt
Editor: Adjust Parameters
Editor: Process Image
Results: Compare Images
Results: Download Output
BatchQueue: Upload Multiple