Created
August 12, 2020 14:06
-
-
Save albert-tomanek/dcecc1620c5e99a3a25fbba3d0a9e96d to your computer and use it in GitHub Desktop.
Scrape thispersondoesnotexist.com
This file contains 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
def faces_datagen(): | |
import urllib.request, io | |
while True: | |
batch = np.zeros((BATCH_SIZE, *imgdims)) | |
for i in range(BATCH_SIZE): | |
data = urllib.request.urlopen( | |
urllib.request.Request( | |
'https://thispersondoesnotexist.com/image', | |
headers={'User-Agent':'Your user agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0'} | |
) | |
).read() | |
img = Image.open(io.BytesIO(data)) | |
img = img.resize((96,96)).convert('L') | |
batch[i] = np.array(img) | |
yield batch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment