Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -25,7 +25,7 @@ def hello_world():
|
|
25 |
url = request.args.get('url')
|
26 |
|
27 |
if url is None:
|
28 |
-
return jsonify(error="Url is required", url=None,
|
29 |
|
30 |
image = Image.open(requests.get(url, stream=True).raw)
|
31 |
|
@@ -36,4 +36,4 @@ def hello_world():
|
|
36 |
# model predicts one of the 1000 ImageNet classes
|
37 |
predicted_class_idx = logits.argmax(-1).item()
|
38 |
|
39 |
-
return jsonify(url=url,
|
|
|
25 |
url = request.args.get('url')
|
26 |
|
27 |
if url is None:
|
28 |
+
return jsonify(error="Url is required", url=None, label=None)
|
29 |
|
30 |
image = Image.open(requests.get(url, stream=True).raw)
|
31 |
|
|
|
36 |
# model predicts one of the 1000 ImageNet classes
|
37 |
predicted_class_idx = logits.argmax(-1).item()
|
38 |
|
39 |
+
return jsonify(url=url, label=model.config.id2label[predicted_class_idx])
|