Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -1,317 +1,333 @@
|
|
1 |
"""
|
2 |
-
Ultra Supreme Optimizer - Main
|
3 |
-
VERSIÓN MEJORADA - Usa el prompt completo de CLIP Interrogator
|
4 |
"""
|
5 |
|
6 |
-
|
7 |
-
import
|
8 |
import gc
|
9 |
import logging
|
10 |
-
import
|
11 |
-
|
12 |
-
from typing import Tuple, Dict, Any, Optional
|
13 |
|
14 |
-
import
|
15 |
-
|
16 |
-
from PIL import Image
|
17 |
-
from clip_interrogator import Config, Interrogator
|
18 |
|
19 |
-
|
|
|
|
|
|
|
20 |
|
|
|
|
|
21 |
logger = logging.getLogger(__name__)
|
22 |
|
|
|
|
|
23 |
|
24 |
-
class UltraSupremeOptimizer:
|
25 |
-
"""Main optimizer class for ultra supreme image analysis"""
|
26 |
-
|
27 |
-
def __init__(self):
|
28 |
-
self.interrogator: Optional[Interrogator] = None
|
29 |
-
self.analyzer = UltraSupremeAnalyzer()
|
30 |
-
self.usage_count = 0
|
31 |
-
self.device = self._get_device()
|
32 |
-
self.is_initialized = False
|
33 |
-
|
34 |
-
@staticmethod
|
35 |
-
def _get_device() -> str:
|
36 |
-
"""Determine the best available device for computation"""
|
37 |
-
if torch.cuda.is_available():
|
38 |
-
return "cuda"
|
39 |
-
elif torch.backends.mps.is_available():
|
40 |
-
return "mps"
|
41 |
-
else:
|
42 |
-
return "cpu"
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
device=self.device
|
56 |
-
)
|
57 |
-
|
58 |
-
self.interrogator = Interrogator(config)
|
59 |
-
self.is_initialized = True
|
60 |
-
|
61 |
-
# Clean up memory after initialization
|
62 |
-
if self.device == "cpu":
|
63 |
-
gc.collect()
|
64 |
-
else:
|
65 |
-
torch.cuda.empty_cache()
|
66 |
-
|
67 |
-
return True
|
68 |
-
|
69 |
-
except Exception as e:
|
70 |
-
logger.error(f"Initialization error: {e}")
|
71 |
-
return False
|
72 |
-
|
73 |
-
def optimize_image(self, image: Any) -> Optional[Image.Image]:
|
74 |
-
"""Optimize image for processing"""
|
75 |
-
if image is None:
|
76 |
-
return None
|
77 |
-
|
78 |
-
try:
|
79 |
-
# Convert to PIL Image if necessary
|
80 |
-
if isinstance(image, np.ndarray):
|
81 |
-
image = Image.fromarray(image)
|
82 |
-
elif not isinstance(image, Image.Image):
|
83 |
-
image = Image.open(image)
|
84 |
-
|
85 |
-
# Convert to RGB if necessary
|
86 |
-
if image.mode != 'RGB':
|
87 |
-
image = image.convert('RGB')
|
88 |
-
|
89 |
-
# Resize if too large
|
90 |
-
max_size = 768 if self.device != "cpu" else 512
|
91 |
-
if image.size[0] > max_size or image.size[1] > max_size:
|
92 |
-
image.thumbnail((max_size, max_size), Image.Resampling.LANCZOS)
|
93 |
-
|
94 |
-
return image
|
95 |
-
|
96 |
-
except Exception as e:
|
97 |
-
logger.error(f"Image optimization error: {e}")
|
98 |
-
return None
|
99 |
-
|
100 |
-
def apply_flux_rules(self, base_prompt: str) -> str:
|
101 |
-
"""Aplica las reglas de Flux a un prompt base de CLIP Interrogator"""
|
102 |
-
|
103 |
-
# Limpiar el prompt de elementos no deseados
|
104 |
-
cleanup_patterns = [
|
105 |
-
r',\s*trending on artstation',
|
106 |
-
r',\s*trending on [^,]+',
|
107 |
-
r',\s*\d+k\s*',
|
108 |
-
r',\s*\d+k resolution',
|
109 |
-
r',\s*artstation',
|
110 |
-
r',\s*concept art',
|
111 |
-
r',\s*digital art',
|
112 |
-
r',\s*by greg rutkowski', # Remover artistas genéricos overused
|
113 |
-
]
|
114 |
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
#
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
elif any(word in base_prompt.lower() for word in ['street', 'urban', 'city']):
|
126 |
-
camera_config = ", Shot on Leica M11, 35mm f/1.4 lens at f/2.8, documentary street photography"
|
127 |
-
else:
|
128 |
-
camera_config = ", Shot on Phase One XF IQ4, 80mm f/2.8 lens at f/4, professional photography"
|
129 |
-
|
130 |
-
# Añadir mejoras de iluminación si no están presentes
|
131 |
-
if 'lighting' not in cleaned_prompt.lower():
|
132 |
-
if 'dramatic' in cleaned_prompt.lower():
|
133 |
-
cleaned_prompt += ", dramatic cinematic lighting"
|
134 |
-
elif 'portrait' in cleaned_prompt.lower():
|
135 |
-
cleaned_prompt += ", professional studio lighting with subtle rim light"
|
136 |
-
else:
|
137 |
-
cleaned_prompt += ", masterful natural lighting"
|
138 |
-
|
139 |
-
# Construir el prompt final
|
140 |
-
final_prompt = cleaned_prompt + camera_config
|
141 |
-
|
142 |
-
# Asegurar que empiece con mayúscula
|
143 |
-
final_prompt = final_prompt[0].upper() + final_prompt[1:] if final_prompt else final_prompt
|
144 |
|
145 |
-
|
146 |
-
final_prompt = re.sub(r'\s+', ' ', final_prompt)
|
147 |
-
final_prompt = re.sub(r',\s*,+', ',', final_prompt)
|
148 |
|
149 |
-
|
|
|
|
|
150 |
|
151 |
-
@spaces.GPU
|
152 |
-
def generate_ultra_supreme_prompt(self, image: Any) -> Tuple[str, str, int, Dict[str, int]]:
|
153 |
-
"""
|
154 |
-
Generate ultra supreme prompt from image usando el pipeline completo
|
155 |
-
|
156 |
-
Returns:
|
157 |
-
Tuple of (prompt, analysis_info, score, breakdown)
|
158 |
-
"""
|
159 |
-
try:
|
160 |
-
# Initialize model if needed
|
161 |
-
if not self.is_initialized:
|
162 |
-
if not self.initialize_model():
|
163 |
-
return "❌ Model initialization failed.", "Please refresh and try again.", 0, {}
|
164 |
-
|
165 |
-
# Validate input
|
166 |
-
if image is None:
|
167 |
-
return "❌ Please upload an image.", "No image provided.", 0, {}
|
168 |
-
|
169 |
-
self.usage_count += 1
|
170 |
-
|
171 |
-
# Optimize image
|
172 |
-
image = self.optimize_image(image)
|
173 |
-
if image is None:
|
174 |
-
return "❌ Image processing failed.", "Invalid image format.", 0, {}
|
175 |
-
|
176 |
-
start_time = datetime.now()
|
177 |
-
|
178 |
-
# NUEVO PIPELINE: Usar CLIP Interrogator completo
|
179 |
-
logger.info("ULTRA SUPREME ANALYSIS - Usando pipeline completo de CLIP Interrogator")
|
180 |
-
|
181 |
-
# 1. Obtener el prompt COMPLETO de CLIP Interrogator (no solo análisis)
|
182 |
-
# Este incluye descripción + artistas + estilos + mediums
|
183 |
-
full_prompt = self.interrogator.interrogate(image)
|
184 |
-
logger.info(f"Prompt completo de CLIP Interrogator: {full_prompt}")
|
185 |
-
|
186 |
-
# 2. También obtener los análisis individuales para el reporte
|
187 |
-
clip_fast = self.interrogator.interrogate_fast(image)
|
188 |
-
clip_classic = self.interrogator.interrogate_classic(image)
|
189 |
-
|
190 |
-
logger.info(f"Análisis Fast: {clip_fast}")
|
191 |
-
logger.info(f"Análisis Classic: {clip_classic}")
|
192 |
-
|
193 |
-
# 3. Aplicar reglas de Flux al prompt completo
|
194 |
-
optimized_prompt = self.apply_flux_rules(full_prompt)
|
195 |
-
|
196 |
-
# 4. Crear análisis para el reporte (simplificado)
|
197 |
-
analysis_summary = {
|
198 |
-
"base_prompt": full_prompt,
|
199 |
-
"clip_fast": clip_fast,
|
200 |
-
"clip_classic": clip_classic,
|
201 |
-
"optimized": optimized_prompt,
|
202 |
-
"detected_style": self._detect_style(full_prompt),
|
203 |
-
"detected_subject": self._detect_subject(full_prompt)
|
204 |
-
}
|
205 |
-
|
206 |
-
# 5. Calcular score basado en la riqueza del prompt
|
207 |
-
score = self._calculate_score(optimized_prompt, full_prompt)
|
208 |
-
breakdown = {
|
209 |
-
"base_quality": min(len(full_prompt) // 10, 25),
|
210 |
-
"technical_enhancement": 25 if "Shot on" in optimized_prompt else 0,
|
211 |
-
"lighting_quality": 25 if "lighting" in optimized_prompt.lower() else 0,
|
212 |
-
"composition": 25 if any(word in optimized_prompt.lower() for word in ["professional", "masterful", "epic"]) else 0
|
213 |
-
}
|
214 |
-
score = sum(breakdown.values())
|
215 |
-
|
216 |
-
end_time = datetime.now()
|
217 |
-
duration = (end_time - start_time).total_seconds()
|
218 |
-
|
219 |
-
# Memory cleanup
|
220 |
-
if self.device == "cpu":
|
221 |
-
gc.collect()
|
222 |
-
else:
|
223 |
-
torch.cuda.empty_cache()
|
224 |
-
|
225 |
-
# Generate analysis report
|
226 |
-
analysis_info = self._generate_analysis_report(
|
227 |
-
analysis_summary, score, breakdown, duration
|
228 |
-
)
|
229 |
-
|
230 |
-
return optimized_prompt, analysis_info, score, breakdown
|
231 |
-
|
232 |
-
except Exception as e:
|
233 |
-
logger.error(f"Ultra supreme generation error: {e}")
|
234 |
-
return f"❌ Error: {str(e)}", "Please try with a different image.", 0, {}
|
235 |
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
"artistic": ["artistic", "abstract", "conceptual"],
|
243 |
-
"dramatic": ["dramatic", "cinematic", "moody"]
|
244 |
-
}
|
245 |
-
|
246 |
-
for style_name, keywords in styles.items():
|
247 |
-
if any(keyword in prompt.lower() for keyword in keywords):
|
248 |
-
return style_name
|
249 |
-
|
250 |
-
return "general"
|
251 |
|
252 |
-
def _detect_subject(self, prompt: str) -> str:
|
253 |
-
"""Detecta el sujeto principal del prompt"""
|
254 |
-
# Tomar las primeras palabras significativas
|
255 |
-
words = prompt.split(',')[0].split()
|
256 |
-
if len(words) > 3:
|
257 |
-
return ' '.join(words[:4])
|
258 |
-
return prompt.split(',')[0]
|
259 |
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
|
267 |
-
|
268 |
-
|
269 |
-
|
|
|
|
|
|
|
270 |
|
271 |
-
|
272 |
-
|
273 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
274 |
|
275 |
-
#
|
276 |
-
|
277 |
-
|
|
|
|
|
|
|
278 |
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
duration: float) -> str:
|
284 |
-
"""Generate detailed analysis report"""
|
285 |
|
286 |
-
|
|
|
|
|
287 |
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
base_prompt_preview = analysis.get("base_prompt", "")[:100] + "..." if len(analysis.get("base_prompt", "")) > 100 else analysis.get("base_prompt", "")
|
292 |
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
**🧠 INTELLIGENT DETECTION:**
|
299 |
-
- **Detected Style:** {detected_style}
|
300 |
-
- **Main Subject:** {detected_subject}
|
301 |
-
- **Pipeline:** CLIP Interrogator → Flux Optimization → Technical Enhancement
|
302 |
-
|
303 |
-
**📊 CLIP INTERROGATOR ANALYSIS:**
|
304 |
-
- **Base Prompt:** {base_prompt_preview}
|
305 |
-
- **Fast Analysis:** {analysis.get('clip_fast', '')[:80]}...
|
306 |
-
- **Classic Analysis:** {analysis.get('clip_classic', '')[:80]}...
|
307 |
|
308 |
-
**⚡ OPTIMIZATION APPLIED:**
|
309 |
-
- ✅ Preserved CLIP Interrogator's rich description
|
310 |
-
- ✅ Added professional camera specifications
|
311 |
-
- ✅ Enhanced lighting descriptions
|
312 |
-
- ✅ Applied Flux-specific optimizations
|
313 |
-
- ✅ Removed redundant/generic elements
|
314 |
|
315 |
-
|
316 |
-
|
317 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
"""
|
2 |
+
Ultra Supreme Flux Optimizer - Main Gradio Interface
|
|
|
3 |
"""
|
4 |
|
5 |
+
import gradio as gr
|
6 |
+
import torch
|
7 |
import gc
|
8 |
import logging
|
9 |
+
import warnings
|
10 |
+
import os
|
|
|
11 |
|
12 |
+
from optimizer import UltraSupremeOptimizer
|
13 |
+
from constants import SCORE_GRADES
|
|
|
|
|
14 |
|
15 |
+
# Configure warnings and environment
|
16 |
+
warnings.filterwarnings("ignore", category=FutureWarning)
|
17 |
+
warnings.filterwarnings("ignore", category=UserWarning)
|
18 |
+
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
19 |
|
20 |
+
# Configure logging
|
21 |
+
logging.basicConfig(level=logging.INFO)
|
22 |
logger = logging.getLogger(__name__)
|
23 |
|
24 |
+
# Initialize the optimizer globally
|
25 |
+
optimizer = UltraSupremeOptimizer()
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
+
def process_ultra_supreme_analysis(image):
|
29 |
+
"""Process image and generate ultra supreme analysis"""
|
30 |
+
try:
|
31 |
+
prompt, info, score, breakdown = optimizer.generate_ultra_supreme_prompt(image)
|
32 |
|
33 |
+
# Find appropriate grade based on score
|
34 |
+
grade_info = None
|
35 |
+
for threshold, grade_data in sorted(SCORE_GRADES.items(), reverse=True):
|
36 |
+
if score >= threshold:
|
37 |
+
grade_info = grade_data
|
38 |
+
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
+
if not grade_info:
|
41 |
+
grade_info = SCORE_GRADES[0] # Default to lowest grade
|
42 |
+
|
43 |
+
score_html = f'''
|
44 |
+
<div style="text-align: center; padding: 2rem; background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%); border: 3px solid {grade_info["color"]}; border-radius: 16px; margin: 1rem 0; box-shadow: 0 8px 25px -5px rgba(0, 0, 0, 0.1);">
|
45 |
+
<div style="font-size: 3rem; font-weight: 800; color: {grade_info["color"]}; margin: 0; text-shadow: 0 2px 4px rgba(0,0,0,0.1);">{score}</div>
|
46 |
+
<div style="font-size: 1.25rem; color: #15803d; margin: 0.5rem 0; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700;">{grade_info["grade"]}</div>
|
47 |
+
<div style="font-size: 1rem; color: #15803d; margin: 0; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500;">Ultra Supreme Intelligence Score</div>
|
48 |
+
</div>
|
49 |
+
'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
+
return prompt, info, score_html
|
|
|
|
|
52 |
|
53 |
+
except Exception as e:
|
54 |
+
logger.error(f"Ultra supreme wrapper error: {e}")
|
55 |
+
return "❌ Processing failed", f"Error: {str(e)}", '<div style="text-align: center; color: red;">Error</div>'
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
+
def clear_outputs():
|
59 |
+
"""Clear all outputs and free memory"""
|
60 |
+
gc.collect()
|
61 |
+
if torch.cuda.is_available():
|
62 |
+
torch.cuda.empty_cache()
|
63 |
+
return "", "", '<div style="text-align: center; padding: 1rem;"><div style="font-size: 2rem; color: #ccc;">--</div><div style="font-size: 0.875rem; color: #999;">Ultra Supreme Score</div></div>'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
+
def create_interface():
|
67 |
+
"""Create the Gradio interface"""
|
68 |
+
|
69 |
+
css = """
|
70 |
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');
|
71 |
+
|
72 |
+
.gradio-container {
|
73 |
+
max-width: 1600px !important;
|
74 |
+
margin: 0 auto !important;
|
75 |
+
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
|
76 |
+
background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%) !important;
|
77 |
+
}
|
78 |
+
|
79 |
+
/* FIX CRÍTICO PARA TEXTO BLANCO SOBRE BLANCO */
|
80 |
+
.markdown-text, .markdown-text *,
|
81 |
+
.prose, .prose *,
|
82 |
+
.gr-markdown, .gr-markdown *,
|
83 |
+
div[class*="markdown"], div[class*="markdown"] * {
|
84 |
+
color: #1f2937 !important;
|
85 |
+
}
|
86 |
+
|
87 |
+
.markdown-text h1, .markdown-text h2, .markdown-text h3,
|
88 |
+
.prose h1, .prose h2, .prose h3,
|
89 |
+
.gr-markdown h1, .gr-markdown h2, .gr-markdown h3 {
|
90 |
+
color: #111827 !important;
|
91 |
+
font-weight: 700 !important;
|
92 |
+
}
|
93 |
+
|
94 |
+
.markdown-text p, .markdown-text li, .markdown-text ul, .markdown-text ol,
|
95 |
+
.prose p, .prose li, .prose ul, .prose ol,
|
96 |
+
.gr-markdown p, .gr-markdown li, .gr-markdown ul, .gr-markdown ol {
|
97 |
+
color: #374151 !important;
|
98 |
+
}
|
99 |
+
|
100 |
+
.markdown-text strong, .prose strong, .gr-markdown strong {
|
101 |
+
color: #111827 !important;
|
102 |
+
font-weight: 700 !important;
|
103 |
+
}
|
104 |
+
|
105 |
+
/* Asegurar que las listas sean visibles */
|
106 |
+
ul, ol {
|
107 |
+
color: #374151 !important;
|
108 |
+
}
|
109 |
+
|
110 |
+
li {
|
111 |
+
color: #374151 !important;
|
112 |
+
}
|
113 |
+
|
114 |
+
/* Bullets de listas */
|
115 |
+
ul li::marker {
|
116 |
+
color: #374151 !important;
|
117 |
+
}
|
118 |
+
|
119 |
+
.main-header {
|
120 |
+
text-align: center;
|
121 |
+
padding: 3rem 0 4rem 0;
|
122 |
+
background: linear-gradient(135deg, #0c0a09 0%, #1c1917 30%, #292524 60%, #44403c 100%);
|
123 |
+
color: white;
|
124 |
+
margin: -2rem -2rem 3rem -2rem;
|
125 |
+
border-radius: 0 0 32px 32px;
|
126 |
+
box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.25);
|
127 |
+
position: relative;
|
128 |
+
overflow: hidden;
|
129 |
+
}
|
130 |
+
|
131 |
+
.main-header::before {
|
132 |
+
content: '';
|
133 |
+
position: absolute;
|
134 |
+
top: 0;
|
135 |
+
left: 0;
|
136 |
+
right: 0;
|
137 |
+
bottom: 0;
|
138 |
+
background: linear-gradient(45deg, rgba(59, 130, 246, 0.1) 0%, rgba(147, 51, 234, 0.1) 50%, rgba(236, 72, 153, 0.1) 100%);
|
139 |
+
z-index: 1;
|
140 |
+
}
|
141 |
+
|
142 |
+
.main-title {
|
143 |
+
font-size: 4rem !important;
|
144 |
+
font-weight: 900 !important;
|
145 |
+
margin: 0 0 1rem 0 !important;
|
146 |
+
letter-spacing: -0.05em !important;
|
147 |
+
background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 25%, #8b5cf6 50%, #a855f7 75%, #ec4899 100%);
|
148 |
+
-webkit-background-clip: text;
|
149 |
+
-webkit-text-fill-color: transparent;
|
150 |
+
background-clip: text;
|
151 |
+
position: relative;
|
152 |
+
z-index: 2;
|
153 |
+
}
|
154 |
+
|
155 |
+
.subtitle {
|
156 |
+
font-size: 1.5rem !important;
|
157 |
+
font-weight: 500 !important;
|
158 |
+
opacity: 0.95 !important;
|
159 |
+
margin: 0 !important;
|
160 |
+
position: relative;
|
161 |
+
z-index: 2;
|
162 |
+
color: #ffffff !important;
|
163 |
+
}
|
164 |
+
|
165 |
+
.prompt-output {
|
166 |
+
font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace !important;
|
167 |
+
font-size: 15px !important;
|
168 |
+
line-height: 1.8 !important;
|
169 |
+
background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%) !important;
|
170 |
+
border: 2px solid #e2e8f0 !important;
|
171 |
+
border-radius: 20px !important;
|
172 |
+
padding: 2.5rem !important;
|
173 |
+
box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.1) !important;
|
174 |
+
transition: all 0.3s ease !important;
|
175 |
+
color: #1f2937 !important;
|
176 |
+
}
|
177 |
+
|
178 |
+
.prompt-output:hover {
|
179 |
+
box-shadow: 0 25px 60px -5px rgba(0, 0, 0, 0.15) !important;
|
180 |
+
transform: translateY(-2px) !important;
|
181 |
+
}
|
182 |
+
|
183 |
+
/* Fix para el output de información */
|
184 |
+
.gr-textbox label {
|
185 |
+
color: #374151 !important;
|
186 |
+
}
|
187 |
+
|
188 |
+
/* Fix para footer */
|
189 |
+
footer, .footer, [class*="footer"] {
|
190 |
+
color: #374151 !important;
|
191 |
+
}
|
192 |
+
|
193 |
+
footer *, .footer *, [class*="footer"] * {
|
194 |
+
color: #374151 !important;
|
195 |
+
}
|
196 |
+
|
197 |
+
footer a, .footer a, [class*="footer"] a {
|
198 |
+
color: #3b82f6 !important;
|
199 |
+
text-decoration: underline;
|
200 |
+
}
|
201 |
+
|
202 |
+
footer a:hover, .footer a:hover, [class*="footer"] a:hover {
|
203 |
+
color: #2563eb !important;
|
204 |
+
}
|
205 |
+
|
206 |
+
/* Botones */
|
207 |
+
.gr-button-primary {
|
208 |
+
background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
|
209 |
+
border: none !important;
|
210 |
+
color: white !important;
|
211 |
+
}
|
212 |
+
|
213 |
+
.gr-button-primary:hover {
|
214 |
+
background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%) !important;
|
215 |
+
transform: translateY(-1px);
|
216 |
+
box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
|
217 |
+
}
|
218 |
+
|
219 |
+
/* Asegurar que TODOS los elementos de texto sean visibles */
|
220 |
+
* {
|
221 |
+
-webkit-text-fill-color: initial !important;
|
222 |
+
}
|
223 |
+
|
224 |
+
/* Solo el título principal mantiene su gradiente */
|
225 |
+
.main-title {
|
226 |
+
-webkit-text-fill-color: transparent !important;
|
227 |
+
}
|
228 |
+
"""
|
229 |
+
|
230 |
+
with gr.Blocks(
|
231 |
+
theme=gr.themes.Soft(),
|
232 |
+
title="🚀 Ultra Supreme Flux Optimizer",
|
233 |
+
css=css
|
234 |
+
) as interface:
|
235 |
|
236 |
+
gr.HTML("""
|
237 |
+
<div class="main-header">
|
238 |
+
<div class="main-title">🚀 ULTRA SUPREME FLUX OPTIMIZER</div>
|
239 |
+
<div class="subtitle">Maximum Absolute Intelligence • Triple CLIP Analysis • Zero Compromise • Research Supremacy</div>
|
240 |
+
</div>
|
241 |
+
""")
|
242 |
|
243 |
+
with gr.Row():
|
244 |
+
with gr.Column(scale=1):
|
245 |
+
gr.Markdown("## 🧠 Ultra Supreme Analysis Engine")
|
246 |
+
|
247 |
+
image_input = gr.Image(
|
248 |
+
label="Upload image for MAXIMUM intelligence analysis",
|
249 |
+
type="pil",
|
250 |
+
height=500
|
251 |
+
)
|
252 |
+
|
253 |
+
analyze_btn = gr.Button(
|
254 |
+
"🚀 ULTRA SUPREME ANALYSIS",
|
255 |
+
variant="primary",
|
256 |
+
size="lg"
|
257 |
+
)
|
258 |
+
|
259 |
+
gr.Markdown("""
|
260 |
+
### 🔬 Maximum Absolute Intelligence
|
261 |
+
|
262 |
+
**🚀 Triple CLIP Interrogation:**
|
263 |
+
• Fast analysis for broad contextual mapping
|
264 |
+
• Classic analysis for detailed feature extraction
|
265 |
+
• Best analysis for maximum depth intelligence
|
266 |
+
|
267 |
+
**🧠 Ultra Deep Feature Extraction:**
|
268 |
+
• Micro-age detection with confidence scoring
|
269 |
+
• Cultural/religious context with semantic analysis
|
270 |
+
• Facial micro-features and expression mapping
|
271 |
+
• Emotional state and micro-expression detection
|
272 |
+
• Environmental lighting and atmospheric analysis
|
273 |
+
• Body language and pose interpretation
|
274 |
+
• Technical photography optimization
|
275 |
+
|
276 |
+
**⚡ Absolute Maximum Intelligence** - No configuration, no limits, no compromise.
|
277 |
+
""")
|
278 |
+
|
279 |
+
with gr.Column(scale=1):
|
280 |
+
gr.Markdown("## ⚡ Ultra Supreme Result")
|
281 |
+
|
282 |
+
prompt_output = gr.Textbox(
|
283 |
+
label="🚀 Ultra Supreme Optimized Flux Prompt",
|
284 |
+
placeholder="Upload an image to witness absolute maximum intelligence analysis...",
|
285 |
+
lines=12,
|
286 |
+
max_lines=20,
|
287 |
+
elem_classes=["prompt-output"],
|
288 |
+
show_copy_button=True
|
289 |
+
)
|
290 |
+
|
291 |
+
score_output = gr.HTML(
|
292 |
+
value='<div style="text-align: center; padding: 1rem;"><div style="font-size: 2rem; color: #ccc;">--</div><div style="font-size: 0.875rem; color: #999;">Ultra Supreme Score</div></div>'
|
293 |
+
)
|
294 |
+
|
295 |
+
info_output = gr.Markdown(value="")
|
296 |
+
|
297 |
+
clear_btn = gr.Button("🗑️ Clear Ultra Analysis", size="sm")
|
298 |
|
299 |
+
# Event handlers
|
300 |
+
analyze_btn.click(
|
301 |
+
fn=process_ultra_supreme_analysis,
|
302 |
+
inputs=[image_input],
|
303 |
+
outputs=[prompt_output, info_output, score_output]
|
304 |
+
)
|
305 |
|
306 |
+
clear_btn.click(
|
307 |
+
fn=clear_outputs,
|
308 |
+
outputs=[prompt_output, info_output, score_output]
|
309 |
+
)
|
|
|
|
|
310 |
|
311 |
+
gr.Markdown("""
|
312 |
+
---
|
313 |
+
### 🏆 Ultra Supreme Research Foundation
|
314 |
|
315 |
+
This system represents the **absolute pinnacle** of image analysis and Flux prompt optimization. Using triple CLIP interrogation,
|
316 |
+
ultra-deep feature extraction, cultural context awareness, and emotional intelligence mapping, it achieves maximum possible
|
317 |
+
understanding and applies research-validated Flux rules with supreme intelligence.
|
|
|
318 |
|
319 |
+
**🔬 Pariente AI Research Laboratory** • **🚀 Ultra Supreme Intelligence Engine**
|
320 |
+
""")
|
321 |
+
|
322 |
+
return interface
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
323 |
|
|
|
|
|
|
|
|
|
|
|
|
|
324 |
|
325 |
+
# Main execution
|
326 |
+
if __name__ == "__main__":
|
327 |
+
demo = create_interface()
|
328 |
+
demo.launch(
|
329 |
+
server_name="0.0.0.0",
|
330 |
+
server_port=7860,
|
331 |
+
share=True,
|
332 |
+
show_error=True
|
333 |
+
)
|