A model zoo for to download and load pretrained models.

Model Zoo

MODELS is a dictionary that maps model names to a url of the tarred model. get_model allows you to easily download a pretrained model (if it hasn't been downloaded already), from the MODELS dict. Then you can easily use it for inference by just passing in the path to an image file! :)

Here's a list of the names of the pretrained models that you can pass to get_model.

list(MODELS.keys())
['resnet18_2021-04-08']

get_model[source]

get_model(model)

Return the model maybe wrapped inside model.

Prediction Wrapper

predict_leaf is a simple wrapper over Learner's predict that decodes the class probabilities for the user.

Learner.predict_leaf[source]

Learner.predict_leaf(image, decimals:int=2)

Predict on image and return predicted class and decoded probabilities.

Rounds probabilities to decimals decimal places.

model = get_model("resnet18_2021-04-08")
prediction = model.predict_leaf("../nbks/images/leaf.jpg")
prediction
{'predicted_class': 'rust',
 'probabilities': {'healthy': 0.05,
  'multiple_diseases': 0.04,
  'rust': 0.88,
  'scab': 0.03}}