tomiconic commited on
Commit
ff6e57d
Β·
verified Β·
1 Parent(s): f037026

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import gradio as gr
2
  import torch
3
  from diffusers import StableDiffusionXLPipeline, DPMSolverMultistepScheduler
 
4
  import random
5
 
6
  # ── Device detection ───────────────────────────────────────────────────────────
@@ -13,16 +14,23 @@ print(f"Running on: {DEVICE.upper()} | dtype: {DTYPE}")
13
  MODEL_REPO = "cyberdelia/CyberRealisticPony"
14
  MODEL_FILE = "CyberRealisticPony_V16.0_FP16.safetensors"
15
 
16
- # ── Pony quality tags (added automatically β€” do not type these in your prompt) ─
17
  PONY_POS_PREFIX = "score_9, score_8_up, score_7_up, "
18
  PONY_NEG_PREFIX = "score_6, score_5, score_4, "
19
 
20
- # ── Load model ─────────────────────────────────────────────────────────────────
21
- print("Loading model β€” this may take several minutes on first start...")
 
 
 
 
 
 
 
 
22
 
23
  pipe = StableDiffusionXLPipeline.from_single_file(
24
- MODEL_REPO,
25
- weight_name=MODEL_FILE,
26
  torch_dtype=DTYPE,
27
  )
28
 
@@ -104,7 +112,7 @@ with gr.Blocks(title="CyberRealistic Pony", theme=gr.themes.Soft()) as demo:
104
  height = gr.Slider(minimum=512, maximum=1152, value=896, step=64, label="Height")
105
 
106
  gr.Markdown("### Sampling")
107
- steps = gr.Slider(minimum=10, maximum=30, value=20, step=1, label="Steps β€” keep low on CPU")
108
  guidance = gr.Slider(minimum=1.0, maximum=12.0, value=5.0, step=0.5, label="Guidance Scale (CFG) β€” recommended: 5")
109
 
110
  gr.Markdown("### Seed")
 
1
  import gradio as gr
2
  import torch
3
  from diffusers import StableDiffusionXLPipeline, DPMSolverMultistepScheduler
4
+ from huggingface_hub import hf_hub_download
5
  import random
6
 
7
  # ── Device detection ───────────────────────────────────────────────────────────
 
14
  MODEL_REPO = "cyberdelia/CyberRealisticPony"
15
  MODEL_FILE = "CyberRealisticPony_V16.0_FP16.safetensors"
16
 
17
+ # ── Pony quality tags ──────────────────────────────────────────────────────────
18
  PONY_POS_PREFIX = "score_9, score_8_up, score_7_up, "
19
  PONY_NEG_PREFIX = "score_6, score_5, score_4, "
20
 
21
+ # ── Download then load from local path ────────────────────────────────────────
22
+ print("Downloading model β€” this may take several minutes on first start...")
23
+
24
+ local_path = hf_hub_download(
25
+ repo_id=MODEL_REPO,
26
+ filename=MODEL_FILE,
27
+ )
28
+
29
+ print(f"Model downloaded to: {local_path}")
30
+ print("Loading pipeline...")
31
 
32
  pipe = StableDiffusionXLPipeline.from_single_file(
33
+ local_path,
 
34
  torch_dtype=DTYPE,
35
  )
36
 
 
112
  height = gr.Slider(minimum=512, maximum=1152, value=896, step=64, label="Height")
113
 
114
  gr.Markdown("### Sampling")
115
+ steps = gr.Slider(minimum=10, maximum=30, value=20, step=1, label="Steps β€” keep low on CPU")
116
  guidance = gr.Slider(minimum=1.0, maximum=12.0, value=5.0, step=0.5, label="Guidance Scale (CFG) β€” recommended: 5")
117
 
118
  gr.Markdown("### Seed")