AlphaPose
AlphaPose copied to clipboard
mportError: cannot import name 'nms_cpu' from partially initialized module 'detector.nms' (most likely due to a circular import) (/home/u1218800/Downloads/AlphaPose-master/detector/nms/__init__.py)
Running in cpu set up by following installation set up. Tried with/without commenting the mentioned line in setup.py In both the cases, the error is same.
File "/home/u1218800/Downloads/AlphaPose-master/detector/nms/nms_wrapper.py", line 4, in
mportError: cannot import name 'nms_cpu' from partially initialized module 'detector.nms' (most likely due to a circular import) (/home/u1218800/Downloads/AlphaPose-master/detector/nms/init.py)
Hi, what command are you running?
Hello, @Fang-Haoshu I'm joining this issue, I run the following command: ython3 scripts/demo_inference.py --cfg configs/coco/resnet/256x192_res50_lr1e-3_1x.yaml --checkpoint pretrained_models/simple_res50_256x192.pth --video uw_video.mp4 --outdir output_directory/ --gpus -1
I get the following error:
2023-10-09 06:25:14 [DEBUG]: Loaded backend agg version v2.2.
/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.10/site-packages/torch/cuda/init.py:546: UserWarning: Can't initialize NVML
warnings.warn("Can't initialize NVML")
Traceback (most recent call last):
File "/home/ec2-user/SageMaker/data-science/AlphaPose/scripts/demo_inference.py", line 178, in
I read somewhere that if I replace in nms_wrapper.py this: from . import nms_cpu, nms_cuda from .soft_nms_cpu import soft_nms_cpu By: from . import * It solves this "circular import" issue, but instead, it gives the next following error:
(Keep in mind the in I have the src folder inside nms, that contains the following files: nms_cpu.cpp, nms_cuda.cpp, nms_kernel.cu, soft_nms_cpu.cpp, soft_nms_cpu.pyx). So the names nms_cpu, nms_cuda and soft_nms_cpu are the names of the three .cpp files inside the src folder)
2023-10-09 06:29:35 [DEBUG]: Loaded backend agg version v2.2.
/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.10/site-packages/torch/cuda/init.py:546: UserWarning: Can't initialize NVML
warnings.warn("Can't initialize NVML")
/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.10/site-packages/torchvision/models/_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and may be removed in the future, please use 'weights' instead.
warnings.warn(
/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.10/site-packages/torchvision/models/_utils.py:223: UserWarning: Arguments other than a weight enum or None
for 'weights' are deprecated since 0.13 and may be removed in the future. The current behavior is equivalent to passing weights=ResNet50_Weights.IMAGENET1K_V1
. You can also use weights=ResNet50_Weights.DEFAULT
to get the most up-to-date weights.
warnings.warn(msg)
2023-10-09 06:29:39 [DEBUG]: Loaded backend agg version v2.2.
2023-10-09 06:29:39 [DEBUG]: Loaded backend agg version v2.2.
2023-10-09 06:29:39 [DEBUG]: Loaded backend agg version v2.2.
Loading pose model from pretrained_models/simple_res50_256x192.pth...
/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.10/site-packages/torch/cuda/init.py:546: UserWarning: Can't initialize NVML
warnings.warn("Can't initialize NVML")
/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.10/site-packages/torch/cuda/init.py:546: UserWarning: Can't initialize NVML
warnings.warn("Can't initialize NVML")
/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.10/site-packages/torch/cuda/init.py:546: UserWarning: Can't initialize NVML
warnings.warn("Can't initialize NVML")
0%| | 0/74133 [00:00<?, ?it/s]Loading YOLO model..
2023-10-09 06:29:44 [DEBUG]: Loaded backend agg version v2.2.
/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.10/site-packages/torch/cuda/init.py:546: UserWarning: Can't initialize NVML
warnings.warn("Can't initialize NVML")
is_numpy is: False
dets type is: <class 'torch.Tensor'>
dets_th type is: <class 'torch.Tensor'>
Process Process-2:
Traceback (most recent call last):
File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.10/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/home/ec2-user/SageMaker/data-science/AlphaPose/alphapose/utils/detector.py", line 243, in image_detection
dets = self.detector.images_detection(imgs, im_dim_list)
File "/home/ec2-user/SageMaker/data-science/AlphaPose/detector/yolo_api.py", line 96, in images_detection
dets = self.dynamic_write_results(prediction, self.confidence,
File "/home/ec2-user/SageMaker/data-science/AlphaPose/detector/yolo_api.py", line 116, in dynamic_write_results
dets = self.write_results(prediction.clone(), confidence, num_classes, nms, nms_conf)
File "/home/ec2-user/SageMaker/data-science/AlphaPose/detector/yolo_api.py", line 199, in write_results
_, inds = nms_op(image_pred_class[:,:5], nms_conf)
File "/home/ec2-user/SageMaker/data-science/AlphaPose/detector/nms/nms_wrapper.py", line 66, in nms
inds = nms_cpu.nms(dets_th, iou_thr)
NameError: name 'nms_cpu' is not defined
In summary, I'm trying to use the demo_inference.py script with a sample of a 5 seconds video, WITHOUT NIVIDIA/CUDA, only CPU use (as mentioned by the --gpus -1 argument). When I replace both lines by "from . import *" it doesn't even recognise the nms_cpu argument. As I understand I can use AlphaPose WITHOUT GPU's. If someone can help me resolve this issue it would be amazing! Thank you!
Any update on this ?
Anyone solved this problem?