Ich habe einen Bildverarbeitungs-Klassifikator erstellt und In diesem Code mache ich eine API, die das Eingabebild Formularschlüssel 'test_image' und sagt die Klasse des Bildes aber cv2.imread()
gibt mir diesen FehlerTypeError at/Bild/erwartete Zeichenfolge oder Unicode-Objekt, InMemoryUploadedFile gefunden
TypeError at /image/ expected string or Unicode object, InMemoryUploadedFile found
ich weiß, dass cv2.imread
nur uRL des Bildes nimmt, aber ich weiß nicht, wie dieses Problem zu beheben.
Mein Code:
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)
es gibt mir diesen Fehler (TypeError: Erforderliches Argument 'Flags' (Pos 2) nicht gefunden) –
https://StackOverflow.com/Questions/47295025/valueerror-at-image-tens-tensoractivation-5-softmax0- shape-4-dtyp/47300005? noredirect = 1 # comment81555441_47300005 irgendwelche Vorschläge –