File size: 1,567 Bytes
ed8261c
f171301
 
ed8261c
5688e62
 
 
 
f171301
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ed8261c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import gradio as gr
import torch
from diffusers import StableDiffusionInpaintPipeline

# pipe = StableDiffusionInpaintPipeline.from_pretrained(
#     "stabilityai/stable-diffusion-2-inpainting",
#     torch_dtype=torch.float16,
# )
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)