Skip to content

UnboundLocalError: local variable 'warped_img' referenced before assignment #7

@yddr

Description

@yddr

Hi, thanks for releasing your code and dataset.
I encounter this error on executing preprocess.py


Exception Handled:  'NoneType' object is not iterable
  0%|                                                                                                                                           |
 samples processed:   0%|
Traceback (most recent call last):
  File "preprocess.py", line 314, in <module>
    mean_face)
  File "preprocess.py", line 254, in process_samples
    del warped_img, landmarks, bbox, vid, stacked_frames, stacked_landmarks
UnboundLocalError: local variable 'warped_img' referenced before assignment

Error log is saying that 'warped_img' isn't assigned.
So I checked 'warped_img' and that Errorhandling code.

In 231 line, in preprocess_sample function,

with tqdm(total=num_frames) as pbar:
                for num_frame in range(num_frames):
                    try:
                        img_raw = vid.get_data(num_frame)
                    except IndexError as e:
                        print("Processing FAILED for sample: " + sample_id)
                        break
                    if img_raw.shape[1] >= MAX_IMAGE_WIDTH:
                        asp_ratio = img_raw.shape[0] / img_raw.shape[1]
                        dim = (MAX_IMAGE_WIDTH, int(MAX_IMAGE_WIDTH * asp_ratio))
                        new_img = cv2.resize(img_raw, dim, interpolation=cv2.INTER_AREA)
                        img = np.asarray(new_img)
                    else:
                        img = img_raw
                    try:
                        **_warped_img, landmarks, bbox = fp.process_image(img)_**
                        _, aligned_landmarks, _ = fp.process_image(warped_img)
                        good_frame_ids.append(num_frame)
                    except Exception as e:
                        print("Exception Handled: ", e)
                        continue

I think face detector can't find face , but I don't know why
If you give advice to me, I'm very appreciate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions