yolo3-pytorch icon indicating copy to clipboard operation
yolo3-pytorch copied to clipboard

使用pth模型转换成pt格式的问题

Open TTgogogo opened this issue 3 years ago • 3 comments

想将模型转换为pt格式后,在libtorch中调用,但不成功: import torch from nets.yolo import YoloBody from utils.utils import get_classes

classes_path = 'model_data/voc_classes.txt' class_names, num_classes = get_classes(classes_path)

model = YoloBody(num_classes)

model_path = 'logs/last_epoch_weights.pth' device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') model.load_state_dict(torch.load(model_path, map_location=device))

example = torch.rand(1, 3, 640, 640) model.eval() output = torch.jit.trace(model, example) torch.jit.save(output, "yolo.pt")

是我的方法有问题吗?

TTgogogo avatar Jul 13 '22 02:07 TTgogogo

能把pth权重文件换成weights格式吗,在dartnet53上跑

dengxiongshi avatar Jul 13 '22 09:07 dengxiongshi

这个应该可以成功保存下来的吧?

bubbliiiing avatar Jul 17 '22 12:07 bubbliiiing

能把pth权重文件换成weights格式吗,在dartnet53上跑

没有这个兼容,没有反向去再用C++,一般直接用那个直接训练了

bubbliiiing avatar Jul 17 '22 12:07 bubbliiiing