yolov7 icon indicating copy to clipboard operation
yolov7 copied to clipboard

kpt, yolov7-w6-pose.pt, Can't call numpy() on Tensor that requires grad. Use tensor.detach().numpy() instead.

Open xinsuinizhuan opened this issue 1 year ago • 11 comments

Traceback (most recent call last): File "E:\Item\Item_done\yolo\yolo5\yolov7\yolov7-main\pose.py", line 27, in output = output_to_keypoint(output) File "E:\Item\Item_done\yolo\yolo5\yolov7\yolov7-main\utils\plots.py", line 443, in output_to_keypoint targets.append([i, cls, *list(*xyxy2xywh(np.array(box)[None])), conf, *list(kpts.cpu().numpy()[index])]) RuntimeError: Can't call numpy() on Tensor that requires grad. Use tensor.detach().numpy() instead.

图片

xinsuinizhuan avatar Jul 27 '22 03:07 xinsuinizhuan

kpts.cpu().numpy() -> kpts.detach().cpu().numpy()

WongKinYiu avatar Jul 27 '22 11:07 WongKinYiu

I added PR #333 to solve this problem.

mkhoshbin72 avatar Jul 27 '22 21:07 mkhoshbin72

I added PR #333 to solve this problem.

how to export the to onnx?

xinsuinizhuan avatar Jul 28 '22 08:07 xinsuinizhuan

use export.py

mkhoshbin72 avatar Jul 28 '22 21:07 mkhoshbin72

use export.py

no, i export it, but the onnx model not right: 图片 how to export it as: 图片

xinsuinizhuan avatar Jul 29 '22 07:07 xinsuinizhuan

Do you use the latest YOLOv7 code? Take a look at #319

mkhoshbin72 avatar Jul 29 '22 08:07 mkhoshbin72

Do you use the latest YOLOv7 code? Take a look at #319

Yes。The latest yolov7 code.But it was the yolov7-w6-pose.pt model.

xinsuinizhuan avatar Jul 30 '22 00:07 xinsuinizhuan

Do you use the latest YOLOv7 code? Take a look at #319

when i use: python3 export.py --weights best.pt --grid --end2end --simplify --topk-all 100 --iou-thres 0.65 --img-size 1280 1280 --conf-thres 0.35 --max-wh 1280 error: 图片

xinsuinizhuan avatar Jul 30 '22 00:07 xinsuinizhuan

when i export the tiny model with nms, but the output have no nms: exported with command: python export.py --weights yolov7-tiny.pt --grid --end2end --simplify --topk-all 100 --iou-thres 0.65 --conf-thres 0.35 --img-size 640 640 --max-wh 640

图片

it shoud be nms result, as const char *OUTPUT_COUNTS = "count"; const char *OUTPUT_BOXES = "box"; const char *OUTPUT_SCORES = "score"; const char *OUTPUT_CLASSES = "class";

xinsuinizhuan avatar Jul 30 '22 00:07 xinsuinizhuan

It's OK. Output of onnx model has shape of (number_of_detections, 7). Second part consists of (batch_id,x0,y0,x1,y1,cls_id,score)

mkhoshbin72 avatar Jul 30 '22 14:07 mkhoshbin72

It's OK. Output of onnx model has shape of (number_of_detections, 7). Second part consists of (batch_id,x0,y0,x1,y1,cls_id,score)

OK。Thank you very much.

xinsuinizhuan avatar Aug 01 '22 00:08 xinsuinizhuan