Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -64,7 +64,7 @@ def analyze_image(image, prompt):
|
|
| 64 |
if "<OD>" in predictions:
|
| 65 |
for i, (bbox, label) in enumerate(zip(predictions["<OD>"]["bboxes"], predictions["<OD>"]["labels"])):
|
| 66 |
# Erweitere Filter fΓΌr Kerzen
|
| 67 |
-
if "candle" not in label.lower() and "bar" not in label.lower() and "chart" not in label.lower():
|
| 68 |
continue
|
| 69 |
xmin, ymin, xmax, ymax = map(int, bbox)
|
| 70 |
|
|
@@ -106,4 +106,18 @@ def analyze_image(image, prompt):
|
|
| 106 |
return {"prompt": prompt, "detections": detections}
|
| 107 |
|
| 108 |
else:
|
| 109 |
-
return {"prompt": prompt, "description": "Unsupported prompt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
if "<OD>" in predictions:
|
| 65 |
for i, (bbox, label) in enumerate(zip(predictions["<OD>"]["bboxes"], predictions["<OD>"]["labels"])):
|
| 66 |
# Erweitere Filter fΓΌr Kerzen
|
| 67 |
+
if "candle" not in label.lower() and "bar" not in label.lower() and "chart" not in label.lower() and "candlestick" not in label.lower():
|
| 68 |
continue
|
| 69 |
xmin, ymin, xmax, ymax = map(int, bbox)
|
| 70 |
|
|
|
|
| 106 |
return {"prompt": prompt, "detections": detections}
|
| 107 |
|
| 108 |
else:
|
| 109 |
+
return {"prompt": prompt, "description": "Unsupported prompt. Use 'Was siehst du auf dem Bild?' or 'List last 8 candles with their colors'."}
|
| 110 |
+
|
| 111 |
+
# Erstelle Gradio-Schnittstelle
|
| 112 |
+
iface = gr.Interface(
|
| 113 |
+
fn=analyze_image,
|
| 114 |
+
inputs=[
|
| 115 |
+
gr.Image(type="pil", label="Upload an Image"),
|
| 116 |
+
gr.Textbox(label="Prompt", placeholder="Enter your prompt, e.g., 'Was siehst du auf dem Bild?' or 'List last 8 candles with their colors'")
|
| 117 |
+
],
|
| 118 |
+
outputs="json",
|
| 119 |
+
title="Image Analysis with Florence-2-base",
|
| 120 |
+
description="Upload an image to analyze candlesticks or get a general description."
|
| 121 |
+
)
|
| 122 |
+
|
| 123 |
+
iface.launch()
|