Views
No views yet
SenseTime/deformable-detr architecture, specifically trained for object detection on fisheye camera imagery. It is a product of the Mcity Data Engine, an open-source system designed for iterative data selection and model improvement in Intelligent Transportation Systems (ITS). The model can detect objects such as "Bus", "Bike", "Car", "Pedestrian", and "Truck", leveraging an open-vocabulary data selection process during its development to focus on rare and novel classes.transformers pipeline for object detection:1from transformers import pipeline
2from PIL import Image
3import requests
4from io import BytesIO
5
6# Load the object detection pipeline
7detector = pipeline("object-detection", model="mcity-data-engine/fisheye8k_SenseTime_deformable-detr")
8
9# Example image (replace with a relevant fisheye image if available, or a local path)
10# Using a generic example image for demonstration purposes. For best results, use a fisheye image.
11image_url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/bird_sized.jpg"
12try:
13 response = requests.get(image_url, stream=True)
14 response.raise_for_status() # Raise an HTTPError for bad responses (4xx or 5xx)
15 image = Image.open(BytesIO(response.content)).convert("RGB")
16except requests.exceptions.RequestException as e:
17 print(f"Could not load example image from URL: {e}. Please provide a local image path.")
18 # Fallback/exit if image cannot be loaded
19 exit()
20
21# Perform inference
22predictions = detector(image)
23
24# Print detected objects
25for pred in predictions:
26 print(f"Label: {pred['label']}, Score: {pred['score']:.2f}, Box: {pred['box']}")
27
28# For visualization (optional, requires matplotlib):
29# from matplotlib import pyplot as plt
30# import matplotlib.patches as patches
31#
32# fig, ax = plt.subplots(1)
33# ax.imshow(image)
34#
35# for p in predictions:
36# box = p['box']
37# rect = patches.Rectangle((box['xmin'], box['ymin']), box['xmax'] - box['xmin'], box['ymax'] - box['ymin'],
38# linewidth=1, edgecolor='r', facecolor='none')
39# ax.add_patch(rect)
40# plt.text(box['xmin'], box['ymin'] - 5, f"{p['label']}: {p['score']:.2f}", color='red', fontsize=8)
41#
42# plt.show()| Training Loss | Epoch | Step | Validation Loss |
|---|---|---|---|
| 0.8943 | 1.0 | 5288 | 1.5330 |
| 0.7865 | 2.0 | 10576 | 1.4108 |
| 0.7238 | 3.0 | 15864 | 1.2660 |
| 0.6657 | 4.0 | 21152 | 1.2084 |
| 0.646 | 5.0 | 26440 | 1.2666 |
| 0.6269 | 6.0 | 31728 | 1.2555 |
| 0.6049 | 7.0 | 37016 | 1.2350 |
| 0.5894 | 8.0 | 42304 | 1.2940 |
| 0.5484 | 9.0 | 47592 | 1.2335 |