Object does not appear to be a 8-bit string path or a Python file-like object
I'm not sure why you added the np.genfromtxt()
call. The following lines to create the in-memory file object are enough; these are the last lines in the view function, starting at your png_output
line:
png_output = io.BytesIO()canvas.print_png(png_output)response = make_response(png_output.getvalue())response.headers['Content-Type'] = 'image/png'return response
With those changes, the code produces a plot:
x_train=np.array(list(map(img_preprocess,x_train)))x_valid=np.array(list(map(img_preprocess,x_valid)))
bit shows object-does-not-appear-to-be-a-8-bit-string-path-or-a-python-file-like-object
This Error is because Here you already changed shape of x_train
by executing x_train=np.array(list(map(img_preprocess,x_train)))
this line, so x_train
is updated now and again if you will give x_train as input to the x_train=np.array(list(map(img_preprocess,x_train)))
function then it will give this error
solution: reset your python kernel and run all code in sequence again.
x_train=np.array(list(map(img_preprocess,x_train)))x_valid=np.array(list(map(img_preprocess,x_valid)))bit shows object-does-not-appear-to-be-a-8-bit-string-path-or-a-python-file-like-object
Whats's the problem behind it?