Commit
•
3215154
1
Parent(s):
1696023
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import degirum as dg
|
3 |
+
from PIL import Image
|
4 |
+
|
5 |
+
zoo=dg.connect(dg.CLOUD,zoo_url='https://cs.degirum.com/degirum/ultralytics_v6',token=st.secrets["DG_TOKEN"])
|
6 |
+
|
7 |
+
st.title('DeGirum Cloud Platform Demo')
|
8 |
+
|
9 |
+
st.header('Specify Model Options Below')
|
10 |
+
runtime_agent_device=st.radio("Choose runtime agent device combo",("TFLite-EdgeTPU","N2X-ORCA","N2X-ORCA1","OpenVINO-CPU"),index=2)
|
11 |
+
runtime_agent,device=runtime_agent_device.split('-')[0],runtime_agent_device.split('-')[1]
|
12 |
+
model_options=zoo.list_models(device=device,runtime=runtime_agent)
|
13 |
+
st.header('Choose and Run a Model')
|
14 |
+
st.text('Select a model and upload an image. Then click on the submit button')
|
15 |
+
with st.form("model_form"):
|
16 |
+
model_name=st.selectbox("Choose a Model from the list", model_options)
|
17 |
+
uploaded_file=st.file_uploader('input image')
|
18 |
+
submitted = st.form_submit_button("Submit")
|
19 |
+
if submitted:
|
20 |
+
model=zoo.load_model(model_name)
|
21 |
+
model.overlay_font_scale=3
|
22 |
+
model.overlay_line_width=6
|
23 |
+
model.image_backend='pil'
|
24 |
+
if model.output_postprocess_type=='PoseDetection':
|
25 |
+
model.overlay_show_labels=False
|
26 |
+
st.write("Model loaded successfully")
|
27 |
+
image = Image.open(uploaded_file)
|
28 |
+
predictions=model(image)
|
29 |
+
if model.output_postprocess_type=='Classification' or model.output_postprocess_type=='DetectionYoloPlates':
|
30 |
+
st.image(predictions.image,caption='Original Image')
|
31 |
+
st.write(predictions.results)
|
32 |
+
else:
|
33 |
+
st.image(predictions.image_overlay,caption='Image with Bounding Boxes/Keypoints')
|