yolov5のモデルをstreamlitを使用したpythonファイル内で使用したいのですが、エラーとなってしまいます。

streamlitで画像ファイルを読み込み、yolov5でdetectした画像を描画するという簡単なアプリを作成したいのですが、
なぜかyolov5を使用する段階でエラーが生じてしまいます。
具体的には以下のようなコードを書いています。

App.py

model = torch.hub.load('ultralytics/yolov5', 'yolov5s') img = cv2.imread('画像ファイルのパス') result = model(img)

App.pyと同階層に作成したpythonファイルに同様の記述をすると問題なく実行されるため、streamlitとの併用によるエラーであると思います。

streamlitでは以下のようなエラーメッセージとなっています。

TypeError: conv2d() received an invalid combination of arguments - got (numpy.ndarray, Parameter, NoneType, tuple, tuple, tuple, int), but expected one of: * (Tensor input, Tensor weight, Tensor bias, tuple of ints stride, tuple of ints padding, tuple of ints dilation, int groups) didn't match because some of the arguments have invalid types: ([31;1mnumpy.ndarray[0m, [31;1mParameter[0m, [31;1mNoneType[0m, [31;1mtuple[0m, [31;1mtuple[0m, [31;1mtuple[0m, [32;1mint[0m) * (Tensor input, Tensor weight, Tensor bias, tuple of ints stride, str padding, tuple of ints dilation, int groups) didn't match because some of the arguments have invalid types: ([31;1mnumpy.ndarray[0m, [31;1mParameter[0m, [31;1mNoneType[0m, [31;1mtuple[0m, [31;1mtuple[0m, [31;1mtuple[0m, [32;1mint[0m)

どなたかわかるからいらっしゃいましたら、教えていただけると嬉しいです。

よろしくお願いします。

コメントを投稿

0 コメント