Spaces:
Sleeping
Sleeping
import gradio as gr | |
import torch | |
from diffusers import StableDiffusionInpaintPipeline | |
pipe = StableDiffusionInpaintPipeline.from_pretrained( | |
"stabilityai/stable-diffusion-2-inpainting", | |
torch_dtype=torch.float16, | |
) | |
import gradio as gr | |
from PIL import Image | |
def process_image(image: Image.Image, prompt: str, slider_value: int) -> Image.Image: | |
# Placeholder function for processing | |
# Replace this with your actual processing logic | |
# For example, modifying the image based on the slider value and prompt | |
processed_image = image.copy() # Just returning a copy for now | |
return processed_image | |
with gr.Blocks() as demo: | |
# Title at the top center | |
gr.Markdown("<h1 style='text-align: center;'>Image Inprinting</h1>") | |
with gr.Row(): | |
with gr.Column(scale=1): | |
# Image upload on the left | |
image_input = gr.Image(type='pil', label='Upload Image') | |
# Slider below the image upload | |
slider = gr.Slider(minimum=1, maximum=4, step=1, value=1, label='Select Zoom') | |
# Textbox for prompt | |
prompt_input = gr.Textbox(label='Enter Prompt') | |
# Submit button | |
submit_btn = gr.Button("Submit") | |
with gr.Column(scale=1): | |
# Output image on the right | |
image_output = gr.Image(label='Output Image') | |
# Event handler to process the image when the button is clicked | |
submit_btn.click(fn=process_image, inputs=[image_input, prompt_input, slider], outputs=image_output) | |
# Launch the Gradio app | |
demo.launch(debug=True) | |