Inference yolov5 with RedisAI

I am trying to make an inference on a custom yolo model using RedisAI.

With the following code I am getting errors;

for .pt

redis.exceptions.ResponseError: PytorchStreamReader failed locating file constants.pkl: file not found Exception raised from valid at ../caffe2/serialize/inline_container.cc:158 (most recent call first): frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) + 0x6b (0x7f02fbb747ab in /home/robb/Desktop/nn/RedisAI/deps/linux-x64-cpu/libtorch/lib/libc10.so) frame #1: c10::detail::torchCheckFail(char const*, char const*, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) + 0xce (0x7f02fbb7015e in /home/robb/Desktop/nn/RedisAI/deps/linux-x64-cpu/libtorch/lib/libc10.so) frame #2: ...

for .torchscript

redis.exceptions.ResponseError: isTuple()INTERNAL ASSERT FAILED at "../aten/src/ATen/core/ivalue_inl.h":1916, please report a bug to PyTorch. Expected Tuple but got String Exception raised from toTupleRef at ../aten/src/ATen/core/ivalue_inl.h:1916 (most recent call first): frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) + 0x6b (0x7f02fbb747ab in /home/robb/Desktop/nn/RedisAI/deps/linux-x64-cpu/libtorch/lib/libc10.so) frame #1: ...

for .onnx

redis.exceptions.ResponseError: PytorchStreamReader failed reading zip archive: failed finding central directory Exception raised from valid at ../caffe2/serialize/inline_container.cc:158 (most recent call first): frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) + 0x6b (0x7f02fbb747ab in /home/robb/Desktop/nn/RedisAI/deps/linux-x64-cpu/libtorch/lib/libc10.so) frame #1: c10::detail::torchCheckFail(char const*, char const*, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) + 0xce (0x7f02fbb7015e in /home/robb/Desktop/nn/RedisAI/deps/linux-x64-cpu/libtorch/lib/libc10.so) frame #2: ...

The code:

from redisai import Client as rai
import numpy as np
import cv2

model_path = 'yolov5/runs/train/results_15/weights/best.pt'

# Connect to Redis
redis_client = rai(host='localhost', port=6379)

img = '/home/robb/Desktop/nn/YOLOv5_cars/yolov5/data/images/bus.jpg'
img = cv2.imread(img)


with open(model_path, 'rb') as f:
    model = f.read()


redis_client.modelstore('willitwork', 'torch', 'CPU', model)

redis_client.tensorset('my_tensor', img)

redis_client.modelexecute('willitwork', ['my_tensor'], ['output'])

output_tensor = redis_client.tensorget('output')
output_data = np.array(output_tensor)