Spaces:
Runtime error
Runtime error
File size: 2,662 Bytes
3215154 1a288da f847c42 3215154 dac7449 3215154 f847c42 2c9e18b f847c42 3215154 7acb21a 92cfad7 3160d15 4fb2279 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
import streamlit as st
import degirum as dg
from PIL import Image
zoo=dg.connect(dg.CLOUD,zoo_url='https://cs.degirum.com/degirum/ultralytics_v6',token=st.secrets["DG_TOKEN"])
st.title('DeGirum Cloud Platform Demo')
with st.sidebar:
st.header('Specify Model Options Below')
runtime_agent_device=st.radio("Choose runtime agent device combo",("N2X-ORCA1","TFLite-EdgeTPU","OpenVINO-CPU"),index=0,horizontal=True)
activation_option=st.radio( 'Select activation function', ['relu6', 'silu'],horizontal=True)
dataset_option=st.radio( 'Select a dataset option', ['coco', 'face','lp','car','hand'],horizontal=True)
show_labels=st.toggle('Show labels in output',value=True)
show_probabilities=st.toggle('Show probabilities in output',value=False)
runtime_agent,device=runtime_agent_device.split('-')[0],runtime_agent_device.split('-')[1]
model_options=zoo.list_models(device=device,runtime=runtime_agent)
st.header('Choose and Run a Model')
st.text('Select a model and upload an image. Then click on the submit button')
with st.form("model_form"):
filtered_model_list=[]
for model in model_options:
if activation_option in model and dataset_option in model:
filtered_model_list.append(model)
st.write('Number of models found = ', len(filtered_model_list))
model_name=st.selectbox("Choose a Model from the list", filtered_model_list)
uploaded_file=st.file_uploader('input image')
submitted = st.form_submit_button("Submit")
if submitted:
model=zoo.load_model(model_name,
overlay_show_labels=show_labels,
overlay_show_probabilities=show_probabilities,
overlay_font_scale=3,
overlay_line_width=6,
image_backend='pil'
)
if model.output_postprocess_type=='PoseDetection':
model.overlay_show_labels=False
st.write("Model loaded successfully")
image = Image.open(uploaded_file)
predictions=model(image)
if model.output_postprocess_type=='Classification' or model.output_postprocess_type=='DetectionYoloPlates':
st.image(predictions.image,caption='Original Image')
st.write(predictions.results)
else:
st.image(predictions.image_overlay,caption='Image with Bounding Boxes/Keypoints')
model.measure_time=True
predictions=model(image)
stats=model.time_stats()
st.write('Expected Frames per second for the model= ', 1000.0/stats["CoreInferenceDuration_ms"].avg) |