1.加载模型
seg_model = torchvision.models.detection.maskrcnn_resnet50_fpn(pretrained=True)
seg_model = seg_model.cuda(1)
seg_model = seg_model.eval()
2.将图像封装为tensor:
torchvision.transforms.functional.to_tensor(img_pil).cuda() # cuda之后可以指定ID
3.从模型取出结果:
cond_person = output["labels"].cpu().detach().numpy()
Pytorch 入门
最新推荐文章于 2024-04-29 00:14:59 发布