forked from danieltwh/Insurtech-CV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testCostEstimate.py
26 lines (20 loc) · 892 Bytes
/
testCostEstimate.py
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 PIL import Image
import numpy as np
from scripts.CostPrediction import costEstimate
from scripts.NewCarSidePrediction import CarSideModel
from scripts.NewDamagePrediction import DamageDetectionModel, DamageSegmentationModel
# Loading Models
carSideModel = CarSideModel("weights/Carside_Yolo.pt")
damageDetectModel = DamageDetectionModel("weights/Damage_Yolo.pt")
damageSegmentModel = DamageSegmentationModel("weights/Damage_MRCNN.h5")
# Loading image for demonstration
img = np.asarray(Image.open('scripts/2.jpg'))
# Detections
original, processed, coords = carSideModel.predict_single(img)
_, _, damageSegments = damageSegmentModel.predict_single(img)
_, _, damagePreds = damageDetectModel.predict_single(img)
# Calculate Costs
total_cost = costEstimate(coords, damageSegments, img)
yolo_total_cost = costEstimate(coords, damagePreds, img)
print(total_cost)
print(yolo_total_cost)