kayfahaarukku commited on
Commit
4f0c4ed
1 Parent(s): 5850fbf
Files changed (1) hide show
  1. app.py +3 -8
app.py CHANGED
@@ -1,12 +1,10 @@
1
  import os
 
2
  import torch
3
  from diffusers import StableDiffusionXLPipeline, EulerAncestralDiscreteScheduler
4
  import gradio as gr
5
  import random
6
  import tqdm
7
- from pyngrok import ngrok
8
-
9
- NGROK_API_KEY = os.getenv("NGROK_API_KEY")
10
 
11
  # Enable TQDM progress tracking
12
  tqdm.monitor_interval = 0
@@ -21,6 +19,7 @@ pipe = StableDiffusionXLPipeline.from_pretrained(
21
  pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
22
 
23
  # Function to generate an image
 
24
  def generate_image(prompt, negative_prompt, use_defaults, resolution, guidance_scale, num_inference_steps, seed, randomize_seed, progress=gr.Progress()):
25
  pipe.to('cuda') # Move the model to GPU when the function is called
26
 
@@ -104,8 +103,4 @@ with gr.Blocks(title="UrangDiffusion 1.0 Demo", theme="NoCrypt/[email protected]") as d
104
  ]
105
  )
106
 
107
- # Set up ngrok
108
- public_url = ngrok.connect(api_key=NGROK_API_KEY)
109
- print(f"Public URL: {public_url}")
110
-
111
- demo.queue(max_size=20).launch(server_name="0.0.0.0", server_port=7860)
 
1
  import os
2
+ import spaces
3
  import torch
4
  from diffusers import StableDiffusionXLPipeline, EulerAncestralDiscreteScheduler
5
  import gradio as gr
6
  import random
7
  import tqdm
 
 
 
8
 
9
  # Enable TQDM progress tracking
10
  tqdm.monitor_interval = 0
 
19
  pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
20
 
21
  # Function to generate an image
22
+ @spaces.GPU() # Adjust the duration as needed
23
  def generate_image(prompt, negative_prompt, use_defaults, resolution, guidance_scale, num_inference_steps, seed, randomize_seed, progress=gr.Progress()):
24
  pipe.to('cuda') # Move the model to GPU when the function is called
25
 
 
103
  ]
104
  )
105
 
106
+ demo.queue(max_size=20).launch(share=False)