Spaces:
Running
on
Zero
Running
on
Zero
Adding warmup function and seed slider
Browse files- .gitignore +1 -0
- app.py +25 -0
.gitignore
CHANGED
|
@@ -8,3 +8,4 @@ diffqrcoder/losses/__pycache__/__init__.cpython-310.pyc
|
|
| 8 |
diffqrcoder/losses/__pycache__/perceptual_loss.cpython-310.pyc
|
| 9 |
diffqrcoder/losses/__pycache__/personalized_code_loss.cpython-310.pyc
|
| 10 |
diffqrcoder/losses/__pycache__/scanning_robust_loss.cpython-310.pyc
|
|
|
|
|
|
| 8 |
diffqrcoder/losses/__pycache__/perceptual_loss.cpython-310.pyc
|
| 9 |
diffqrcoder/losses/__pycache__/personalized_code_loss.cpython-310.pyc
|
| 10 |
diffqrcoder/losses/__pycache__/scanning_robust_loss.cpython-310.pyc
|
| 11 |
+
models/cetusMix_Whalefall2_fp16.safetensors
|
app.py
CHANGED
|
@@ -11,6 +11,18 @@ DEFAULT_PROMPT = (
|
|
| 11 |
|
| 12 |
DEFAULT_NEG = "easynegative"
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
@spaces.GPU
|
| 15 |
def infer(
|
| 16 |
url_or_text: str,
|
|
@@ -20,6 +32,7 @@ def infer(
|
|
| 20 |
scanning_robust_guidance_scale: float,
|
| 21 |
perceptual_guidance_scale: float,
|
| 22 |
srmpgd_iters: int,
|
|
|
|
| 23 |
):
|
| 24 |
try:
|
| 25 |
print("π§ infer() starting")
|
|
@@ -52,6 +65,7 @@ def infer(
|
|
| 52 |
scanning_robust_guidance_scale=scanning_robust_guidance_scale,
|
| 53 |
perceptual_guidance_scale=perceptual_guidance_scale,
|
| 54 |
srmpgd_num_iteration=srmpgd_num_iteration,
|
|
|
|
| 55 |
)
|
| 56 |
|
| 57 |
print("β
generation complete")
|
|
@@ -83,6 +97,15 @@ Generate aesthetic, scanning-robust QR codes using the **DiffQRCoder** pipeline
|
|
| 83 |
lines=3,
|
| 84 |
)
|
| 85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
with gr.Accordion("Advanced parameters", open=False):
|
| 87 |
steps = gr.Slider(
|
| 88 |
minimum=10,
|
|
@@ -133,8 +156,10 @@ Generate aesthetic, scanning-robust QR codes using the **DiffQRCoder** pipeline
|
|
| 133 |
srg_scale,
|
| 134 |
pg_scale,
|
| 135 |
srmpgd_iters,
|
|
|
|
| 136 |
],
|
| 137 |
outputs=[out],
|
| 138 |
)
|
|
|
|
| 139 |
|
| 140 |
demo.launch()
|
|
|
|
| 11 |
|
| 12 |
DEFAULT_NEG = "easynegative"
|
| 13 |
|
| 14 |
+
def warmup():
|
| 15 |
+
"""
|
| 16 |
+
Run once on Space startup, on CPU only.
|
| 17 |
+
Downloads models & builds pipeline into cache.
|
| 18 |
+
"""
|
| 19 |
+
print("π₯ Warmup starting: downloading models & building pipeline on CPU...")
|
| 20 |
+
pipe = load_pipeline()
|
| 21 |
+
print("π₯ Warmup done. Pipeline ready on CPU.")
|
| 22 |
+
|
| 23 |
+
# Optional: return a tiny status string for UI (doesn't have to be used)
|
| 24 |
+
return "Warmup complete."
|
| 25 |
+
|
| 26 |
@spaces.GPU
|
| 27 |
def infer(
|
| 28 |
url_or_text: str,
|
|
|
|
| 32 |
scanning_robust_guidance_scale: float,
|
| 33 |
perceptual_guidance_scale: float,
|
| 34 |
srmpgd_iters: int,
|
| 35 |
+
seed: int
|
| 36 |
):
|
| 37 |
try:
|
| 38 |
print("π§ infer() starting")
|
|
|
|
| 65 |
scanning_robust_guidance_scale=scanning_robust_guidance_scale,
|
| 66 |
perceptual_guidance_scale=perceptual_guidance_scale,
|
| 67 |
srmpgd_num_iteration=srmpgd_num_iteration,
|
| 68 |
+
seed=seed,
|
| 69 |
)
|
| 70 |
|
| 71 |
print("β
generation complete")
|
|
|
|
| 97 |
lines=3,
|
| 98 |
)
|
| 99 |
|
| 100 |
+
seed_input = gr.Slider(
|
| 101 |
+
minimum=0,
|
| 102 |
+
maximum=999999,
|
| 103 |
+
value=42,
|
| 104 |
+
step=1,
|
| 105 |
+
label="Seed",
|
| 106 |
+
)
|
| 107 |
+
|
| 108 |
+
|
| 109 |
with gr.Accordion("Advanced parameters", open=False):
|
| 110 |
steps = gr.Slider(
|
| 111 |
minimum=10,
|
|
|
|
| 156 |
srg_scale,
|
| 157 |
pg_scale,
|
| 158 |
srmpgd_iters,
|
| 159 |
+
seed_input
|
| 160 |
],
|
| 161 |
outputs=[out],
|
| 162 |
)
|
| 163 |
+
demo.load(fn=warmup, inputs=None, outputs=None)
|
| 164 |
|
| 165 |
demo.launch()
|