私は画像処理クラシファイアをビルドしました。このコードでは、入力画像フォームキー 'test_image'を取って画像のクラスを予測するAPIを作成しています。 cv2.imread()
は、私はcv2.imread
は画像のURLのみを取りますが、私はこれを解決する方法を知らないことを知っている私は、このエラーTypeIrror at/image /期待される文字列またはUnicodeオブジェクト、InMemoryUploadedFileが見つかりました
TypeError at /image/ expected string or Unicode object, InMemoryUploadedFile found
を与えています。
マイコード:
def classify_image(request):
if request.method == 'POST' and request.FILES['test_image']:
test_image = request.FILES['test_image']
test_image = cv2.imread(test_image)
test_image = cv2.resize(test_image, (128, 128))
test_image = np.array(test_image)
test_image = test_image.astype('float32')
test_image /= 255
print(test_image.shape)
test_image = np.expand_dims(test_image, axis=0)
pred = model.predict_classes(test_image)
print(pred)
return JsonResponse(pred, safe=False)
このエラーが発生します(TypeError:必須引数 'flags'(pos 2)が見つかりません) –
https://stackoverflow.com/questions/47295025/valueerror-at-image-tensor-tensoractivation-5-softmax0- shape-4-dtyp/47300005?noredirect = 1#comment81555441_47300005すべてのsuggesions –