Skip to content

flowerchecker/plant-id-examples

Repository files navigation

Plant.id by kindwise offers plant identification and plant health assessment API based on machine learning. Once you register and obtain the API key, you can use these client's code available in this repository to speed-up the development of your implementation.

Plant.id API v3

Plant Identification 🌱

Send us your plant images, and get a list of possible species suggestions with additional information.

pip install kindwise-api-client
from kindwise import PlantApi

api = PlantApi('your_api_key')
identification = api.identify('../images/unknown_plant.jpg', details=['url', 'common_names'])

print('is plant' if identification.result.is_plant.binary else 'is not plant')
for suggestion in identification.result.classification.suggestions:
    print(suggestion.name)
    print(f'probability {suggestion.probability:.2%}')
    print(suggestion.details['url'], suggestion.details['common_names'])
    print()

Same example in pure python

import base64

import requests

with open('../images/unknown_plant.jpg', 'rb') as file:
    images = [base64.b64encode(file.read()).decode('ascii')]

response = requests.post(
    'https://api.plant.id/v3/identification',
    params={'details': 'url,common_names'},
    headers={'Api-Key': 'your_api_key'},
    json={'images': images},
)

identification = response.json()

print('is plant' if identification['result']['is_plant']['binary'] else 'is not plant')
for suggestion in identification['result']['classification']['suggestions']:
    print(suggestion['name'])
    print(f'probability {suggestion["probability"]:.2%}')
    print(suggestion['details']['url'], suggestion['details']['common_names'])
    print()

Health Assessment 🥀

Send us your ill plant images, and get a list of possible health issues your plant suffers from.

from kindwise import PlantApi

api = PlantApi('your_api_key')
identification = api.health_assessment('../images/unhealthy_plant.jpg', details=['description', 'treatment'])

print('is healthy' if identification.result.is_healthy.binary else 'has disease')
for suggestion in identification.result.disease.suggestions:
    print(suggestion.name)
    print(f'probability {suggestion.probability:.2%}')
    print(suggestion.details['description'])
    print(suggestion.details['treatment'])
    print()

About

Example client's code for work with Plant.id identification API in various languages

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published