Spaces:
Runtime error
Runtime error
File size: 6,034 Bytes
f179fb3 875be83 f179fb3 fe30f16 f179fb3 fe30f16 f179fb3 fe30f16 f179fb3 a781ddc f179fb3 fe30f16 f179fb3 4aab6df f786a41 f179fb3 a781ddc 2da2ac4 a781ddc 2da2ac4 a781ddc f786a41 a781ddc 875be83 f179fb3 0a65708 f179fb3 2da2ac4 0a65708 875be83 f179fb3 69e6233 f179fb3 69e6233 f179fb3 fe30f16 f179fb3 f786a41 f179fb3 fe30f16 f179fb3 fe30f16 f179fb3 fe30f16 f179fb3 fe30f16 f179fb3 fe30f16 f179fb3 fe30f16 f179fb3 fe30f16 f179fb3 fe30f16 f179fb3 fe30f16 f179fb3 fe30f16 f179fb3 fe30f16 f179fb3 fe30f16 f179fb3 fe30f16 f179fb3 a781ddc f179fb3 fe30f16 f179fb3 a781ddc f179fb3 fe30f16 f179fb3 a781ddc f179fb3 fe30f16 f179fb3 fe30f16 f179fb3 fe30f16 fdb4334 875be83 d6d4ba1 875be83 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
"""
Configuration file for Pixagram AI Pixel Art Generator
CLEANED VERSION - Applied all audit fixes
- Removed unused config values
- Moved print statements to function
- Cleaned up duplicates
"""
import os
import torch
# Device configuration
device = "cuda" if torch.cuda.is_available() else "cpu"
dtype = torch.float16 if device == "cuda" else torch.float32
# Model configuration
MODEL_REPO = "primerz/pixagram"
HUGGINGFACE_TOKEN = os.getenv("HUGGINGFACE_TOKEN", None)
# Model files
MODEL_FILES = {
"checkpoint": "horizon.safetensors",
"lora": "retroart.safetensors",
"vae": "pixelate.safetensors"
}
# InstantID Configuration
INSTANTID_CONFIG = {
"repo": "InstantX/InstantID",
"controlnet_subfolder": "ControlNetModel",
"ip_adapter_file": "ip-adapter.bin",
"default_ip_scale": 0.8,
}
# LORA configuration
TRIGGER_WORD = "p1x3l4rt, pixel art"
# Face detection configuration
FACE_DETECTION_CONFIG = {
"name": "antelopev2",
"det_size": (640, 640),
"ctx_id": 0,
"repo_id": "DIAMONIK7777/antelopev2",
"local_dir": "/data/models/antelopev2",
"root": "/data",
"providers": ['CPUExecutionProvider'],
}
# Recommended resolutions
RECOMMENDED_SIZES = [
(896, 1152), # Portrait
(1152, 896), # Landscape
(832, 1216), # Tall portrait
(1216, 832), # Wide landscape
(1024, 1024) # Square
]
# Default generation parameters
DEFAULT_PARAMS = {
"num_inference_steps": 12,
"guidance_scale": 1.3,
"strength": 0.50,
"depth_control_scale": 0.75,
"identity_control_scale": 0.85,
"lora_scale": 1.0,
"identity_preservation": 1.2,
"enable_color_matching": False,
"consistency_mode": True,
"seed": -1
}
# Optimized preset configurations
PRESETS = {
"Ultra Fidelity": {
"strength": 0.40,
"guidance_scale": 1.15,
"identity_preservation": 1.8,
"lora_scale": 0.8,
"depth_control_scale": 0.65,
"identity_control_scale": 0.95,
"description": "Maximum face preservation - 96-98% similarity (Level 3)"
},
"Premium Portrait": {
"strength": 0.52,
"guidance_scale": 1.3,
"identity_preservation": 1.35,
"lora_scale": 1.1,
"depth_control_scale": 0.75,
"identity_control_scale": 0.85,
"description": "Optimized balanced - strong pixel art + excellent face (92-94% similarity)"
},
"Balanced Portrait": {
"strength": 0.50,
"guidance_scale": 1.3,
"identity_preservation": 1.2,
"lora_scale": 1.0,
"depth_control_scale": 0.75,
"identity_control_scale": 0.85,
"description": "Good balance between fidelity and style - 90-93% similarity"
},
"Artistic Excellence": {
"strength": 0.58,
"guidance_scale": 1.4,
"identity_preservation": 1.2,
"lora_scale": 1.2,
"depth_control_scale": 0.78,
"identity_control_scale": 0.75,
"description": "Creative with strong likeness - 88-91% similarity"
},
"Style Focus": {
"strength": 0.68,
"guidance_scale": 1.5,
"identity_preservation": 0.9,
"lora_scale": 1.4,
"depth_control_scale": 0.82,
"identity_control_scale": 0.65,
"description": "Maximum pixel art style - 83-87% similarity"
},
"Subtle Enhancement": {
"strength": 0.38,
"guidance_scale": 1.1,
"identity_preservation": 1.9,
"lora_scale": 0.75,
"depth_control_scale": 0.60,
"identity_control_scale": 0.98,
"description": "Minimal transformation, photo-realistic - 97-99% similarity"
}
}
# Adaptive parameter adjustment thresholds
ADAPTIVE_THRESHOLDS = {
"small_face_size": 50000,
"low_confidence": 0.8,
"profile_angle": 20
}
# Adaptive parameter sets
ADAPTIVE_PARAMS = {
"small_face": {
"identity_preservation": 1.8,
"identity_control_scale": 0.95,
"guidance_scale": 1.2,
"lora_scale": 0.8,
"reason": "Small face detected - boosting preservation"
},
"low_confidence": {
"identity_preservation": 1.6,
"identity_control_scale": 0.9,
"guidance_scale": 1.3,
"lora_scale": 0.85,
"reason": "Low confidence - increasing identity weight"
},
"profile_view": {
"identity_preservation": 1.7,
"identity_control_scale": 0.95,
"guidance_scale": 1.2,
"lora_scale": 0.85,
"reason": "Profile view - enhancing preservation"
}
}
# Caption generation settings
CAPTION_CONFIG = {
"max_length": 20,
"num_beams": 4
}
# Color matching settings
COLOR_MATCH_CONFIG = {
"lab_lightness_blend": 0.15,
"lab_color_blend_preserved": 0.05,
"lab_color_blend_full": 0.20,
"saturation_boost": 1.05,
"gaussian_blur_kernel": (51, 51),
"gaussian_blur_sigma": 20
}
# Face mask settings
FACE_MASK_CONFIG = {
"padding": 0.1,
"feather": 30
}
# Model download retry settings
DOWNLOAD_CONFIG = {
"max_retries": 3,
"retry_delay": 2
}
# Age brackets for demographic detection
AGE_BRACKETS = [
(0, 18, "young"),
(18, 30, "young adult"),
(30, 50, "middle-aged"),
(50, 150, "mature")
]
# CLIP skip setting
CLIP_SKIP = 2
# Multi-scale face processing
MULTI_SCALE_FACTORS = [0.75, 1.0, 1.25]
# Identity boost multiplier
IDENTITY_BOOST_MULTIPLIER = 1.15
def print_config_status():
"""Print configuration status (call explicitly to avoid clutter)"""
print(f"[CONFIG] Configuration loaded")
print(f" Device: {device}")
print(f" Dtype: {dtype}")
print(f" Model Repo: {MODEL_REPO}")
print(f" HuggingFace Token: {'Set' if HUGGINGFACE_TOKEN else 'Not set (using IP-based access)'}")
print(f" InstantID: Enabled")
print(f" Face Detection: {FACE_DETECTION_CONFIG['name']} from {FACE_DETECTION_CONFIG['repo_id']}")
print(f" Face Providers: {FACE_DETECTION_CONFIG['providers']}")
# Auto-print on import (can be disabled by commenting out)
print_config_status()
|