MacSuperior commited on
Commit
6eb7ad3
·
1 Parent(s): 4ad3d33

Update layout for embedded spaces

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -19,15 +19,18 @@ def predict(img):
19
  ort_inputs = {ort_session.get_inputs()[0].name: img}
20
  ort_outputs = ort_session.run(None, ort_inputs)
21
 
22
- #probs = np.exp(ort_outputs) / np.sum(np.exp(ort_outputs)) # softmax
23
-
24
  label_index = np.argmax(ort_outputs[0], axis=1).item()
25
  predicted_label = weights.meta["categories"][label_index]
26
  return predicted_label
27
 
 
 
 
 
 
 
 
 
 
28
 
29
- demo = gr.Interface(predict, gr.Image(type="pil", image_mode="RGB"), gr.Label(),
30
- title="ResNet-50 Using onnxruntime",
31
- description="Upload any image and see if resnet-50 can classify it! (1000 possible image classes)",
32
- article="Part of a tutorial on [how to deploy an ONNX mode to Hugging Face](https://liamgroen.nl/posts/day-6-deploying-model-to-huggingface-spaces-through-onnx/index.html)")
33
- demo.launch()
 
19
  ort_inputs = {ort_session.get_inputs()[0].name: img}
20
  ort_outputs = ort_session.run(None, ort_inputs)
21
 
 
 
22
  label_index = np.argmax(ort_outputs[0], axis=1).item()
23
  predicted_label = weights.meta["categories"][label_index]
24
  return predicted_label
25
 
26
+ with gr.Blocks() as demo:
27
+ gr.Markdown("# ResNet-50 Using ONNX Runtime")
28
+ gr.Markdown("Upload any image and see if ResNet-50 can classify it! (1000 possible image classes)")
29
+
30
+ with gr.Row():
31
+ image_input = gr.Image(type="pil", image_mode="RGB", label="Input Image")
32
+ label_output = gr.Label(label="Predicted Label")
33
+
34
+ gr.Markdown("Part of a tutorial on [how to deploy an ONNX mode to Hugging Face](https://liamgroen.nl/posts/day-6-deploying-model-to-huggingface-spaces-through-onnx/index.html)")
35
 
36
+ demo.launch()