Closed HoangTienDuc closed 1 year ago
This current version of DeepStream-Yolo doesn't work on DeepStream 5.1
Are you using the export_yoloV7.py
from util
folder?
Yes. I follow your documentation
Can you send your pytorch model to my email for testing?
Hi @marcoslucianops , Thank for your reply. The .pt model was sent to your email marcoslucianops@gmail.com
I think you are using the wrong export file. Here the export and engine build worked normally.
Hi @marcoslucianops, I really appreciate your help. The onnx models and these evns were sent to you.
from copy import deepcopy
from models.yolo import Model
import torch
from utils.torch_utils import select_device, is_parallel
import yaml
device = select_device('0', batch_size=1)
ckpt = torch.load('yolov7.pt', map_location=device)
model = Model('cfg/deploy/yolov7.yaml', ch=3, nc=5).to(device)
with open('cfg/deploy/yolov7.yaml') as f: yml = yaml.load(f, Loader=yaml.SafeLoader) anchors = len(yml['anchors'][0]) // 2
state_dict = ckpt['model'].float().state_dict() exclude = [] intersect_state_dict = {k: v for k, v in state_dict.items() if k in model.state_dict() and not any(x in k for x in exclude) and v.shape == model.state_dict()[k].shape} model.load_state_dict(intersect_state_dict, strict=False) model.names = ckpt['model'].names model.nc = ckpt['model'].nc
for i in range((model.nc+5)anchors): model.state_dict()['model.105.m.0.weight'].data[i, :, :, :] = state_dict['model.105.im.0.implicit'].data[:, i, : :].squeeze() model.state_dict()['model.105.m.1.weight'].data[i, :, :, :] = state_dict['model.105.im.1.implicit'].data[:, i, : :].squeeze() model.state_dict()['model.105.m.2.weight'].data[i, :, :, :] = state_dict['model.105.im.2.implicit'].data[:, i, : :].squeeze() model.state_dict()['model.105.m.0.bias'].data += state_dict['model.105.m.0.weight'].mul(state_dict['model.105.ia.0.implicit']).sum(1).squeeze() model.state_dict()['model.105.m.1.bias'].data += state_dict['model.105.m.1.weight'].mul(state_dict['model.105.ia.1.implicit']).sum(1).squeeze() model.state_dict()['model.105.m.2.bias'].data += state_dict['model.105.m.2.weight'].mul(state_dict['model.105.ia.2.implicit']).sum(1).squeeze() model.state_dict()['model.105.m.0.bias'].data = state_dict['model.105.im.0.implicit'].data.squeeze() model.state_dict()['model.105.m.1.bias'].data = state_dict['model.105.im.1.implicit'].data.squeeze() model.state_dict()['model.105.m.2.bias'].data *= state_dict['model.105.im.2.implicit'].data.squeeze()
ckpt = {'model': deepcopy(model.module if is_parallel(model) else model).half(), 'optimizer': None, 'training_results': None, 'epoch': -1}
torch.save(ckpt, 'yolov7_reparameter.pt')
2. I convert the re-parameter .pt model to onnx using export_yoloV7.py
Thank @marcoslucianops so much, solved this problem
• Hardware Platform (Jetson / GPU) Both • DeepStream Version [5.1 on GPU and 6.2 on jetson] • JetPack Version (valid for Jetson only) 5.1
Hi @marcoslucianops, thank you for your great work. After re-parameter my yolov7 onnx model, I tried to run it on ds However, I got the bellow error. Pls help me to check it.