Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -109,16 +109,12 @@ def classifyCar(im):
|
|
| 109 |
|
| 110 |
# if a car was detected, extract the car and perform modernity score classification
|
| 111 |
if len(boxes) != 0:
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
#im2 = Image.fromarray(np.uint8(im)).convert('RGB').crop(boxes[max_idx].to(torch.int64).numpy())
|
| 115 |
-
im2 = cropImage(outputs, im, boxes, car_class_true)
|
| 116 |
-
#carResize = transforms.Compose([transforms.Resize((224, 224))])
|
| 117 |
-
#im2 = carResize(im2)
|
| 118 |
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
|
| 123 |
# if no car was detected, show original image and print "No car detected"
|
| 124 |
else:
|
|
|
|
| 109 |
|
| 110 |
# if a car was detected, extract the car and perform modernity score classification
|
| 111 |
if len(boxes) != 0:
|
| 112 |
+
im2 = cropImage(outputs, im, boxes, car_class_true)
|
| 113 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
|
| 115 |
+
with torch.no_grad():
|
| 116 |
+
scores = torch.nn.functional.softmax(DesignModernityModel(carTransforms(im2).unsqueeze(0))[0])
|
| 117 |
+
label = {LABELS[i]: float(scores[i]) for i in range(n_labels)}
|
| 118 |
|
| 119 |
# if no car was detected, show original image and print "No car detected"
|
| 120 |
else:
|