Created
April 12, 2023 01:22
-
-
Save tempire/e0128f3ae59be9d5a6cfe3d7efb321b1 to your computer and use it in GitHub Desktop.
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
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