Tanut commited on
Commit
7c5aece
·
1 Parent(s): d9f072c
Files changed (1) hide show
  1. app.py +6 -9
app.py CHANGED
@@ -1,13 +1,11 @@
1
- import os, gc, random
2
  import gradio as gr
3
  import torch, spaces
4
  from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
5
 
6
  # ---- config ----
7
  MODEL_ID = "runwayml/stable-diffusion-v1-5"
8
- DTYPE = torch.float16 # ZeroGPU slice supports fp16
9
- HF_TOKEN = os.getenv("HF_TOKEN") # optional (only for private models)
10
- AUTH = {"token": HF_TOKEN} if HF_TOKEN else {}
11
 
12
  # lazy cache
13
  _PIPE = None
@@ -21,13 +19,12 @@ def get_pipe():
21
  safety_checker=None,
22
  use_safetensors=True,
23
  low_cpu_mem_usage=True,
24
- **AUTH
25
  )
26
  # fast, stable scheduler
27
  pipe.scheduler = DPMSolverMultistepScheduler.from_config(
28
  pipe.scheduler.config, use_karras_sigmas=True, algorithm_type="dpmsolver++"
29
  )
30
- # memory savers (good for Spaces/ZeroGPU)
31
  pipe.enable_attention_slicing()
32
  pipe.enable_vae_slicing()
33
  pipe.enable_model_cpu_offload()
@@ -63,9 +60,9 @@ def generate(prompt: str, negative: str, steps: int, cfg: float, width: int, hei
63
  )
64
  return out.images[0]
65
 
66
- # -------- UI (one output, zero fancy) --------
67
  with gr.Blocks() as demo:
68
- gr.Markdown("# 🎨 Stable Diffusion 1.5 — ZeroGPU (minimal)")
69
 
70
  with gr.Row():
71
  with gr.Column():
@@ -83,5 +80,5 @@ with gr.Blocks() as demo:
83
  btn.click(generate, [prompt, negative, steps, cfg, width, height, seed], out)
84
 
85
  if __name__ == "__main__":
86
- # keep it plain so the Space "just builds"
87
  demo.launch()
 
1
+ import gc, random
2
  import gradio as gr
3
  import torch, spaces
4
  from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
5
 
6
  # ---- config ----
7
  MODEL_ID = "runwayml/stable-diffusion-v1-5"
8
+ DTYPE = torch.float16 # ZeroGPU slice runs fp16 nicely
 
 
9
 
10
  # lazy cache
11
  _PIPE = None
 
19
  safety_checker=None,
20
  use_safetensors=True,
21
  low_cpu_mem_usage=True,
 
22
  )
23
  # fast, stable scheduler
24
  pipe.scheduler = DPMSolverMultistepScheduler.from_config(
25
  pipe.scheduler.config, use_karras_sigmas=True, algorithm_type="dpmsolver++"
26
  )
27
+ # memory savers (great for Spaces/ZeroGPU)
28
  pipe.enable_attention_slicing()
29
  pipe.enable_vae_slicing()
30
  pipe.enable_model_cpu_offload()
 
60
  )
61
  return out.images[0]
62
 
63
+ # -------- UI --------
64
  with gr.Blocks() as demo:
65
+ gr.Markdown("# 🎨 Stable Diffusion 1.5 — ZeroGPU (public, minimal)")
66
 
67
  with gr.Row():
68
  with gr.Column():
 
80
  btn.click(generate, [prompt, negative, steps, cfg, width, height, seed], out)
81
 
82
  if __name__ == "__main__":
83
+ # Keep it plain so the Space builds cleanly
84
  demo.launch()