Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -81,9 +81,15 @@ def classifyCar(im):
|
|
| 81 |
out = v.draw_instance_predictions(outputs["instances"].to("cpu"))
|
| 82 |
except Exception as err:
|
| 83 |
return im, {"error3": 0.5}
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
return Image.fromarray(np.uint8(out.get_image())).convert('RGB'), {LABELS[i]: float(scores[i]) for i in range(n_labels)}
|
| 88 |
|
| 89 |
#examples = [[example_img.jpg], [example_img2.jpg]] # must be uploaded in repo
|
|
|
|
| 81 |
out = v.draw_instance_predictions(outputs["instances"].to("cpu"))
|
| 82 |
except Exception as err:
|
| 83 |
return im, {"error3": 0.5}
|
| 84 |
+
try:
|
| 85 |
+
im2 = carTransforms(im).unsqueeze(0) # transform and add batch dimension
|
| 86 |
+
except:
|
| 87 |
+
return im, {"error4": 0.5}
|
| 88 |
+
try:
|
| 89 |
+
with torch.no_grad():
|
| 90 |
+
scores = torch.nn.functional.softmax(DesignModernityModel(im2)[0])
|
| 91 |
+
except:
|
| 92 |
+
return im, {"error5": 0.5}
|
| 93 |
return Image.fromarray(np.uint8(out.get_image())).convert('RGB'), {LABELS[i]: float(scores[i]) for i in range(n_labels)}
|
| 94 |
|
| 95 |
#examples = [[example_img.jpg], [example_img2.jpg]] # must be uploaded in repo
|