imagenet_class_index.json 数据读取 renet导onnx

def imagenet_labels():
    ''' Return a list of imagenet_labels '''
    imagenet_labels = None
    imagenet_index = open('./imagenet_class_index.json')
    if imagenet_index:
        imagenet_labels = json.load(imagenet_index)
        imagenet_index.close()

    return imagenet_labels
#####
categories= imagenet_labels()
print(categories[str(top_k_onnx[0][0])][1],top_k_onnx)

def prepare_model_for_qnn(self):
        dummy_input = torch.randn(self.input_shape)
        print("Dowloading pretrained {model_name} model....".format(model_name = self.model_name))

        if self.model_name == "resnet34":
            self.pt_model = torchvision.models.resnet34(pretrained=True)
        if self.model_name == "resnet101":
            self.pt_model = torchvision.models.resnet101(pretrained=True)
        if self.model_name == "mobilenet":
            self.pt_model = torchvision.models.mobilenet_v2(pretrained=True)

        print("Done")

        print("Preparing onnx model for {}...".format(self.model_name))

        torch.onnx.export(self.pt_model.eval(),
                  dummy_input,
                  self.filename,
                  training=torch.onnx.TrainingMode.PRESERVE,
                  export_params=True,
                  do_constant_folding=False,
                  input_names=['input'],
                  output_names=['output'],
                  opset_version=16
                  )
        print("Done")

https://download.youkuaiyun.com/download/dannisklx/92404607?spm=1001.2014.3001.5501

以及 inception  

imagenet_slim_labels.txt

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值