Spaces:
Sleeping
Sleeping
File size: 1,888 Bytes
b60b6c5 |
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 51 52 53 54 55 |
### Pipelining Two Models This notebook is an example of how to use DeGirum PySDK to do AI inference of a video file using two AI models: face detection and gender classification. The face detection model is run on the image and the results are then processed by the gender classification model, one face at a time. Combined result is then displayed. -------------------------------------------------------------------------------- import degirum as dg, degirum_tools inference_host_address = "@local" zoo_url = 'degirum/hailo' token='' device_type=['HAILORT/HAILO8L'] # specify model names face_det_model_name = "yolov8n_relu6_face--640x640_quant_hailort_hailo8l_1" gender_cls_model_name = "yolov8n_relu6_fairface_gender--256x256_quant_hailort_hailo8l_1" # specify video source video_source = "../assets/faces_and_gender.mp4" # Load face detection and gender detection models face_det_model = dg.load_model( model_name=face_det_model_name, inference_host_address=inference_host_address, zoo_url=zoo_url, token='', device_type=device_type, overlay_color=[(255,255,0),(0,255,0)] ) gender_cls_model = dg.load_model( model_name=gender_cls_model_name, inference_host_address=inference_host_address, zoo_url=zoo_url, token='', device_type=device_type, ) # Create a compound cropping model with 20% crop extent crop_model = degirum_tools.CroppingAndClassifyingCompoundModel( face_det_model, gender_cls_model, 30.0 ) # run AI inference on video stream inference_results = degirum_tools.predict_stream(crop_model, video_source) # display inference results # Press 'x' or 'q' to stop with degirum_tools.Display("Faces and Gender") as display: for inference_result in inference_results: display.show(inference_result.image_overlay) -------------------------------------------------------------------------------- |