Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -82,8 +82,11 @@ def classifyCar(im):
|
|
| 82 |
|
| 83 |
im2 = Image.fromarray(np.uint8(im)).convert('RGB').crop(boxes[max_idx].to(torch.int64).numpy())
|
| 84 |
|
| 85 |
-
|
| 86 |
-
im2 =
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
label = "success"
|
| 89 |
except:
|
|
@@ -93,7 +96,7 @@ def classifyCar(im):
|
|
| 93 |
# scores = torch.nn.functional.softmax(DesignModernityModel(im2)[0])
|
| 94 |
#{LABELS[i]: float(scores[i]) for i in range(n_labels)}
|
| 95 |
#Image.fromarray(np.uint8(out.get_image())).convert('RGB')
|
| 96 |
-
return im2,
|
| 97 |
|
| 98 |
#examples = [[example_img.jpg], [example_img2.jpg]] # must be uploaded in repo
|
| 99 |
|
|
|
|
| 82 |
|
| 83 |
im2 = Image.fromarray(np.uint8(im)).convert('RGB').crop(boxes[max_idx].to(torch.int64).numpy())
|
| 84 |
|
| 85 |
+
carResize = transforms.Compose([transforms.Resize((224, 224))])
|
| 86 |
+
im2 = carResize(im2)
|
| 87 |
+
|
| 88 |
+
with torch.no_grad():
|
| 89 |
+
scores = torch.nn.functional.softmax(DesignModernityModel(carTransforms(im2).unsqueeze(0))[0])
|
| 90 |
|
| 91 |
label = "success"
|
| 92 |
except:
|
|
|
|
| 96 |
# scores = torch.nn.functional.softmax(DesignModernityModel(im2)[0])
|
| 97 |
#{LABELS[i]: float(scores[i]) for i in range(n_labels)}
|
| 98 |
#Image.fromarray(np.uint8(out.get_image())).convert('RGB')
|
| 99 |
+
return im2, {LABELS[i]: float(scores[i]) for i in range(n_labels)}
|
| 100 |
|
| 101 |
#examples = [[example_img.jpg], [example_img2.jpg]] # must be uploaded in repo
|
| 102 |
|