DeepLabCut / DeepLabCut

Official implementation of DeepLabCut: Markerless pose estimation of user-defined features with deep learning for all animals incl. humans
http://deeplabcut.org
GNU Lesser General Public License v3.0
4.7k stars 1.67k forks source link

Inferencing images with SuperAnimal #2789

Closed jesstytam closed 1 week ago

jesstytam commented 1 week ago

Hi, I've read the docs but couldn't find anything on inferencing on images instead of videos. Just wondering if anyone has any pointers? I'd like to get SuperAnimal running, but it seems like SuperAnimal hasn't been properly implemented yet?

As an example, I tried running the example code from the notebook DeepLabCut/examples/testscript_superanimal_inference.py and the docs as follows:

video_path = 'demo-video.mp4'
superanimal_name = 'superanimal_quadruped_hrnetw32'

deeplabcut.video_inference_superanimal([video],
                                        superanimal_name,
                                        model_name='resnet_50',
                                        video_adapt = True)

However, all returned this error:

ValueError: modelname=superanimal_quadruped_None should be one of: full_human, full_cat, full_dog, primate_face, mouse_pupil_vclose, horse_sideview, full_macaque, superanimal_topviewmouse_dlcrnet, superanimal_quadruped_dlcrnet, superanimal_topviewmouse_hrnetw32, superanimal_quadruped_hrnetw32, superanimal_topviewmouse, superanimal_quadruped, superanimal_bird_fasterrcnn_mobilenet_v3_large_fpn, superanimal_bird_ssdlite, superanimal_bird_resnet_50, superanimal_topviewmouse_fasterrcnn_mobilenet_v3_large_fpn, superanimal_topviewmouse_fasterrcnn_resnet50_fpn_v2, superanimal_topviewmouse_hrnet_w32, superanimal_topviewmouse_resnet_50, superanimal_quadruped_fasterrcnn_mobilenet_v3_large_fpn, superanimal_quadruped_fasterrcnn_resnet50_fpn_v2, superanimal_quadruped_hrnet_w32, superanimal_quadruped_resnet_50.

I tried adding modelname as a parameter but it seems like it is not actually a parameter?

Either way, ideally I'd like to know if it is possible to use the models on some camera trap images that I have. Thanks!

n-poulsen commented 1 week ago

Hi @jesstytam! There are methods to run inference on images using SuperAnimal models! There's a good amount of documentation about that in the COLAB_YOURDATA_SuperAnimal.ipynb notebook (look for the superanimal_analyze_images method). With the latest RC release (version 3.0.0rc6), that would be:

from deeplabcut.pose_estimation_pytorch.apis import superanimal_analyze_images

image_folder = ["path/to/a/folder/containing/images"]
superanimal_name = "superanimal_quadruped"
model_name = "hrnet_w32"
detector_name = "fasterrcnn_mobilenet_v3_large_fpn"

superanimal_analyze_images(
    superanimal_name,
    model_name,
    detector_name,
    image_folder,
    max_individuals=10,
    output_folder="outputs/",
)