|
import streamlit as st |
|
import degirum as dg |
|
from PIL import Image |
|
import degirum_tools |
|
|
|
|
|
|
|
|
|
|
|
hw_location = "@cloud" |
|
|
|
|
|
|
|
|
|
|
|
face_model_zoo_url = "https://cs.degirum.com/degirum/ultralytics_v6" |
|
|
|
|
|
face_model_name = "yolov8n_relu6_face--640x640_quant_n2x_orca1_1" |
|
|
|
|
|
age_model_zoo_url = "https://cs.degirum.com/degirum/sandbox" |
|
|
|
|
|
age_model_name = "yolov8s_regress_age_silu_utkface--256x256_float_openvino_cpu_1" |
|
|
|
|
|
face_zoo = dg.connect(hw_location, face_model_zoo_url, token=st.secrets["DG_TOKEN"]) |
|
age_zoo = dg.connect(hw_location, age_model_zoo_url, token=st.secrets["DG_TOKEN"]) |
|
|
|
|
|
face_model = face_zoo.load_model(face_model_name, |
|
image_backend='pil', |
|
overlay_color=(255,0,0), |
|
overlay_line_width=2, |
|
overlay_font_scale=1.5 |
|
) |
|
age_model= age_zoo.load_model(age_model_name, image_backend='pil') |
|
|
|
crop_model = degirum_tools.CroppingAndClassifyingCompoundModel( |
|
face_model, age_model, 50.0 |
|
) |
|
|
|
st.title('DeGirum Cloud Platform Demo of Face Detection and Age Regression Models') |
|
|
|
st.text('Upload an image. Then click on the submit button') |
|
with st.form("model_form"): |
|
uploaded_file=st.file_uploader('input image') |
|
submitted = st.form_submit_button("Submit") |
|
if submitted: |
|
image = Image.open(uploaded_file) |
|
image.thumbnail((640,640), Image.Resampling.LANCZOS) |
|
inference_results=crop_model(image) |
|
st.image(inference_results.image_overlay,caption='Image with Bounding Boxes') |