I'm starting to use google colab I'm I want to load a set of images for processing from my laptop.
I have tried this:
But I get the error:
TypeError: embedded NUL character
Which is then the right process to import the images?
Try this instead.
from io import BytesIO
uploaded = files.upload()
im = Image.open(BytesIO(uploaded['test.png']))
This is because the upload() command doesn't save the file. It stores the content in uploaded dictionary.
Or you can this use this function to upload files. It will both upload and save them.
def upload_files():
from google.colab import files
uploaded = files.upload()
for k, v in uploaded.items():
open(k, 'wb').write(v)
return list(uploaded.keys())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With