AsmaAILab commited on
Commit
9e13cc6
·
verified ·
1 Parent(s): abe0f07

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +78 -78
app.py CHANGED
@@ -1,78 +1,78 @@
1
- # --- Gradio Interface Definition ---
2
- import gradio as gr
3
- from regenerate import on_upload_image, handle_generate_button
4
- with gr.Blocks() as demo:
5
-
6
-
7
- gr.Markdown(
8
- """
9
- # Interior Design AI: Regenerate Mode
10
- Upload an image, select objects to regenerate, and provide prompts.
11
- """
12
- )
13
-
14
- with gr.Row():
15
- with gr.Column():
16
- input_image_component = gr.Image(
17
- type="pil",
18
- label="Upload an image of your room (PNG/JPG)",
19
- sources=["upload"],
20
- height=300,
21
- interactive=True # Allow direct image upload
22
- )
23
-
24
-
25
- gr.Markdown("---")
26
- gr.Markdown("### Prompts & Seed")
27
- positive_prompt_textbox = gr.Textbox(
28
- label="Enter prompt",
29
- placeholder="a photograph of a room, interior design, 4k, high resolution",
30
- interactive=False
31
- )
32
-
33
-
34
- gr.Markdown("---")
35
- # gr.Markdown("### Regeneration Options")
36
- # # This replaces the st.expander and st.write explanation
37
- # gr.Markdown("This mode allows you to choose which objects you want to re-generate in the image. "
38
- # "Use the selection dropdown to add or remove objects. If you are ready, press the generate button"
39
- # " to generate the image, which can take up to 30 seconds. If you want to improve the generated image, click"
40
- # " the 'move image to input' button.")
41
-
42
- regenerate_objects_checkboxes = gr.CheckboxGroup(
43
- label="Choose which concepts you want to regenerate in the image",
44
- choices=[], # Populated after image processing
45
- interactive=False
46
- )
47
-
48
-
49
- generate_button = gr.Button("Generate Output", interactive=False)
50
-
51
- with gr.Column():
52
- output_image_display = gr.Image(type="pil", label="Output Image", height=400)
53
-
54
-
55
- # --- Event Listeners ---
56
-
57
- # When an image is uploaded or the "Process Image" button is clicked
58
- input_image_component.upload(
59
- fn=on_upload_image,
60
- inputs=[input_image_component],
61
- outputs=[
62
- input_image_component,
63
- regenerate_objects_checkboxes,
64
- positive_prompt_textbox,
65
- generate_button # Now correctly matched in outputs and function signature
66
- ]
67
- )
68
-
69
- generate_button.click(
70
- fn=handle_generate_button,
71
- inputs=[
72
- positive_prompt_textbox,
73
- regenerate_objects_checkboxes, # This passes the list of selected RGB tuples
74
- ],
75
- outputs=[output_image_display] # Removed the second output
76
- )
77
-
78
- demo.launch(debug=True, share = True)
 
1
+ # --- Gradio Interface Definition ---
2
+ import gradio as gr
3
+ from regenerate import on_upload_image, handle_generate_button
4
+ with gr.Blocks() as demo:
5
+
6
+
7
+ gr.Markdown(
8
+ """
9
+ # Interior Design AI: Regenerate Mode
10
+ Upload an image, select objects to regenerate, and provide prompts.
11
+ """
12
+ )
13
+
14
+ with gr.Row():
15
+ with gr.Column():
16
+ input_image_component = gr.Image(
17
+ type="pil",
18
+ label="Upload an image of your room (PNG/JPG)",
19
+ sources=["upload"],
20
+ height=300,
21
+ interactive=True # Allow direct image upload
22
+ )
23
+
24
+
25
+ gr.Markdown("---")
26
+ gr.Markdown("### Prompts & Seed")
27
+ positive_prompt_textbox = gr.Textbox(
28
+ label="Enter prompt",
29
+ placeholder="a photograph of a room, interior design, 4k, high resolution",
30
+ interactive=False
31
+ )
32
+
33
+
34
+ gr.Markdown("---")
35
+ # gr.Markdown("### Regeneration Options")
36
+ # # This replaces the st.expander and st.write explanation
37
+ # gr.Markdown("This mode allows you to choose which objects you want to re-generate in the image. "
38
+ # "Use the selection dropdown to add or remove objects. If you are ready, press the generate button"
39
+ # " to generate the image, which can take up to 30 seconds. If you want to improve the generated image, click"
40
+ # " the 'move image to input' button.")
41
+
42
+ regenerate_objects_checkboxes = gr.CheckboxGroup(
43
+ label="Choose which concepts you want to regenerate in the image",
44
+ choices=[], # Populated after image processing
45
+ interactive=False
46
+ )
47
+
48
+
49
+ generate_button = gr.Button("Generate Output", interactive=False)
50
+
51
+ with gr.Column():
52
+ output_image_display = gr.Image(type="pil", label="Output Image", height=400)
53
+
54
+
55
+ # --- Event Listeners ---
56
+
57
+ # When an image is uploaded or the "Process Image" button is clicked
58
+ input_image_component.upload(
59
+ fn=on_upload_image,
60
+ inputs=[input_image_component],
61
+ outputs=[
62
+ input_image_component,
63
+ regenerate_objects_checkboxes,
64
+ positive_prompt_textbox,
65
+ generate_button # Now correctly matched in outputs and function signature
66
+ ]
67
+ )
68
+
69
+ generate_button.click(
70
+ fn=handle_generate_button,
71
+ inputs=[
72
+ positive_prompt_textbox,
73
+ regenerate_objects_checkboxes, # This passes the list of selected RGB tuples
74
+ ],
75
+ outputs=[output_image_display] # Removed the second output
76
+ )
77
+
78
+ demo.launch(debug=True)