doinglean commited on
Commit
9b9b214
·
verified ·
1 Parent(s): dd9548e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -3,6 +3,15 @@ from transformers import AutoModelForObjectDetection, AutoImageProcessor
3
  import cv2
4
  import numpy as np
5
  import torch
 
 
 
 
 
 
 
 
 
6
 
7
  # Lade das Modell und den Image Processor
8
  model = AutoModelForObjectDetection.from_pretrained("facebook/dinov3-convnext-small-pretrain-lvd1689m")
@@ -33,9 +42,8 @@ def analyze_image(image, prompt):
33
  mean_color = np.mean(candle_roi, axis=(0, 1)).astype(int)
34
  color_rgb = f"RGB({mean_color[2]},{mean_color[1]},{mean_color[0]})"
35
 
36
- # Generische Labels, da DINOv3 nicht candlestick-spezifisch ist
37
  detections.append({
38
- "pattern": f"Candlestick_{label.item()}", # Placeholder
39
  "confidence": score.item(),
40
  "color": color_rgb,
41
  "x_center": (xmin + xmax) / 2,
 
3
  import cv2
4
  import numpy as np
5
  import torch
6
+ import os
7
+ from huggingface_hub import login
8
+
9
+ # Authentifizierung mit Hugging Face API-Token
10
+ HF_TOKEN = os.getenv("HF_TOKEN")
11
+ if HF_TOKEN:
12
+ login(HF_TOKEN)
13
+ else:
14
+ raise ValueError("HF_TOKEN environment variable not set. Please add it in Space settings.")
15
 
16
  # Lade das Modell und den Image Processor
17
  model = AutoModelForObjectDetection.from_pretrained("facebook/dinov3-convnext-small-pretrain-lvd1689m")
 
42
  mean_color = np.mean(candle_roi, axis=(0, 1)).astype(int)
43
  color_rgb = f"RGB({mean_color[2]},{mean_color[1]},{mean_color[0]})"
44
 
 
45
  detections.append({
46
+ "pattern": f"Candlestick_{label.item()}", # Generische Labels
47
  "confidence": score.item(),
48
  "color": color_rgb,
49
  "x_center": (xmin + xmax) / 2,