Update app.py
Browse files
app.py
CHANGED
@@ -12,45 +12,33 @@ matplotlib.use('Agg') # Use Agg backend
|
|
12 |
|
13 |
# Check for CUDA availability
|
14 |
if not torch.cuda.is_available():
|
15 |
-
# If CUDA isn't available, create
|
16 |
with gr.Blocks() as demo:
|
17 |
-
gr.
|
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 |
-
margin-top: 20px;
|
43 |
-
}
|
44 |
-
</style>
|
45 |
-
<div class="overlay">
|
46 |
-
<h1>CUDA is not available</h1>
|
47 |
-
<p>Please clone the repository or run it in Colab:</p>
|
48 |
-
<a href="https://github.com/SanshruthR/Stable-Diffusion-Inpainting_with_SAM" style="color: #1e90ff; text-decoration: underline;">GitHub Repository</a>
|
49 |
-
<div class="message">
|
50 |
-
<p>We are currently unable to run on this machine because CUDA is missing.</p>
|
51 |
-
</div>
|
52 |
-
</div>
|
53 |
-
""")
|
54 |
demo.launch(share=True, debug=True)
|
55 |
exit() # Exit the program if CUDA is not available
|
56 |
|
|
|
12 |
|
13 |
# Check for CUDA availability
|
14 |
if not torch.cuda.is_available():
|
15 |
+
# If CUDA isn't available, create the Gradio interface but disable all elements and show a warning
|
16 |
with gr.Blocks() as demo:
|
17 |
+
gr.Markdown("# Segment Anything + Stable Diffusion Inpainting")
|
18 |
+
|
19 |
+
# Show warning message for users with a link to the GitHub repository
|
20 |
+
gr.Markdown("**CUDA is not available.** Please run it on Google Colab. You can find the Colab here: [Colab Link](https://github.com/SanshruthR/Stable-Diffusion-Inpainting_with_SAM)")
|
21 |
+
|
22 |
+
# Step 1: Segment Image Tab
|
23 |
+
with gr.Tab("Step 1: Segment Image"):
|
24 |
+
with gr.Row():
|
25 |
+
input_image = gr.Image(label="Input Image", interactive=False)
|
26 |
+
mask_output = gr.Plot(label="Available Masks", interactive=False)
|
27 |
+
segment_btn = gr.Button("Generate Masks", interactive=False)
|
28 |
+
|
29 |
+
# Step 2: Inpainting Tab
|
30 |
+
with gr.Tab("Step 2: Inpaint"):
|
31 |
+
with gr.Row():
|
32 |
+
with gr.Column():
|
33 |
+
mask_index = gr.Slider(minimum=0, maximum=20, step=1,
|
34 |
+
label="Mask Index (select based on mask numbers from Step 1)", interactive=False)
|
35 |
+
prompt1 = gr.Textbox(label="Prompt 1", placeholder="Enter first inpainting prompt", interactive=False)
|
36 |
+
prompt2 = gr.Textbox(label="Prompt 2", placeholder="Enter second inpainting prompt", interactive=False)
|
37 |
+
prompt3 = gr.Textbox(label="Prompt 3", placeholder="Enter third inpainting prompt", interactive=False)
|
38 |
+
prompt4 = gr.Textbox(label="Prompt 4", placeholder="Enter fourth inpainting prompt", interactive=False)
|
39 |
+
inpaint_output = gr.Plot(label="Inpainting Results", interactive=False)
|
40 |
+
inpaint_btn = gr.Button("Generate Inpainting", interactive=False)
|
41 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
demo.launch(share=True, debug=True)
|
43 |
exit() # Exit the program if CUDA is not available
|
44 |
|