Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
@@ -21,7 +21,7 @@ def _get_layers(arch:str, pretrained=True):
|
|
21 |
"Get the layers and arch for a VGG Model (16 and 19 are supported only)"
|
22 |
feat_net = vgg19(pretrained=pretrained) if arch.find('9') > 1 else vgg16(pretrained=pretrained)
|
23 |
config = _vgg_config.get(arch)
|
24 |
-
features = feat_net.features.
|
25 |
for p in features.parameters(): p.requires_grad=False
|
26 |
return feat_net, [features[i] for i in config]
|
27 |
|
@@ -38,7 +38,7 @@ learner = from_pretrained_fastai(repo_id)
|
|
38 |
|
39 |
def infer(img):
|
40 |
pred = learner.predict(img)
|
41 |
-
image = pred[0].
|
42 |
image = image.transpose((1, 2, 0))
|
43 |
plt.imshow(image)
|
44 |
return plt.gcf() #pred[0].show()
|
|
|
21 |
"Get the layers and arch for a VGG Model (16 and 19 are supported only)"
|
22 |
feat_net = vgg19(pretrained=pretrained) if arch.find('9') > 1 else vgg16(pretrained=pretrained)
|
23 |
config = _vgg_config.get(arch)
|
24 |
+
features = feat_net.features.eval()
|
25 |
for p in features.parameters(): p.requires_grad=False
|
26 |
return feat_net, [features[i] for i in config]
|
27 |
|
|
|
38 |
|
39 |
def infer(img):
|
40 |
pred = learner.predict(img)
|
41 |
+
image = pred[0].numpy()
|
42 |
image = image.transpose((1, 2, 0))
|
43 |
plt.imshow(image)
|
44 |
return plt.gcf() #pred[0].show()
|