Septzzz's picture
Upload folder using huggingface_hub (part 25)
7d0f0c3 verified
Raw
History Blame Contribute Delete
1.55 kB
import requests
import json
from datetime import date, datetime, timedelta
import os
from typing import Optional, Dict, Union, List
def detection_objects_as_modified_image_by_image_url(url: str, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Image URL and it will return a updated image of detected objects in image via bounding boxes"
"""
url = f"https://mantis-object-detection.p.rapidapi.com/rest/v1/public/detectobjects"
querystring = {'url': url, }
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "mantis-object-detection.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def detection_objects_as_json_by_image_url(url: str, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Any valid image URL and return JSON"
"""
url = f"https://mantis-object-detection.p.rapidapi.com/rest/v1/public/detectobjects/json"
querystring = {'url': url, }
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "mantis-object-detection.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation