Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -557,57 +557,57 @@ def optimize_image(self, image):
|
|
| 557 |
@spaces.GPU
|
| 558 |
def generate_ultra_supreme_prompt(self, image):
|
| 559 |
try:
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
|
| 567 |
-
|
| 568 |
-
|
| 569 |
-
|
| 570 |
-
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
|
| 578 |
-
|
| 579 |
-
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
|
| 585 |
-
|
| 586 |
-
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
| 602 |
-
|
| 603 |
-
|
| 604 |
-
|
| 605 |
-
|
| 606 |
-
|
| 607 |
-
|
| 608 |
-
|
| 609 |
-
|
| 610 |
-
analysis_info = f"""**π ULTRA SUPREME ANALYSIS COMPLETE**
|
| 611 |
**Processing:** {gpu_status} β’ {duration:.1f}s β’ Triple CLIP Ultra Intelligence
|
| 612 |
**Ultra Score:** {score}/100 β’ Breakdown: Structure({breakdown.get('structure',0)}) Features({breakdown.get('features',0)}) Cultural({breakdown.get('cultural',0)}) Emotional({breakdown.get('emotional',0)}) Technical({breakdown.get('technical',0)})
|
| 613 |
**Generation:** #{self.usage_count}
|
|
@@ -624,12 +624,12 @@ analysis_info = f"""**π ULTRA SUPREME ANALYSIS COMPLETE**
|
|
| 624 |
- **Classic:** {clip_classic[:50]}...
|
| 625 |
- **Best:** {clip_best[:50]}...
|
| 626 |
**β‘ ULTRA OPTIMIZATION:** Applied absolute maximum depth analysis with Pariente AI research rules"""
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
|
| 630 |
-
|
| 631 |
-
|
| 632 |
-
|
| 633 |
|
| 634 |
# Initialize the optimizer
|
| 635 |
optimizer = UltraSupremeOptimizer()
|
|
|
|
| 557 |
@spaces.GPU
|
| 558 |
def generate_ultra_supreme_prompt(self, image):
|
| 559 |
try:
|
| 560 |
+
if not self.is_initialized:
|
| 561 |
+
if not self.initialize_model():
|
| 562 |
+
return "β Model initialization failed.", "Please refresh and try again.", 0, {}
|
| 563 |
+
|
| 564 |
+
if image is None:
|
| 565 |
+
return "β Please upload an image.", "No image provided.", 0, {}
|
| 566 |
+
|
| 567 |
+
self.usage_count += 1
|
| 568 |
+
|
| 569 |
+
image = self.optimize_image(image)
|
| 570 |
+
if image is None:
|
| 571 |
+
return "β Image processing failed.", "Invalid image format.", 0, {}
|
| 572 |
+
|
| 573 |
+
start_time = datetime.now()
|
| 574 |
+
|
| 575 |
+
# ULTRA SUPREME TRIPLE CLIP ANALYSIS
|
| 576 |
+
logger.info("ULTRA SUPREME ANALYSIS - Maximum intelligence deployment")
|
| 577 |
+
|
| 578 |
+
clip_fast = self.interrogator.interrogate_fast(image)
|
| 579 |
+
clip_classic = self.interrogator.interrogate_classic(image)
|
| 580 |
+
clip_best = self.interrogator.interrogate(image)
|
| 581 |
+
|
| 582 |
+
logger.info(f"ULTRA CLIP Results:\nFast: {clip_fast}\nClassic: {clip_classic}\nBest: {clip_best}")
|
| 583 |
+
|
| 584 |
+
# ULTRA SUPREME ANALYSIS
|
| 585 |
+
ultra_analysis = self.analyzer.ultra_supreme_analysis(clip_fast, clip_classic, clip_best)
|
| 586 |
+
|
| 587 |
+
# BUILD ULTRA SUPREME FLUX PROMPT
|
| 588 |
+
optimized_prompt = self.analyzer.build_ultra_supreme_prompt(ultra_analysis, [clip_fast, clip_classic, clip_best])
|
| 589 |
+
|
| 590 |
+
# CALCULATE ULTRA SUPREME SCORE
|
| 591 |
+
score, breakdown = self.analyzer.calculate_ultra_supreme_score(optimized_prompt, ultra_analysis)
|
| 592 |
+
|
| 593 |
+
end_time = datetime.now()
|
| 594 |
+
duration = (end_time - start_time).total_seconds()
|
| 595 |
+
|
| 596 |
+
# Memory cleanup
|
| 597 |
+
if self.device == "cpu":
|
| 598 |
+
gc.collect()
|
| 599 |
+
else:
|
| 600 |
+
torch.cuda.empty_cache()
|
| 601 |
+
|
| 602 |
+
# ULTRA COMPREHENSIVE ANALYSIS REPORT
|
| 603 |
+
gpu_status = "β‘ ZeroGPU" if torch.cuda.is_available() else "π» CPU"
|
| 604 |
+
|
| 605 |
+
# Format detected elements
|
| 606 |
+
features = ", ".join(ultra_analysis["facial_ultra"]["facial_hair"]) if ultra_analysis["facial_ultra"]["facial_hair"] else "None detected"
|
| 607 |
+
cultural = ", ".join(ultra_analysis["demographic"]["cultural_religious"]) if ultra_analysis["demographic"]["cultural_religious"] else "None detected"
|
| 608 |
+
clothing = ", ".join(ultra_analysis["clothing_accessories"]["eyewear"] + ultra_analysis["clothing_accessories"]["headwear"]) if ultra_analysis["clothing_accessories"]["eyewear"] or ultra_analysis["clothing_accessories"]["headwear"] else "None detected"
|
| 609 |
+
|
| 610 |
+
analysis_info = f"""**π ULTRA SUPREME ANALYSIS COMPLETE**
|
| 611 |
**Processing:** {gpu_status} β’ {duration:.1f}s β’ Triple CLIP Ultra Intelligence
|
| 612 |
**Ultra Score:** {score}/100 β’ Breakdown: Structure({breakdown.get('structure',0)}) Features({breakdown.get('features',0)}) Cultural({breakdown.get('cultural',0)}) Emotional({breakdown.get('emotional',0)}) Technical({breakdown.get('technical',0)})
|
| 613 |
**Generation:** #{self.usage_count}
|
|
|
|
| 624 |
- **Classic:** {clip_classic[:50]}...
|
| 625 |
- **Best:** {clip_best[:50]}...
|
| 626 |
**β‘ ULTRA OPTIMIZATION:** Applied absolute maximum depth analysis with Pariente AI research rules"""
|
| 627 |
+
|
| 628 |
+
return optimized_prompt, analysis_info, score, breakdown
|
| 629 |
+
|
| 630 |
+
except Exception as e:
|
| 631 |
+
logger.error(f"Ultra supreme generation error: {e}")
|
| 632 |
+
return f"β Error: {str(e)}", "Please try with a different image.", 0, {}
|
| 633 |
|
| 634 |
# Initialize the optimizer
|
| 635 |
optimizer = UltraSupremeOptimizer()
|