Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -26,8 +26,6 @@ model = model.eval()
|
|
| 26 |
imagenet_id_to_classname = {}
|
| 27 |
for k, v in imagenet_classnames.items():
|
| 28 |
imagenet_id_to_classname[k] = v[1]
|
| 29 |
-
|
| 30 |
-
os.system("wget https://upload.wikimedia.org/wikipedia/commons/thumb/c/c5/13-11-02-olb-by-RalfR-03.jpg/800px-13-11-02-olb-by-RalfR-03.jpg -O library.jpg")
|
| 31 |
|
| 32 |
def inference(img):
|
| 33 |
image = img
|
|
@@ -47,13 +45,6 @@ def inference(img):
|
|
| 47 |
prediction = model(image)
|
| 48 |
prediction = F.softmax(prediction, dim=1)
|
| 49 |
|
| 50 |
-
# pred_classes = prediction.topk(k=5).indices
|
| 51 |
-
# pred_class_names = [imagenet_id_to_classname[str(i.item())] for i in pred_classes[0]]
|
| 52 |
-
# pred_class_probs = [prediction[0][i.item()].item() * 100 for i in pred_classes[0]]
|
| 53 |
-
# res = "Top 5 predicted labels:\n"
|
| 54 |
-
# for name, prob in zip(pred_class_names, pred_class_probs):
|
| 55 |
-
# res += f"[{prob:2.2f}%]\t{name}\n"
|
| 56 |
-
|
| 57 |
return {imagenet_id_to_classname[str(i)]: float(prediction[0][i]) for i in range(1000)}
|
| 58 |
|
| 59 |
inputs = gr.inputs.Image(type='pil')
|
|
|
|
| 26 |
imagenet_id_to_classname = {}
|
| 27 |
for k, v in imagenet_classnames.items():
|
| 28 |
imagenet_id_to_classname[k] = v[1]
|
|
|
|
|
|
|
| 29 |
|
| 30 |
def inference(img):
|
| 31 |
image = img
|
|
|
|
| 45 |
prediction = model(image)
|
| 46 |
prediction = F.softmax(prediction, dim=1)
|
| 47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
return {imagenet_id_to_classname[str(i)]: float(prediction[0][i]) for i in range(1000)}
|
| 49 |
|
| 50 |
inputs = gr.inputs.Image(type='pil')
|