Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,14 +25,10 @@ def predict(img):
|
|
| 25 |
confidences: python dictionary containing confidences
|
| 26 |
'''
|
| 27 |
# Transform image to pytorch tensor of shape [1, 3, 224, 224]
|
| 28 |
-
|
| 29 |
img = T.PILToTensor()(img).unsqueeze(0)
|
| 30 |
-
print(img.dtype)
|
| 31 |
-
print(type(img))
|
| 32 |
img = T.Resize(size=(224, 224))(img)
|
| 33 |
img = img / 255
|
| 34 |
-
print(type(img))
|
| 35 |
-
print(img.dtype)
|
| 36 |
|
| 37 |
# Use model without gradients to reduce computation
|
| 38 |
with torch.no_grad():
|
|
@@ -48,4 +44,4 @@ gr.Interface(fn=predict,
|
|
| 48 |
inputs=gr.Image(type="pil"),
|
| 49 |
outputs=gr.Label(num_top_classes=10),
|
| 50 |
theme="default",
|
| 51 |
-
).launch(share=
|
|
|
|
| 25 |
confidences: python dictionary containing confidences
|
| 26 |
'''
|
| 27 |
# Transform image to pytorch tensor of shape [1, 3, 224, 224]
|
| 28 |
+
# Put your image transforms here
|
| 29 |
img = T.PILToTensor()(img).unsqueeze(0)
|
|
|
|
|
|
|
| 30 |
img = T.Resize(size=(224, 224))(img)
|
| 31 |
img = img / 255
|
|
|
|
|
|
|
| 32 |
|
| 33 |
# Use model without gradients to reduce computation
|
| 34 |
with torch.no_grad():
|
|
|
|
| 44 |
inputs=gr.Image(type="pil"),
|
| 45 |
outputs=gr.Label(num_top_classes=10),
|
| 46 |
theme="default",
|
| 47 |
+
).launch(share=False)
|