How do I use a pretrained model to predict an image? ==================================================== .. code-block:: python from deepforest import main from deepforest import get_data from deepforest.visualize import plot_results # Initialize the model class model = main.deepforest() # Load a pretrained tree detection model from Hugging Face model.load_model(model_name="weecology/deepforest-tree", revision="main") sample_image_path = get_data("OSBS_029.png") img = model.predict_image(path=sample_image_path) plot_results(img) .. image:: ../../../www/getting_started1.png :align: center .. note:: **Please note that this video was made before the deepforest-pytorch -> deepforest name change.** .. raw:: html
For single images, ``predict_image`` can read an image from memory or file and return predicted bounding boxes.