hysts / anime-face-detector

Anime Face Detector using mmdet and mmpose
MIT License
416 stars 24 forks source link

colab notebook encounters problem while installing dependencies #7

Closed zhongzishi closed 2 years ago

zhongzishi commented 2 years ago

Hi, the colab notebook looks broken. I used it about 2 weeks ago with out any problem. Basically in dependcie installing phase, when executing "mim install mmcv-full", colab will ask if I want to use an older version to replace pre-installed newer version. I had to choose to install older version to make the detector works.

I retried the colab notebook yesterday, this time if I still chose to replace preinstalled v1.5.0 by v.1.4.2, it will stuck at "building wheel for mmcv-full" for 20 mins and fail. If I chose not to replace preinstalled version and skip mmcv-full, the dependcie installing phase could be completed without error. But when I ran the detector, I got an error "KeyError: 'center'"

Please help.

KeyError                                  Traceback (most recent call last)
[<ipython-input-8-2cb6d21c10b9>](https://localhost:8080/#) in <module>()
     12 image = cv2.imread(input)
     13 
---> 14 preds = detector(image)

6 frames
[/content/anime-face-detector/anime_face_detector/detector.py](https://localhost:8080/#) in __call__(self, image_or_path, boxes)
    145                 boxes = [np.array([0, 0, w - 1, h - 1, 1])]
    146         box_list = [{'bbox': box} for box in boxes]
--> 147         return self._detect_landmarks(image, box_list)

[/content/anime-face-detector/anime_face_detector/detector.py](https://localhost:8080/#) in _detect_landmarks(self, image, boxes)
    101             format='xyxy',
    102             dataset_info=self.dataset_info,
--> 103             return_heatmap=False)
    104         return preds
    105 

[/usr/local/lib/python3.7/dist-packages/mmcv/utils/misc.py](https://localhost:8080/#) in new_func(*args, **kwargs)
    338 
    339             # apply converted arguments to the decorated method
--> 340             output = old_func(*args, **kwargs)
    341             return output
    342 

[/usr/local/lib/python3.7/dist-packages/mmpose/apis/inference.py](https://localhost:8080/#) in inference_top_down_pose_model(model, imgs_or_paths, person_results, bbox_thr, format, dataset, dataset_info, return_heatmap, outputs)
    385             dataset_info=dataset_info,
    386             return_heatmap=return_heatmap,
--> 387             use_multi_frames=use_multi_frames)
    388 
    389         if return_heatmap:

[/usr/local/lib/python3.7/dist-packages/mmpose/apis/inference.py](https://localhost:8080/#) in _inference_single_pose_model(model, imgs_or_paths, bboxes, dataset, dataset_info, return_heatmap, use_multi_frames)
    245                 data['image_file'] = imgs_or_paths
    246 
--> 247         data = test_pipeline(data)
    248         batch_data.append(data)
    249 

[/usr/local/lib/python3.7/dist-packages/mmpose/datasets/pipelines/shared_transform.py](https://localhost:8080/#) in __call__(self, data)
    105         """
    106         for t in self.transforms:
--> 107             data = t(data)
    108             if data is None:
    109                 return None

[/usr/local/lib/python3.7/dist-packages/mmpose/datasets/pipelines/top_down_transform.py](https://localhost:8080/#) in __call__(self, results)
    287         joints_3d = results['joints_3d']
    288         joints_3d_visible = results['joints_3d_visible']
--> 289         c = results['center']
    290         s = results['scale']
    291         r = results['rotation']

KeyError: 'center'
zhongzishi commented 2 years ago

After multiple retries of installing depencies, finally I manged to make it work again :)

Several points here:

1, mmcv-full, the best way to install it on Colab is via pip, but need to follow their official installation documentation, since colab has CUDA11.3 and torch 1.11 pre-installed, the mmcv-full installation should be done in this way:

pip install mmcv-full=={mmcv_version} -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.11.0/index.html

Otherwise, the building always fails.

2, 'KeyError center' issue comes from incompatibility with the latest version (0.26) of mmpose, installing 0.25.1 fixes it.

hysts commented 2 years ago

Hi, @zhongzishi Thank you for the info! I fixed the notebook.