ravikumar101 commited on
Commit
f171301
·
verified ·
1 Parent(s): fe88519

preview of UI

Browse files
Files changed (1) hide show
  1. app.py +40 -4
app.py CHANGED
@@ -1,7 +1,43 @@
1
  import gradio as gr
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
1
  import gradio as gr
2
+ import torch
3
+ from diffusers import StableDiffusionInpaintPipeline
4
 
5
+ pipe = StableDiffusionInpaintPipeline.from_pretrained(
6
+ "stabilityai/stable-diffusion-2-inpainting",
7
+ torch_dtype=torch.float16,
8
+ )
9
+ import gradio as gr
10
+ from PIL import Image
11
+
12
+ def process_image(image: Image.Image, prompt: str, slider_value: int) -> Image.Image:
13
+ # Placeholder function for processing
14
+ # Replace this with your actual processing logic
15
+ # For example, modifying the image based on the slider value and prompt
16
+ processed_image = image.copy() # Just returning a copy for now
17
+ return processed_image
18
+
19
+ with gr.Blocks() as demo:
20
+ # Title at the top center
21
+ gr.Markdown("<h1 style='text-align: center;'>Image Inprinting</h1>")
22
+
23
+ with gr.Row():
24
+ with gr.Column(scale=1):
25
+ # Image upload on the left
26
+ image_input = gr.Image(type='pil', label='Upload Image')
27
+ # Slider below the image upload
28
+ slider = gr.Slider(minimum=1, maximum=4, step=1, value=1, label='Select Zoom')
29
+ # Textbox for prompt
30
+ prompt_input = gr.Textbox(label='Enter Prompt')
31
+ # Submit button
32
+ submit_btn = gr.Button("Submit")
33
+
34
+ with gr.Column(scale=1):
35
+ # Output image on the right
36
+ image_output = gr.Image(label='Output Image')
37
+
38
+ # Event handler to process the image when the button is clicked
39
+ submit_btn.click(fn=process_image, inputs=[image_input, prompt_input, slider], outputs=image_output)
40
+
41
+ # Launch the Gradio app
42
+ demo.launch(debug=True)
43