Sanshruth commited on
Commit
37922b2
1 Parent(s): 1c337e7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -38
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 a simple Gradio interface to notify users
16
  with gr.Blocks() as demo:
17
- gr.HTML("""
18
- <style>
19
- body {
20
- position: relative;
21
- height: 100vh;
22
- width: 100%;
23
- display: flex;
24
- justify-content: center;
25
- align-items: center;
26
- background: rgba(0, 0, 0, 0.1);
27
- filter: blur(10px);
28
- }
29
- .overlay {
30
- position: absolute;
31
- z-index: 10;
32
- color: white;
33
- font-size: 20px;
34
- text-align: center;
35
- padding: 20px;
36
- background-color: rgba(0, 0, 0, 0.7);
37
- border-radius: 10px;
38
- box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.5);
39
- }
40
- .message {
41
- font-size: 22px;
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