VTuber_Unity icon indicating copy to clipboard operation
VTuber_Unity copied to clipboard

UnboundLocalError: local variable 'steady_pose' referenced before assignment

Open yubaoliu opened this issue 4 years ago • 2 comments

Hello, I see this error when I test demo.py:

python demo.py --debug
Downloading the face detection CNN. Please wait...
Downloading the Face Alignment Network(FAN). Please wait...
Traceback (most recent call last):
  File "demo.py", line 219, in <module>
    main()
  File "demo.py", line 154, in main
    roll = np.clip(-(180+np.degrees(steady_pose[2])), -50, 50)
UnboundLocalError: local variable 'steady_pose' referenced before assignment

Thanks

yubaoliu avatar Mar 17 '21 07:03 yubaoliu

Same issue

GuaiYiHu avatar Apr 18 '21 12:04 GuaiYiHu

Fixed

        pose+= [(ll+rl)/2.0, (lu+ru)/2.0]
        steady_pose = []

        if error > 100: # large error means tracking fails: reinitialize pose estimator
                        # at the same time, keep sending the same information (e.g. same roll)
            pose_estimator = PoseEstimator(img_size=sample_frame.shape[:2])

        else:
            # Stabilize the pose.
            steady_pose.clear()
            pose_np = np.array(pose).flatten()
            for value, ps_stb in zip(pose_np, pose_stabilizers):
                ps_stb.update([value])
                steady_pose.append(ps_stb.state[0])
        
        if len(steady_pose) == 0:
            continue

        roll = np.clip(-(180+np.degrees(steady_pose[2])), -50, 50)
        pitch = np.clip(-(np.degrees(steady_pose[1]))-15, -40, 40) # the 15 here is my camera angle.
        yaw = np.clip(-(np.degrees(steady_pose[0])), -50, 50)
        min_ear = min(eye_aspect_ratio(marks[36:42]), eye_aspect_ratio(marks[42:48]))
        mar = mouth_aspect_ration(marks[60:68])
        mdst = mouth_distance(marks[60:68])/(facebox[2]-facebox[0])

GuaiYiHu avatar Apr 18 '21 12:04 GuaiYiHu