File size: 2,209 Bytes
3215154
 
 
 
 
 
 
 
 
9fd2506
3215154
 
d86ef72
52321f3
3215154
 
 
dac7449
 
 
 
 
 
3215154
 
 
 
 
 
92cfad7
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
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')

st.header('Specify Model Options Below')
runtime_agent_device=st.radio("Choose runtime agent device combo",("N2X-ORCA1","N2X-ORCA","TFLite-EdgeTPU","OpenVINO-CPU"),index=0)
runtime_agent,device=runtime_agent_device.split('-')[0],runtime_agent_device.split('-')[1]
model_options=zoo.list_models(device=device,runtime=runtime_agent)
activation_option=st.radio( 'Select activation function', ['relu6', 'silu'])
dataset_option=st.radio( 'Select a dataset option', ['coco', 'face','lp','car','hand'])
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)
        model.overlay_font_scale=3
        model.overlay_line_width=6
        model.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)