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",("TFLite-EdgeTPU","N2X-ORCA","N2X-ORCA1","OpenVINO-CPU"),index=2) 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"): model_name=st.selectbox("Choose a Model from the list", model_options) 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' model.measure_time=True 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') stats=model.time_stats() st.write('Expected Frames per second for the model= ', 1000.0/stats["CoreInferenceDuration_ms"].avg)