File size: 699 Bytes
c25b15a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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()