-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi-firebase-testing.py
More file actions
33 lines (27 loc) · 992 Bytes
/
Copy pathapi-firebase-testing.py
File metadata and controls
33 lines (27 loc) · 992 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import requests
from io import BytesIO
def identify_plant_from_url(image_url, api_key):
# Download the image from the URL
response = requests.get(image_url)
response.raise_for_status() # Check if download was successful
# Prepare the form data
files = {
'images': ('image.jpg', BytesIO(response.content), 'image/jpeg')
}
params = {
'api-key': api_key,
'include-related-images': 'false',
'no-reject': 'false',
'nb-results': 10,
'lang': 'en',
'type': 'kt' # or 'legacy' if needed
}
# Make the API request
api_url = "https://my-api.plantnet.org/v2/identify/all"
response = requests.post(api_url, files=files, params=params)
return response.json()
# Example usage
image_url = ""#testing and this works with firebase images! Yippie!
api_key = ""#removed api key and such
result = identify_plant_from_url(image_url, api_key)
print(result)