| from solution import TrafficViolationDetector | |
| from pathlib import Path | |
| import json | |
| def run(): | |
| print("Loading models...") | |
| detector = TrafficViolationDetector(model_dir=str(Path("models").resolve().absolute())) | |
| images = ["testimages/1.jpg", "testimages/2.webp", "testimages/images.jpg"] | |
| results = {} | |
| print("Running inference...") | |
| for img in images: | |
| if Path(img).exists(): | |
| print(f"Processing {img}...") | |
| res = detector.predict(img) | |
| results[img] = res | |
| else: | |
| results[img] = "File not found" | |
| print("\n--- RESULTS ---") | |
| print(json.dumps(results, indent=2)) | |
| if __name__ == "__main__": | |
| run() | |