Skip to content

Instantly share code, notes, and snippets.

@tempire
Created April 12, 2023 01:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tempire/e0128f3ae59be9d5a6cfe3d7efb321b1 to your computer and use it in GitHub Desktop.
Save tempire/e0128f3ae59be9d5a6cfe3d7efb321b1 to your computer and use it in GitHub Desktop.
import requests
def segment_image(image_path, api_key):
with open(image_path, 'rb') as image_file:
response = requests.post(
'https://api.deepai.org/api/deepmask',
files={'image': image_file},
headers={'api-key': api_key}
)
if response.status_code == 200:
return response.json()
else:
raise Exception(f"Error: {response.text}")
if __name__ == "__main__":
api_key = "YOUR_API_KEY" # Replace with your API key
image_path = "path/to/your/image.jpg" # Replace with the path to your image file
segmentation_result = segment_image(image_path, api_key)
print(segmentation_result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment