Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save albert-tomanek/dcecc1620c5e99a3a25fbba3d0a9e96d to your computer and use it in GitHub Desktop.
Save albert-tomanek/dcecc1620c5e99a3a25fbba3d0a9e96d to your computer and use it in GitHub Desktop.
Scrape thispersondoesnotexist.com
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