Spaces:
Runtime error
Runtime error
Optimize GPU quota usage and add authentication notices
Browse files- Reduce ZeroGPU duration from 150 to 120 seconds (unauthenticated limit)
- Disable upscaling by default in artistic pipeline to save GPU time
- Add GPU quota notice for authenticated vs unauthenticated users
- Add warning about large image sizes (1024px) exceeding quota
- Add tip to disable animation and upscaling to maximize quota
- Update default enable_upscale to False in function and JSON loader
- Update UI descriptions for upscaling and quota management
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -577,7 +577,7 @@ def compile_models_with_aoti():
|
|
| 577 |
return False
|
| 578 |
|
| 579 |
|
| 580 |
-
@spaces.GPU(duration=
|
| 581 |
def generate_qr_code_unified(
|
| 582 |
prompt: str,
|
| 583 |
negative_prompt: str = "ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, body out of frame, blurry, bad anatomy, blurred, watermark, grainy, signature, cut off, draft, closed eyes, text, logo",
|
|
@@ -1114,7 +1114,7 @@ def generate_artistic_qr(
|
|
| 1114 |
module_drawer: str = "Square",
|
| 1115 |
use_custom_seed: bool = False,
|
| 1116 |
seed: int = 0,
|
| 1117 |
-
enable_upscale: bool =
|
| 1118 |
enable_animation: bool = True,
|
| 1119 |
enable_freeu: bool = True,
|
| 1120 |
freeu_b1: float = 1.4,
|
|
@@ -1487,7 +1487,7 @@ def load_settings_from_json_artistic(json_string: str):
|
|
| 1487 |
module_drawer = params.get("module_drawer", "Square")
|
| 1488 |
use_custom_seed = params.get("use_custom_seed", True)
|
| 1489 |
seed = params.get("seed", 718313)
|
| 1490 |
-
enable_upscale = params.get("enable_upscale",
|
| 1491 |
enable_freeu = params.get("enable_freeu", True)
|
| 1492 |
freeu_b1 = params.get("freeu_b1", 1.4)
|
| 1493 |
freeu_b2 = params.get("freeu_b2", 1.3)
|
|
@@ -2514,6 +2514,12 @@ if __name__ == "__main__" and not os.environ.get("QR_TESTING_MODE"):
|
|
| 2514 |
**Privacy Notice:** Generated images are automatically deleted after 1 hour.
|
| 2515 |
Temporary files are checked and cleaned every hour. Download your QR codes promptly after generation.
|
| 2516 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2517 |
### Tips:
|
| 2518 |
- Use detailed prompts for better results
|
| 2519 |
- Include style keywords like 'photorealistic', 'detailed', '8k'
|
|
@@ -2521,11 +2527,11 @@ if __name__ == "__main__" and not os.environ.get("QR_TESTING_MODE"):
|
|
| 2521 |
- Try the examples below for inspiration
|
| 2522 |
- **Animation** (enabled by default): Shows intermediate generation steps every 5 steps. Disable for faster generation. (Available in "Change Settings Manually")
|
| 2523 |
- **Color Quantization** (disabled by default): Optional feature to specify a custom color scheme (2-4 colors) for your QR code. Perfect for matching brand colors or creating themed designs with gradient variations. (Available in "Change Settings Manually")
|
| 2524 |
-
- **Upscale Image**: Enhances output quality with RealESRGAN (
|
| 2525 |
- **Copy/paste settings**: After generation, copy the JSON settings string that appears below the image and paste it into "Import Settings from JSON" to reproduce exact results or share with others
|
| 2526 |
|
| 2527 |
### Two Modes:
|
| 2528 |
-
- **Artistic QR** (New pipeline, default): More artistic and creative results with upscaling (slower, more creative, less scannable)
|
| 2529 |
- **Standard QR** (Old pipeline, more stable): Stable, accurate QR code generation (faster, more scannable, less creative)
|
| 2530 |
|
| 2531 |
### Note:
|
|
@@ -2716,8 +2722,8 @@ if __name__ == "__main__" and not os.environ.get("QR_TESTING_MODE"):
|
|
| 2716 |
# Add upscale checkbox
|
| 2717 |
artistic_enable_upscale = gr.Checkbox(
|
| 2718 |
label="Enable Upscaling",
|
| 2719 |
-
value=
|
| 2720 |
-
info="Enable upscaling with RealESRGAN for higher quality output (
|
| 2721 |
)
|
| 2722 |
|
| 2723 |
# Animation toggle
|
|
|
|
| 577 |
return False
|
| 578 |
|
| 579 |
|
| 580 |
+
@spaces.GPU(duration=120) # Max duration for unauthenticated users
|
| 581 |
def generate_qr_code_unified(
|
| 582 |
prompt: str,
|
| 583 |
negative_prompt: str = "ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, body out of frame, blurry, bad anatomy, blurred, watermark, grainy, signature, cut off, draft, closed eyes, text, logo",
|
|
|
|
| 1114 |
module_drawer: str = "Square",
|
| 1115 |
use_custom_seed: bool = False,
|
| 1116 |
seed: int = 0,
|
| 1117 |
+
enable_upscale: bool = False,
|
| 1118 |
enable_animation: bool = True,
|
| 1119 |
enable_freeu: bool = True,
|
| 1120 |
freeu_b1: float = 1.4,
|
|
|
|
| 1487 |
module_drawer = params.get("module_drawer", "Square")
|
| 1488 |
use_custom_seed = params.get("use_custom_seed", True)
|
| 1489 |
seed = params.get("seed", 718313)
|
| 1490 |
+
enable_upscale = params.get("enable_upscale", False)
|
| 1491 |
enable_freeu = params.get("enable_freeu", True)
|
| 1492 |
freeu_b1 = params.get("freeu_b1", 1.4)
|
| 1493 |
freeu_b2 = params.get("freeu_b2", 1.3)
|
|
|
|
| 2514 |
**Privacy Notice:** Generated images are automatically deleted after 1 hour.
|
| 2515 |
Temporary files are checked and cleaned every hour. Download your QR codes promptly after generation.
|
| 2516 |
|
| 2517 |
+
**GPU Quota Notice:**
|
| 2518 |
+
- **Unauthenticated users**: 120 seconds daily quota (~1 generation). Please log in for more usage.
|
| 2519 |
+
- **Free authenticated users**: 210 seconds daily quota (~3-5 generations depending on settings).
|
| 2520 |
+
- **⚠️ Warning**: Large image sizes (1024px) may exceed quota even for a single generation! Use smaller sizes (512-768px) for better quota management.
|
| 2521 |
+
- **💡 Tip**: Disable animation and upscaling in "Change Settings Manually" to reduce GPU time and maximize your quota.
|
| 2522 |
+
|
| 2523 |
### Tips:
|
| 2524 |
- Use detailed prompts for better results
|
| 2525 |
- Include style keywords like 'photorealistic', 'detailed', '8k'
|
|
|
|
| 2527 |
- Try the examples below for inspiration
|
| 2528 |
- **Animation** (enabled by default): Shows intermediate generation steps every 5 steps. Disable for faster generation. (Available in "Change Settings Manually")
|
| 2529 |
- **Color Quantization** (disabled by default): Optional feature to specify a custom color scheme (2-4 colors) for your QR code. Perfect for matching brand colors or creating themed designs with gradient variations. (Available in "Change Settings Manually")
|
| 2530 |
+
- **Upscale Image**: Enhances output quality with RealESRGAN (disabled by default to save GPU time). (Available in "Change Settings Manually")
|
| 2531 |
- **Copy/paste settings**: After generation, copy the JSON settings string that appears below the image and paste it into "Import Settings from JSON" to reproduce exact results or share with others
|
| 2532 |
|
| 2533 |
### Two Modes:
|
| 2534 |
+
- **Artistic QR** (New pipeline, default): More artistic and creative results with optional upscaling (slower, more creative, less scannable)
|
| 2535 |
- **Standard QR** (Old pipeline, more stable): Stable, accurate QR code generation (faster, more scannable, less creative)
|
| 2536 |
|
| 2537 |
### Note:
|
|
|
|
| 2722 |
# Add upscale checkbox
|
| 2723 |
artistic_enable_upscale = gr.Checkbox(
|
| 2724 |
label="Enable Upscaling",
|
| 2725 |
+
value=False,
|
| 2726 |
+
info="Enable upscaling with RealESRGAN for higher quality output (disabled by default to reduce GPU time)",
|
| 2727 |
)
|
| 2728 |
|
| 2729 |
# Animation toggle
|