Spaces:
Running on Zero
Running on Zero
Download src/integration/near_miss_processor.py from vish07anth/ATA: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/spaces/vish07anth/ATA/resolve/main/src/integration/near_miss_processor.py
- Command line
-
hf download hf://spaces/vish07anth/ATA/src/integration/near_miss_processor.py
-
curl -L -o near_miss_processor.py https://huggingface.co/spaces/vish07anth/ATA/resolve/main/src/integration/near_miss_processor.py
1.01 kB
| from src.integration.near_miss_feature_adapter import ( | |
| NearMissFeatureAdapter | |
| ) | |
| class NearMissProcessor: | |
| def __init__(self): | |
| self.adapter = NearMissFeatureAdapter() | |
| def process_frame(self, detections): | |
| vehicles = [] | |
| for detection in detections: | |
| if not detection.get("tracking_status") == "active": | |
| continue | |
| vehicles.append(detection) | |
| results = [] | |
| for i in range(len(vehicles)): | |
| for j in range(i + 1, len(vehicles)): | |
| vehicle1 = vehicles[i] | |
| vehicle2 = vehicles[j] | |
| features = self.adapter.create_features( | |
| vehicle1, | |
| vehicle2, | |
| len(vehicles) | |
| ) | |
| results.append({ | |
| "vehicle_1": vehicle1["vehicle_id"], | |
| "vehicle_2": vehicle2["vehicle_id"], | |
| "features": features | |
| }) | |
| return results |