Views
No views yet


| Ground Truth Labels | Model Predictions |
|---|---|
![]() | ![]() |
| Ground truth annotations | Model predictions with confidence scores |
pip install ultralytics huggingface_hub torch torchvision opencv-python pillow1from huggingface_hub import hf_hub_download
2from ultralytics import YOLO
3
4# Download the trained model
5model_path = hf_hub_download(
6 repo_id="haydarkadioglu/brand-eye",
7 filename="brandeye.pt"
8)
9
10# Load the model
11model = YOLO(model_path)1import cv2
2from PIL import Image
3
4def detect_brands(image_path, conf_threshold=0.25):
5 """
6 Detect brands in a single image
7
8 Args:
9 image_path (str): Path to the image file
10 conf_threshold (float): Confidence threshold (0.0-1.0)
11
12 Returns:
13 results: Detection results with bounding boxes and labels
14 """
15 results = model(image_path, conf=conf_threshold)
16
17 # Display results
18 results[0].show()
19
20 # Get detection details
21 boxes = results[0].boxes
22 if boxes is not None:
23 print(f"Found {len(boxes)} brand detections:")
24 for box in boxes:
25 conf = box.conf[0].item()
26 cls = int(box.cls[0].item())
27 class_name = model.names[cls]
28 print(f" - {class_name}: {conf:.3f} confidence")
29
30 return results
31
32# Example usage
33results = detect_brands("path/to/your/image.jpg")1import os
2from pathlib import Path
3
4def process_folder(input_folder, output_folder="results", conf=0.25):
5 """
6 Process all images in a folder
7
8 Args:
9 input_folder (str): Path to folder containing images
10 output_folder (str): Path to save results
11 conf (float): Confidence threshold
12 """
13 input_path = Path(input_folder)
14 output_path = Path(output_folder)
15 output_path.mkdir(exist_ok=True)
16
17 # Supported image formats
18 image_extensions = ['.jpg', '.jpeg', '.png', '.bmp', '.tiff', '.webp']
19
20 for img_file in input_path.iterdir():
21 if img_file.suffix.lower() in image_extensions:
22 print(f"Processing {img_file.name}...")
23
24 # Run detection
25 results = model(str(img_file), conf=conf)
26
27 # Save annotated image
28 save_path = output_path / f"detected_{img_file.name}"
29 results[0].save(str(save_path))
30
31 # Print summary
32 boxes = results[0].boxes
33 if boxes is not None:
34 print(f" ✅ Found {len(boxes)} brands")
35 else:
36 print(f" ❌ No brands detected")
37
38# Example usage
39process_folder("input_images/", "detection_results/")1import cv2
2
3def real_time_detection():
4 """
5 Real-time brand detection using webcam
6 """
7 cap = cv2.VideoCapture(0) # Use 0 for default camera
8
9 while True:
10 ret, frame = cap.read()
11 if not ret:
12 break
13
14 # Run detection
15 results = model(frame, conf=0.3)
16
17 # Draw results on frame
18 annotated_frame = results[0].plot()
19
20 # Display frame
21 cv2.imshow('Brand Detection', annotated_frame)
22
23 # Exit on 'q' press
24 if cv2.waitKey(1) & 0xFF == ord('q'):
25 break
26
27 cap.release()
28 cv2.destroyAllWindows()
29
30# Run real-time detection
31# real_time_detection()brand-eye/
├── README.md # This file
├── visualize.ipynb # Training results visualization
├── brandeye.pt # Trained model weights
├── model/
│ ├── train/
│ │ ├── results.csv # Training metrics
│ │ ├── weights/
│ │ │ └── last.pt # Final model checkpoint
│ │ └── *.png # Training plots
│ └── val/
│ ├── predictions.json # Validation predictions
│ └── *.png # Validation visualizations
├── confusion_matrix_normalized.png # Model confusion matrix
└── val_batch*_*.jpg # Validation batch examples1# High precision (fewer false positives)
2results_high_conf = model("image.jpg", conf=0.7)
3
4# High recall (catch more brands, may include false positives)
5results_low_conf = model("image.jpg", conf=0.1)1# Export detections to JSON
2import json
3
4def export_detections(image_path, output_json):
5 results = model(image_path)
6 detections = []
7
8 boxes = results[0].boxes
9 if boxes is not None:
10 for box in boxes:
11 detection = {
12 "class": model.names[int(box.cls[0])],
13 "confidence": float(box.conf[0]),
14 "bbox": box.xyxy[0].tolist() # [x1, y1, x2, y2]
15 }
16 detections.append(detection)
17
18 with open(output_json, 'w') as f:
19 json.dump(detections, f, indent=2)
20
21export_detections("image.jpg", "detections.json")git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)