Skip to content

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

License

Notifications You must be signed in to change notification settings

flowerchecker/plant-id-examples

Repository files navigation

Plant.id by kindwise offers plant identification and plant diseases identification 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 🌱

Submit images of plants and get a list of possible species suggestions along with detailed 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 🥀

Submit photos of sick plants, and receive a list of potential health issues.

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()

Conversation 🤖 💬

Chat about identification with ChatBot. ChatBot supports multiple backends and its configuration can be modified.

from kindwise import PlantApi, MessageType

api = PlantApi('your_api_key')
conversation = api.ask_question('plant identification', 'Is this plant edible?')

for message in conversation.messages:
    if message.type == MessageType.ANSWER:
        print(f'App: {message.content}')
    else:
        print(f'Client: {message.content}')
    print()
print('Feedback:', conversation.feedback.get('rating'))

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