Beispiel #1
0
def test(request):
    from age_detect_app.models import AgeGuesser
    #self.get_message(guessed_age, body_part)
    ageGuesser = AgeGuesser()
    guessed_age = {
        'is_male':True,
        'min':0,
        'max':0,
        'age':0,
        'decade':0,
        'is_youth':False,
        'is_old':False,
        'is_20s':True,
        'is_30s':False,
        'language':'en',
        'message': ''
    }
    #body_part = '_forehead'
    #body_part = '_nose_mouth'
    body_part = '_left_eye'
    
    result = json.dumps(ageGuesser.get_message(guessed_age, body_part))
    response = HttpResponse(result, mimetype = "application/json")
    return response
Beispiel #2
0
    filenames = glob.glob("{0}train/{1}*.jpg".format(settings.PROJECT_ROOT, path))
    for filename in filenames:
        im = cv2.imread(filename, cv2.IMREAD_GRAYSCALE)
        image_data = np.asarray(im, dtype=np.uint8)
        X.append(image_data)
        name_arr = filename.split('/')
        files.append(name_arr[len(name_arr)-1])
    return [X,files]

if __name__ == "__main__":
    
    
    if len(sys.argv) < 2:
        print "USAGE: guess_age.py </path/to/test/images/>"
        sys.exit()
    
    [X,files] = read_images(sys.argv[1])
    
    ageGuesser = AgeGuesser()
    
    for i in range(0,len(X)):
        
        
        
        image = X[i]
        file = files[i]
        age = file[0:2]
        
        guessed_age = ageGuesser.guess_age(image)
        print "{0},{1}".format(age, guessed_age)
    
Beispiel #3
0
 def get_age(self):
     ageGuesser = AgeGuesser()
     guessed_age = ageGuesser.guess_age(self.image_upload_dir, self.udid, self.language)
     
     return guessed_age