Last active
October 30, 2019 08:09
-
-
Save ao-picterra/9904e5fd70e47664b9f4de9f2b5a53e8 to your computer and use it in GitHub Desktop.
detect on a raster
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def detect(detector_id, raster_id): | |
| server_url = "https://picterra.ch/public/api/v1" # Picterra Public API server | |
| headers = { 'X-Api-Key': "123456789" } # Get API key on the Picterra platform | |
| url = server_url + ("/detectors/%s/run/" % detector_id) | |
| requests.post(url, headers=headers, data={'raster_id': raster_id}) | |
| response = r.json() # Start prediction | |
| result_id = response["result_id"] | |
| poll_interval = response["poll_interval"] # Waiting interval | |
| url = server_url + ("/results/%s/" % result_id) | |
| while True: # Wait until prediction is finished | |
| time.sleep(poll_interval) | |
| r = requests.get(url, headers=headers) # Get prediction status | |
| if r.json()["ready"]: | |
| download_url = r.json()["result_url"] | |
| break | |
| print("Detection finished, results available at %s" % download_url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment