joergmlpts / nature-id

Identify plants, birds, and insects in photos. Should an identification to species be unsuccessful, an identification to a higher taxonomic level - like genus, family, or order - is made.
MIT License
37 stars 5 forks source link

Nature-id model identifying food dishes, not plant or insect species #1

Closed hzmann closed 2 months ago

hzmann commented 3 months ago

Hi! I am finding that this model identifies food dishes rather than plant and insect species. I have followed the instructions for downloading the classifiers: "Each classifier consists of a .tflite model and a .csv labelmap file. Both are required. On each of the above websites scroll down and under Output click on labelmap to download the labels. Then scroll back up and under Model formats switch to TFLite (aiyvision/classifier/...). There click on Download to get the .tflite file."

First, I scrolled down to Model Variations and switched to the TensorFlow Lite tab. Then I downloaded each as a tar.gz zip file. When I download the plant classifier, the only file to be extracted was 3.tflite. When I downloaded the insect classifier, that same 3.tflite file was also the only file to be extracted. Therefore, I only have one 3.tflite file in the classifiers directory. Then, for each classifier page, I scrolled up to Model Details at the top of the page, found the only Output section on the page, and selected the only labelmap file to download. For the plant and insect classifiers, this labelmap downloads as "aiy_food_V1_labelmap" and aiy_food_V1_labelmap (1)" respectively. They are the same .csv file, which is just a massive list of food dishes. Therefore, when I had all the images downloaded and ran the model with the example command you provided of: python .\nature_id.py -m plants plant_images\Persicaria_amphibia.jpg, it returned:

Classification of 'plant_images\Persicaria_amphibia.jpg' took 2.1 secs. 97.6% Char kway teow 0.8% Caprese salad 0.4% Squab 0.4% Rassolnik 0.4% Minchee.

As you can see these are all food dishes. Did the files provided on the download page get mixed up? If so, can you please investigate the page and restore the correct files?

Thank you for your time and for helping me run this model correctly.

joergmlpts commented 3 months ago

Hi, I see what you mean, the webpage to download models has changed. The link to the Google models is now being redirected to kaggle.com. It says about the model "this model is trained to recognize 2023 food dishes from images". The models to identify birds, insects, and plants are listed below as variants.

I just gave it a try and managed to download models but could not figure out how to download label files. You had more success since you downloaded both a model and the label file for food dishes.

hzmann commented 3 months ago

Thank you for your quick response and for looking into this issue so promptly. If you wanted to see more, the .csv label file can be accessed when you scroll up to the "Model Details" header at the top of the page, locate the "Output" sub-header, and then select the underlined "labelmap" term. You may have to select "Read more" to be able to click on the labelmap. However, as mentioned, it is the same .csv file for all three of the models and is a list of food dishes, so these instructions are irrelevant for accessing the correct Nature-ID files.

joergmlpts commented 3 months ago

Thanks for your info on downloading the .cvs label file. I have followed up on that and noticed code examples in the submodels section. The main model on foods has two examples, one for loading the model and another one for using it. The submodels only have sample code that loads the model.

The example for using the food model includes this line:

labelmap_url = "https://www.gstatic.com/aihub/tfhub/labelmaps/aiy_food_V1_labelmap.csv"

There is no sample code for downloading the insect, bird, and plant labels. But a slight variation of the URL will do the trick:

https://www.gstatic.com/aihub/tfhub/labelmaps/aiy_insects_V1_labelmap.csv https://www.gstatic.com/aihub/tfhub/labelmaps/aiy_birds_V1_labelmap.csv https://www.gstatic.com/aihub/tfhub/labelmaps/aiy_plants_V1_labelmap.csv

joergmlpts commented 2 months ago

The model download instructions have been updated.