-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
I had an issue with the urllib.request.urlretrieve function. It downloaded the sample-cat.jpg file without error messages but stored it as a corrupted file.
I borrowed the requests.get() code from one of the blocks below to make it work.
# Download the image by using its url and filename
# One of several methods to donwload an image
# create directory that is visible from browser
try:
os.makedirs("/kaggle/working/inferenceImages/")
except:
print("directory already exists")
os.chdir("/kaggle/working/inferenceImages/")
# Upload the image
image_object = requests.get(image_url).content
with open(image_filename, 'wb') as handler:
handler.write(image_object)
#image_data = PILImage.create(image_filename)
Note that I changed the working directory to make the files visible in the browser
Note that it's not essential to generate the variable image_data , the model will also accept the jpg file name under image_filename . But this may be different for other datatypes, perhaps
The model can now be called by prediction_label, p, probabilities = image_learner.predict(image_filename)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels