“SC‑Depth v3 + DeGirum PySDK on Hailo‑8: Can’t run Python post-processor”

Hello everyone, I’m trying to run SC‑Depth v3 using DeGirum PySDK via the tutorial thread here (linked above), but I’m running into persistent errors and cannot get depth values out.

My Depth.py file:

import os, sys
sys.path.insert(0, "/home/pi/hailo_model_zoo")
os.environ["PYTHONPATH"] = "/home/pi/hailo_model_zoo:" + os.environ.get("PYTHONPATH", "")

import degirum as dg
import cv2
import numpy as np
from picamera2 import Picamera2

# 1. Load your SC-Depth V3 model
model = dg.load_model(
    model_name='scdepthv3',
    inference_host_address='@local',
    zoo_url='/home/pi/my_hailo_zoo'
)

#  2. Initialize the AI camera
picam2 = Picamera2()
cfg = picam2.create_preview_configuration(main={"size": (384, 384), "format": "RGB888"})
picam2.configure(cfg)
picam2.start()

print("Starting depth inference. Press 'q' or 'x' to exit.")
while True:
    frame = picam2.capture_array()  # RGB image
    
    # 1. Resize to (width=320, height=256)
    resized = cv2.resize(frame, (320, 256), interpolation=cv2.INTER_LINEAR)
    
    # Manually apply TensorFlow-like preprocessing:
    img = resized.astype(np.uint8) 
    # e.g. resize with OpenCV or PIL and multiply by 255 as needed
    result = model(img)
    

    # 4. Get normalized depth overlay
    overlay = result.image_overlay  # already visualized by your postprocessor

    # 5. Resize for display (optional)
    display = cv2.resize(overlay, (640, 480))

    # 6. Show result
    cv2.imshow("SC-Depth V3 output", display)

    if cv2.waitKey(1) & 0xFF in (ord('q'), ord('x')):
        break

# Cleanup
cv2.destroyAllWindows()
picam2.stop()

My current JSON configuration:

{
  "ConfigVersion": 10,
  "DEVICE": [
    {
      "DeviceType": "HAILO8",
      "RuntimeAgent": "HAILORT",
      "SupportedDeviceTypes": "HAILORT/HAILO8"
    }
  ],
  "PRE_PROCESS": [
    {
      "InputType": "Tensor",
      "InputN": 1,
      "InputH": 256,
      "InputW": 320,
      "InputC": 3,
      "InputRawDataType": "DG_UINT8"
    }
  ],
  "MODEL_PARAMETERS": [
    { "ModelPath": "scdepthv3.hef" }
  ],
  "POST_PROCESS": [
    {
      "OutputPostprocessType": "None",
      "PythonFile": "depth_estimation_postprocessing.py",
      "MetaArch": "scdepthv3"
    }
  ]
}

Post-processor used

I’ve referenced and copied this post‑processing code from the official Hailo Model Zoo GitHub:
sample snippet from depth_estimation_postprocessing.py

Errors I encounter

  • Many of the errors previously shared include:
    • AttributeError: module 'depth_estimation_postprocessing' has no attribute 'PostProcessor'
    • Other runtime exceptions in Python worker threads

My goals

  1. Successfully infer using SC‑Depth v3 on Hailo‑8 with DeGirum PySDK on Raspberry Pi.
  2. Retrieve numeric per-pixel depth values (not just overlays), especially at the center or arbitrary pixel coordinates.

Questions

  • Did I set "OutputPostprocessType": "Python" and "MetaArch": "scdepthv3" correctly?
  • Do I need to register or implement a custom PostProcessor class instead of a standalone function?
  • Should I instead set "OutputPostprocessType": "None" and manually extract results using model.predict() or predict_batch()?

If anyone could share a minimal working JSON configuration or Python postprocessor that successfully returns depth map data (rather than raising module or attribute errors), I’d be very grateful.

Thanks in advance!

Hi @Durrani_Hakim
I am from the DeGirum team and we can try to help. The main issue I see here is that you mixed postprocessing code that is incompatible with PySDK. The model JSON for PySDK does not accept MetaArch as a field and the postprocessor should be written in a particular way. We will provide you a minimum working example script for this model, but we need a couple of days to prepare all the assets. Thank you for your patience.

1 Like

Thanks @shashi, looking forward to it!

Hi @Durrani_Hakim
Please see our pysdk notebook for depth estimation here: hailo_examples/examples/022_monocular_depth_estimation.ipynb at main · DeGirum/hailo_examples. Feel free to let us know if you have any questions.

hailo_examples/examples/022_monocular_depth_estimation.ipynb at main · DeGirum/hailo_examples With this solution, is it possible to integrate a YOLO model to perform depth estimation?

Not sure that this solution can help to integrate a YOLO model that can perform depth estimation.

Well, it’s because I’m trying to match the depth estimation model with the YOLO bounding boxes to determine which object is closest to the camera. I did it with depth anything on my PC but I want to implement it on a Raspberry IA Hat system with Hailo 8, so I´m seeking for a depth estimation model similar.