Spaces:
Running on Zero
Running on Zero
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -51,7 +51,13 @@ def _write_caption(request: str, transparent: bool, palette, seed: int, attempts
|
|
| 51 |
return request
|
| 52 |
|
| 53 |
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
def generate(
|
| 56 |
prompt: str,
|
| 57 |
transparent: bool = True,
|
|
|
|
| 51 |
return request
|
| 52 |
|
| 53 |
|
| 54 |
+
def _gpu_duration(prompt, transparent=True, caption_writer="Auto", *args, **kwargs):
|
| 55 |
+
# measured on ZeroGPU: LLM caption expansion ~8-10 s + reading/drawing ~1-1.5 s; drawing alone ~1-1.5 s
|
| 56 |
+
expand = caption_writer == "Always" or (caption_writer == "Auto" and len((prompt or "").split()) < SHORT_WORDS)
|
| 57 |
+
return 15 if expand else 8
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
@spaces.GPU(duration=_gpu_duration)
|
| 61 |
def generate(
|
| 62 |
prompt: str,
|
| 63 |
transparent: bool = True,
|