Hello,
I am working on a food classifier/detector which predicts if a picture is a hamburger or not. It seems to label everything as a hamburger. I have the following as my code:
!pip install -Uqq fastbook
import fastbook
fastbook.setup_book()
from fastai.vision.all import *
path=untar_data(URLs.FOOD)/'images'/'hamburger'
path.ls()
files=get_image_files(path)
len (files)
files[0]
files[100]
files[0].name
dls = ImageDataLoaders.from_folder(path, valid_pct=0.2,item_tfms=Resize(224))
dls.valid_ds.items[:3]
dls.show_batch()
learn = cnn_learner(dls, resnet34, metrics=error_rate)
learn.fine_tune(1)
learn.predict(files[0])
learn.show_results()
btn_upload = widgets.FileUpload()
btn_upload
img = PILImage.create(btn_upload.data[-1])
img.to_thumb(128,128)
is_burger,_,probs = learn.predict(img)
print(f"Is this a hamburger?: {is_burger}.")