Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -9,6 +9,12 @@ model = torch.hub.load('pytorch/vision:v0.6.0', 'resnet18', pretrained=True).eva
|
|
9 |
response = requests.get("https://git.io/JJkYN")
|
10 |
labels = response.text.split("\n")
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
def predict(inp):
|
13 |
inp = transforms.ToTensor()(inp).unsqueeze(0)
|
14 |
with torch.no_grad():
|
@@ -16,4 +22,9 @@ def predict(inp):
|
|
16 |
confidences = {labels[i]: float(prediction[i]) for i in range(1000)}
|
17 |
return confidences
|
18 |
|
19 |
-
gr.Interface(fn=predict,
|
|
|
|
|
|
|
|
|
|
|
|
9 |
response = requests.get("https://git.io/JJkYN")
|
10 |
labels = response.text.split("\n")
|
11 |
|
12 |
+
title = "Image Classifier Two -- PyTorch Resnet-18"
|
13 |
+
description = """This machine has vision. It can see objects and concepts in an image. To test the machine, upload or drop an image, submit and read the results. The results comprise a list of words that the machine sees in the image. Beside a word, the length of the bar indicates the confidence with which the machine sees the word. The longer the bar, the more confident the machine is.
|
14 |
+
"""
|
15 |
+
article = "This app was made by following [this Gradio guide](https://gradio.app/image_classification_in_pytorch/)."
|
16 |
+
|
17 |
+
|
18 |
def predict(inp):
|
19 |
inp = transforms.ToTensor()(inp).unsqueeze(0)
|
20 |
with torch.no_grad():
|
|
|
22 |
confidences = {labels[i]: float(prediction[i]) for i in range(1000)}
|
23 |
return confidences
|
24 |
|
25 |
+
gr.Interface(fn=predict,
|
26 |
+
inputs = gr.inputs.Image(type="pil"),
|
27 |
+
outputs = gr.outputs.Label(num_top_classes=5),
|
28 |
+
title = title,
|
29 |
+
description = description,
|
30 |
+
article = article).launch()
|