Created
February 11, 2021 00:44
-
-
Save symisc/387563f51f8542587c6b2c9a4db45d15 to your computer and use it in GitHub Desktop.
Dynamically generates a set of random pixels of desired width & height using PixLab /pixelgenerate API endpoint - https://pixlab.io/cmd?id=pixelgenerate
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 | |
# Generates a set of random pixels of desired Width & Height. This endpoint is similar to /newimage except that the image contents is filled with random pixels. This is very useful for generating background (negative) samples for feeding Machine Learning training algorithms | |
req = requests.get('https://api.pixlab.io/pixelgenerate',params={ | |
'key':'PIXLAB_API_KEY', # https://pixlab.io/dashboard to get your API Key | |
"width":300, | |
"height":300 | |
}) | |
reply = req.json() | |
if reply['status'] != 200: | |
print (reply['error']) | |
exit(); | |
#Link to the newly generated image | |
print ("Randomly generated image location: "+ reply['ssl_link']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment