scheitelpunk commited on
Commit
8976fb9
·
1 Parent(s): 1851aef

✅ Fix Applied: Gradio Output Format

Browse files

Das Problem:
- Gradio Interface erwartete 4 separate Werte: [markdown, image, image, code]
- Aber die Funktion gab ein Dictionary zurück
- Zusätzlich: tuple has no attribute 'copy' Fehler beim Caching

Die Lösung:
1. Hauptfunktion korrigiert - gibt jetzt Tuple zurück: (summary, curvature_plot, entity_3d_plot,
detailed_json)
2. Caching korrigiert - behandelt Tuples korrekt ohne .copy()
3. Enhanced-Funktionen korrigiert - unpacked Tuples richtig
4. Error handling korrigiert - gibt Tuple zurück bei Fehlern

🚀 System Status: HF Space Ready

Das GASM Enhanced System ist jetzt:
- ✅ Gradio-kompatibel (4 separate Outputs)
- ✅ Error-resilient (robustes Exception handling)
- ✅ Cache-optimiert (intelligentes Tuple-Caching)
- ✅ GPU/CPU-kompatibel (automatischer fallback)
- ✅ Enhanced processing (Mixed Precision + Optimizations)

Der Fehler sollte jetzt behoben sein! Das System kann problemlos auf HuggingFace Space deployed
werden. 🎯

Files changed (1) hide show
  1. app.py +22 -18
app.py CHANGED
@@ -1588,9 +1588,15 @@ def real_gasm_process_text(
1588
  real_gasm_process_text.cache = {}
1589
 
1590
  if cache_key in real_gasm_process_text.cache:
1591
- cached_result = real_gasm_process_text.cache[cache_key].copy()
1592
- cached_result['summary'] = "🚀 **Cached Result** (Enhanced)\n\n" + cached_result['summary']
1593
- return cached_result
 
 
 
 
 
 
1594
 
1595
  # Try GPU first with mixed precision
1596
  try:
@@ -1604,33 +1610,31 @@ def real_gasm_process_text(
1604
 
1605
  # Cache successful results (limit cache size for HF)
1606
  if len(real_gasm_process_text.cache) < 20:
1607
- real_gasm_process_text.cache[cache_key] = result.copy()
1608
 
1609
  return result
1610
 
1611
  except Exception as e:
1612
  logger.error(f"All processing failed: {e}")
1613
- return {
1614
- 'summary': f"❌ Processing failed: {str(e)}",
1615
- 'curvature_plot': None,
1616
- 'entity_3d_plot': None,
1617
- 'detailed_json': json.dumps({"error": str(e)}, indent=2)
1618
- }
1619
 
1620
  def real_gasm_process_text_gpu_enhanced(text, enable_geometry, show_visualization, max_length):
1621
  """GPU processing with mixed precision and optimizations"""
1622
  with torch.cuda.amp.autocast():
1623
- result = real_gasm_process_text_gpu(text, enable_geometry, show_visualization, max_length)
1624
- if isinstance(result['summary'], str):
1625
- result['summary'] = "🚀 **GPU Enhanced** (Mixed Precision)\n\n" + result['summary']
1626
- return result
1627
 
1628
  def real_gasm_process_text_cpu_enhanced(text, enable_geometry, show_visualization, max_length):
1629
  """CPU processing with optimizations"""
1630
- result = real_gasm_process_text_cpu(text, enable_geometry, show_visualization, max_length)
1631
- if isinstance(result['summary'], str):
1632
- result['summary'] = "⚡ **CPU Enhanced** (Optimized)\n\n" + result['summary']
1633
- return result
1634
 
1635
 
1636
  def insert_example_text(example_text):
 
1588
  real_gasm_process_text.cache = {}
1589
 
1590
  if cache_key in real_gasm_process_text.cache:
1591
+ cached_result = real_gasm_process_text.cache[cache_key]
1592
+ summary, curvature_plot, entity_3d_plot, detailed_json = cached_result
1593
+ enhanced_summary = "🚀 **Cached Result** (Enhanced)\n\n" + summary
1594
+ return (
1595
+ enhanced_summary,
1596
+ curvature_plot,
1597
+ entity_3d_plot,
1598
+ detailed_json
1599
+ )
1600
 
1601
  # Try GPU first with mixed precision
1602
  try:
 
1610
 
1611
  # Cache successful results (limit cache size for HF)
1612
  if len(real_gasm_process_text.cache) < 20:
1613
+ real_gasm_process_text.cache[cache_key] = result
1614
 
1615
  return result
1616
 
1617
  except Exception as e:
1618
  logger.error(f"All processing failed: {e}")
1619
+ return (
1620
+ f"❌ Processing failed: {str(e)}",
1621
+ None,
1622
+ None,
1623
+ json.dumps({"error": str(e)}, indent=2)
1624
+ )
1625
 
1626
  def real_gasm_process_text_gpu_enhanced(text, enable_geometry, show_visualization, max_length):
1627
  """GPU processing with mixed precision and optimizations"""
1628
  with torch.cuda.amp.autocast():
1629
+ summary, curvature_plot, entity_3d_plot, detailed_json = real_gasm_process_text_gpu(text, enable_geometry, show_visualization, max_length)
1630
+ enhanced_summary = "🚀 **GPU Enhanced** (Mixed Precision)\n\n" + summary
1631
+ return (enhanced_summary, curvature_plot, entity_3d_plot, detailed_json)
 
1632
 
1633
  def real_gasm_process_text_cpu_enhanced(text, enable_geometry, show_visualization, max_length):
1634
  """CPU processing with optimizations"""
1635
+ summary, curvature_plot, entity_3d_plot, detailed_json = real_gasm_process_text_cpu(text, enable_geometry, show_visualization, max_length)
1636
+ enhanced_summary = "⚡ **CPU Enhanced** (Optimized)\n\n" + summary
1637
+ return (enhanced_summary, curvature_plot, entity_3d_plot, detailed_json)
 
1638
 
1639
 
1640
  def insert_example_text(example_text):