Easy integration
Easy API Integration with Deep Image AI
1. Process an Image
Sending an image with process method and periodically checking the result
import time
import json
from pathlib import Path
from urllib.request import urlretrieve
# using requests library
import requests
API_KEY = REPLACE_WITH_YOUR_API_KEY
headers = {
'x-api-key': API_KEY,
}
data = {
"enhancements": ["denoise", "deblur", "light"],
"width": 2000
}
data_dumped = {"parameters": json.dumps(data)}
with open(YOUR_LOCAL_FILE_TO_SEND, 'rb') as f:
response = requests.post('https://deep-image.ai/rest_api/process', headers=headers,
files={'image': f},
data=data_dumped)
if response.status_code == 200:
response_json = response.json()
job_id = response_json["job"]
result_status = "received"
while result_status in ['received', 'in_progress', 'not_started']:
response = requests.get(f'https://deep-image.ai/rest_api/result/{job_id}',
headers=headers)
response_json = response.json()
result_status = response_json['status']
time.sleep(1)
if result_status == 'complete':
p = Path(response_json['result_url'])
urlretrieve(response_json['result_url'], p.name)
Sending an Image with process_result method and periodically checking the result
2. Get results faster with webhooks (Recommended)
Example: Send a Request with a Webhook
Example: Receiving the Webhook (Flask)
3. Automate Workflows with Zapier Integration
4. Enhance Automation with Make (Integromat) Integration
Last updated