LibTorch,使用deeplab模型提供转发时的段错误

时间:2019-07-09 12:35:52

标签: pytorch image-segmentation semantic-segmentation deeplab libtorch

我正在尝试通过Libtorch中的DeepLab模型运行图像以对其进行分割。使用pytorch,我正在像这样转换Deeplabv3模型:

{name:'Belmont Race', address:{ state:'TN' }}

现在,在带有LibTorch的c ++中,我正在尝试加载模型并通过它运行数据。但是,这失败了:

import torch
import torchvision
from torchvision import models

deeplap_model = models.segmentation.deeplabv3_resnet101(pretrained=True)
deeplap_model.eval()

class wrapper(torch.nn.Module):
    def __init__(self, model):
        super(wrapper, self).__init__()
        self.model = model

    def forward(self, input):
        results = []
        output = self.model(input)
        for k, v in output.items():
            results.append(v)
        return tuple(results)

model = wrapper(deeplap_model)

example = torch.rand(1, 3, 224, 224)
# Use torch.jit.trace to generate a torch.jit.ScriptModule via tracing.
traced_script_module = torch.jit.trace(model, example)

traced_script_module.save("model.pt")

我在哪里错了?

0 个答案:

没有答案