Spaces:
Runtime error
Runtime error
Doubleupai
commited on
Commit
•
241b476
1
Parent(s):
37b22fc
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from PIL import Image
|
3 |
+
|
4 |
+
def delete_object(image, mask):
|
5 |
+
# Logic to delete object based on mask
|
6 |
+
return image # Placeholder for the modified image
|
7 |
+
|
8 |
+
def add_object(image, prompt):
|
9 |
+
# Logic to add object based on prompt
|
10 |
+
return image # Placeholder for the modified image
|
11 |
+
|
12 |
+
def change_style(image, style_prompt):
|
13 |
+
# Logic to change style based on prompt
|
14 |
+
return image # Placeholder for the modified image
|
15 |
+
|
16 |
+
with gr.Blocks() as app:
|
17 |
+
gr.Markdown("# Photo Editor")
|
18 |
+
|
19 |
+
with gr.Row():
|
20 |
+
with gr.Column():
|
21 |
+
image_input = gr.Image(type="pil", label="Upload Image")
|
22 |
+
delete_mask = gr.Sketch(label="Draw to Delete Object", tool="brush", color="black", height=200, width=200)
|
23 |
+
delete_button = gr.Button("Delete Object")
|
24 |
+
delete_output = gr.Image(label="Modified Image After Deletion")
|
25 |
+
|
26 |
+
delete_button.click(delete_object, inputs=[image_input, delete_mask], outputs=delete_output)
|
27 |
+
|
28 |
+
with gr.Column():
|
29 |
+
add_prompt = gr.Textbox(label="Prompt to Add Object")
|
30 |
+
add_button = gr.Button("Add Object")
|
31 |
+
add_output = gr.Image(label="Modified Image After Adding Object")
|
32 |
+
|
33 |
+
add_button.click(add_object, inputs=[image_input, add_prompt], outputs=add_output)
|
34 |
+
|
35 |
+
with gr.Column():
|
36 |
+
style_prompt = gr.Textbox(label="Style Prompt")
|
37 |
+
style_button = gr.Button("Change Style")
|
38 |
+
style_output = gr.Image(label="Image with New Style")
|
39 |
+
|
40 |
+
style_button.click(change_style, inputs=[image_input, style_prompt], outputs=style_output)
|
41 |
+
|
42 |
+
app.launch()
|