Nandhugp
Power Member
- Jan 24, 2013
- 578
- 286
So recently I saw thispersondoesnotexist.com where computer generates a person face that doesn't even exist. I told some of my friends and they didn't even believe it. So I wanted to share something that this community may find useful. Even though I don't have any method to make money
, I wanted to contribute something to this community for everything that I learned here.
This is a simple code any python noob can do.
Make sure you enter the directory in this format
E:/images/
If you put E:/images it wont work
To make this work you need to have urllib3 module installed on python.
I actually wanted to do something more like detecting gender and age. i couldn't because I was unable to install tensorflow in my PC
. Tensorflow requires 64 bit PC but mine only have 32 bit. I also looked for trial VPS but couldn't find any, However I found an idea on how to make it work.
So py-agender is an python module that can detect gender and age from a photo.
This is the base code for using this module. It requires cv2 and tensorflow. I don't know what output we get after executing the code but certainly we will get the probability of gender.
We can use that to save the image file with the gender and age on the image file.
This code can be further modified to get image of specified gender and age group by saving those files in another folder.
This might help people who are creating bulk accounts and such.
This is a simple code any python noob can do.
Make sure you enter the directory in this format
E:/images/
If you put E:/images it wont work
To make this work you need to have urllib3 module installed on python.
Code:
import urllib.request
import random
n=input("How many images do you need?")
val=int(n)
dir=input("Enter the directory you want to save")
for i in range(val):
file_name = random.randrange(1,10000)
full_file_name = dir + str(file_name) + '.jpg' #Insert your
def downloader(image_url,full_file_name):
urllib.request.urlretrieve(image_url,full_file_name)
downloader("https://www.thispersondoesnotexist.com/",full_file_name)
I actually wanted to do something more like detecting gender and age. i couldn't because I was unable to install tensorflow in my PC
So py-agender is an python module that can detect gender and age from a photo.
Code:
from pyagender import PyAgender
agender = PyAgender()
# see available options in __init__() src
faces = agender.detect_genders_ages(cv2.imread(MY_IMAGE))
# [
# {left: 34, top: 11, right: 122, bottom: 232, width:(r-l), height: (b-t), gender: 0.67, age: 23.5},
# ...
# ]
This is the base code for using this module. It requires cv2 and tensorflow. I don't know what output we get after executing the code but certainly we will get the probability of gender.
We can use that to save the image file with the gender and age on the image file.
This code can be further modified to get image of specified gender and age group by saving those files in another folder.
This might help people who are creating bulk accounts and such.