erik Thank you for your reply. I checked the datatype, but it is ok. I want to make the MRE but i can't do that because of policy of my company. however, i can share baseline model.
https://github.com/linklist2/PIAFusion_pytorch
https://github.com/linklist2/PIAFusion_pytorch/blob/master/pretrained/best_cls.pth
This repo is baseline. In partialy, i use illumination aware network. so you can download pretrained weight based on pytorch from this repo. Then i convert Torch into onnx using this code.
# -*- coding: utf-8 -*-
import argparse
import os
import random
import numpy as np
import torch
import onnx
import numpy
from onnxsim import simplify
from torch import optim
from models.cls_model import Illumination_classifier
import blobconverter
def convert_onnx(model, output, opset=12) :
shape = (1, 3, 640, 512)
img = torch.ones(shape, dtype=torch.float32).cuda()
torch.onnx.export(
model,
img,
output,
do_constant_folding=True,
)
onnx_model = onnx.load(output)
onnx_model, check = simplify(onnx_model)
# assert check, "Simplified ONNX model could not be validated"
onnx.save(onnx_model, output)
if __name__ == '__main__':
model = Illumination_classifier(input_channels=3)
weight = torch.load("./best_cls.pth")
model.load_state_dict(weight)
model = model.cuda()
model.eval()
convert_onnx(model, "./onnx_file/best.onnx", opset=9)
After that i covert onnx into blob. But as i mentioned, I got different result.
Could you check this problem..?
In addition, How can i change the inference part on depthai..?
i mean when i use this code, then i got same result. so if i can do that, i want to change inference code.
import cv2
import numpy as np
from openvino.inference_engine import IECore
shape = (512, 640)
ie = IECore()
exec_net = ie.import_network("best.blob",device_name='MYRIAD')
input_blob = next(iter(exec_net.input_info))
# Get video from the computers webcam
cam = cv2.VideoCapture(0)
cam.set(cv2.CAP_PROP_FPS, 30)
while True:
ret, raw_image = cam.read()
if not ret:
continue
image = cv2.resize(raw_image, shape)
cv2.imshow('USB Camera', image)
image = np.expand_dims(image, axis=0)
image = image.transpose((0, 3, 1, 2))
# Do the inference on the MYRIAD device
output = exec_net.infer(inputs={input_blob: image}) # blob
print(output)
if cv2.waitKey(1) == ord('q'):
break
Thank you..