Created
June 22, 2025 23:46
-
-
Save symisc/fcf333524c9b339fc235d12ee1a5871e to your computer and use it in GitHub Desktop.
Generate a natural language description of an image content using the PixLab DESCRIBE API Endpoint - https://pixlab.io/endpoints/describe
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 | |
import json | |
# Generate a natural language description of an image content | |
# Target Image: Change to any link or switch to POST if you want to upload your image directly, refer to the REST API code samples for more info. | |
img = 'https://s-media-cache-ak0.pinimg.com/originals/35/d0/f6/35d0f6ee0e40306c41cfd714c625f78e.jpg' | |
key = 'PIXLAB_API_KEY' # Get your API key from https://console.pixlab.io/ | |
req = requests.get('https://api.pixlab.io/describe',params={ | |
'img':img, | |
'key':key, | |
'lang':'english', | |
'short':False | |
}) | |
reply = req.json() | |
if reply['status'] != 200: | |
print (reply['error']) | |
else: | |
description = reply['description'] | |
print(f"Natural language content description: {description}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://pixlab.io/api-endpoint for the list of API endpoints and their respective documentation.