Xernive's picture
Fix Hunyuan3D error handling + enhanced logging
0e805d4
"""Configuration and quality presets for asset generation."""
from dataclasses import dataclass
from typing import Dict
@dataclass
class QualityPreset:
"""Quality preset configuration."""
name: str
flux_steps: int
flux_guidance: float
hunyuan_steps: int
hunyuan_guidance: float
octree_resolution: int
texture_resolution: int
num_chunks: int
estimated_time_s: int
# Quality presets (optimized for L4 GPU)
QUALITY_PRESETS: Dict[str, QualityPreset] = {
"Fast": QualityPreset(
name="Fast",
flux_steps=10,
flux_guidance=3.5,
hunyuan_steps=10,
hunyuan_guidance=5.5,
octree_resolution=384,
texture_resolution=2048,
num_chunks=8000,
estimated_time_s=45
),
"Balanced": QualityPreset(
name="Balanced",
flux_steps=15,
flux_guidance=3.5,
hunyuan_steps=25,
hunyuan_guidance=6.0,
octree_resolution=512,
texture_resolution=2048,
num_chunks=10000,
estimated_time_s=60
),
"High": QualityPreset(
name="High",
flux_steps=25,
flux_guidance=3.5,
hunyuan_steps=35,
hunyuan_guidance=6.5,
octree_resolution=512,
texture_resolution=4096,
num_chunks=12000,
estimated_time_s=90
),
"Ultra": QualityPreset(
name="Ultra",
flux_steps=30,
flux_guidance=3.5,
hunyuan_steps=50,
hunyuan_guidance=7.0,
octree_resolution=512,
texture_resolution=4096,
num_chunks=15000,
estimated_time_s=120
),
}
# FLUX model configuration
FLUX_MODELS = {
"dev": "black-forest-labs/FLUX.1-dev",
}
# Hunyuan3D configuration
HUNYUAN_SETTINGS = {
"space_id": "tencent/Hunyuan3D-2.1",
"timeout": 300.0,
"connect_timeout": 60.0,
}
# Cache configuration
CACHE_EXPIRY_HOURS = 24
MAX_CACHE_SIZE_GB = 10
# Security configuration
MAX_PROMPT_LENGTH = 500
MAX_REQUESTS_PER_HOUR = 10
REQUEST_WINDOW_SECONDS = 3600
MAX_FILE_SIZE_MB = 100
# GPU configuration
PYTORCH_CUDA_ALLOC_CONF = "expandable_segments:True,max_split_size_mb:512"
ENABLE_TF32 = True
ENABLE_CUDNN_BENCHMARK = True