Spaces:
Sleeping
Sleeping
File size: 1,080 Bytes
6c0ab8e |
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 |
import gradio as gr
from huggingface_hub import hf_hub_download
from ultralytics import YOLO
import torch
# Lade das Modell
model_path = hf_hub_download(repo_id="foduucom/stockmarket-pattern-detection-yolov8", filename="model.pt")
model = YOLO(model_path)
def analyze_image(image):
# Führe Objekterkennung durch
results = model.predict(source=image, save=False)
# Extrahiere Ergebnisse
detections = []
for result in results:
for box in result.boxes:
label = result.names[int(box.cls)]
confidence = float(box.conf)
detections.append({
"pattern": label,
"confidence": confidence,
"color": "green" if "Bullish" in label else "red"
})
return detections
# Erstelle Gradio-Schnittstelle
iface = gr.Interface(
fn=analyze_image,
inputs=gr.Image(type="pil"),
outputs="json",
title="Candlestick Pattern Detection",
description="Upload a TradingView screenshot to detect candlestick patterns and colors."
)
# Starte die App
iface.launch() |