Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -66,11 +66,12 @@ carTransforms = transforms.Compose([transforms.Resize(224),
|
|
| 66 |
|
| 67 |
def classifyCar(im):
|
| 68 |
im = Image.fromarray(im.astype('uint8'), 'RGB')
|
| 69 |
-
im = carTransforms(im).unsqueeze(0) # transform and add batch dimension
|
| 70 |
with torch.no_grad():
|
| 71 |
outputs = predictor(im)
|
| 72 |
v = Visualizer(im[:, :, ::-1], MetadataCatalog.get(cfg.DATASETS.TRAIN[0]), scale=1.2)
|
| 73 |
out = v.draw_instance_predictions(outputs["instances"].to("cpu"))
|
|
|
|
|
|
|
| 74 |
scores = torch.nn.functional.softmax(DesignModernityModel(im)[0])
|
| 75 |
return Image.fromarray(np.uint8(out.get_image())).convert('RGB'), {LABELS[i]: float(scores[i]) for i in range(n_labels)}
|
| 76 |
|
|
|
|
| 66 |
|
| 67 |
def classifyCar(im):
|
| 68 |
im = Image.fromarray(im.astype('uint8'), 'RGB')
|
|
|
|
| 69 |
with torch.no_grad():
|
| 70 |
outputs = predictor(im)
|
| 71 |
v = Visualizer(im[:, :, ::-1], MetadataCatalog.get(cfg.DATASETS.TRAIN[0]), scale=1.2)
|
| 72 |
out = v.draw_instance_predictions(outputs["instances"].to("cpu"))
|
| 73 |
+
im = carTransforms(im).unsqueeze(0) # transform and add batch dimension
|
| 74 |
+
with torch.no_grad():
|
| 75 |
scores = torch.nn.functional.softmax(DesignModernityModel(im)[0])
|
| 76 |
return Image.fromarray(np.uint8(out.get_image())).convert('RGB'), {LABELS[i]: float(scores[i]) for i in range(n_labels)}
|
| 77 |
|