{"id":16420730,"url":"https://github.com/andrew-chen-wang/static-image-age-detection","last_synced_at":"2025-09-13T06:31:02.621Z","repository":{"id":103627225,"uuid":"272012229","full_name":"Andrew-Chen-Wang/static-image-age-detection","owner":"Andrew-Chen-Wang","description":"Estimating Age Using Multiple Pictures instead of One","archived":true,"fork":false,"pushed_at":"2024-08-30T23:50:35.000Z","size":81319,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-21T09:54:59.192Z","etag":null,"topics":["age-estimation","computer-vision","face-detection","opencv","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Andrew-Chen-Wang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-13T13:17:03.000Z","updated_at":"2024-11-30T00:57:11.000Z","dependencies_parsed_at":"2024-11-10T09:02:56.203Z","dependency_job_id":"3aed3c26-81c5-4cde-8cd3-383d3b05b149","html_url":"https://github.com/Andrew-Chen-Wang/static-image-age-detection","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Andrew-Chen-Wang/static-image-age-detection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andrew-Chen-Wang%2Fstatic-image-age-detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andrew-Chen-Wang%2Fstatic-image-age-detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andrew-Chen-Wang%2Fstatic-image-age-detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andrew-Chen-Wang%2Fstatic-image-age-detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Andrew-Chen-Wang","download_url":"https://codeload.github.com/Andrew-Chen-Wang/static-image-age-detection/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andrew-Chen-Wang%2Fstatic-image-age-detection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274927791,"owners_count":25375458,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-13T02:00:10.085Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["age-estimation","computer-vision","face-detection","opencv","python"],"created_at":"2024-10-11T07:29:00.959Z","updated_at":"2025-09-13T06:30:57.472Z","avatar_url":"https://github.com/Andrew-Chen-Wang.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Detecting Age with Static Images\n\nCreated 9 June 2020\n\nStarted AND Finished 13 June 2020\n\nPublished by Andrew Chen Wang\n\nTable of Contents:\n- Introduction\n- How this works\n- Technical details\n- Conclusion + Benchmark\n- What's left to be done\n- References\n- FAQ\n- Contact Me\n- License\n\n---\n### Introduction\n\nThe purpose of this package is to identify age through\nstatic images. Following some four repositories later\nand not knowing much machine learning techniques (only\nconcepts), I decided to use OpenCV's DNN to better\naccommodate for future plans of live calls in addition\nto some other models in order to deal with dropped FPS.\n\nFor now, this is all about static images, finding out\nhow many images are needed to get an average accurate\nprediction rate of 95% and finding ways to improve\nthe rate while decreasing the number of images needed\nfor proper identification.\n\nNote: when speaking of utilizing multiple images, it's\nto increase accuracy by getting more features at different\nangles and curves in case that's the reason.\n\n---\n### How this works\n\nThis module uses the tutorial by PyImageSearch seen \n[here](https://www.pyimagesearch.com/2020/04/13/opencv-age-detection-with-deep-learning/).\nI've reworked this code to utilize a single image or a directory\nof images so that I can increase accuracy.\n\nReally, the increase of accuracy comes from the mean age combined\nwith the intertwining of the confidence of each age bracket. The\ndirectory usage has an initial image (which you can specify in\nan argument if it's not the first in alphanumeric order) which\nwe use to define the initial objects. There must be at least one\nobject that appears in all submitted pictures.\n\nI've also integrated object tagging so that I know that the objects\nare the same; if not, then we raise an error saying they are different.\nIf there are multiple objects in the initial image, we only raise an\nerror if none of the initial faces appear in the initial picture.\n\nUsage for multi-image dependant age estimation (you must have a dataset\nin the data folder to use this with at least two people. Go to the\n[Data README](https://github.com/Andrew-Chen-Wang/static-image-age-detection/blob/master/data/README.md)\nfor instructions on what you should have in the data directory):\n\n```bash\npython main.py -i data/input -d data/dataset\n```\n\nUsage for single image (i.e. not dependent on others, but you can specify a\ndirectory, too): `python main.py --image data/single_images/adrian.png`\n\nIf you submit a directory of images, then we draw out the initial image\nwith bounding boxes. You can specify to show all images with bounding\nboxes.\n\n---\n### Technical details\n\nBesides the single image age detector, the multi-image age detector\nutilizes several single image age estimations of a person and combines\nthem in an algorithm. You may notice there is a facial recognition\npackage; that is used for figuring out which person gets a certain age\nbracket during the age detection calculation.\n\nThe facial recognition DOES NOT affect the results of the age estimation.\nIt is primarily designed to detect the person and log the correct age\nbracket in case an input image has multiple people.\n\n---\n### Conclusion + Benchmark\n\nConclusion:\n\nAs of 13 June 2020 midnight, I finished it and tested it\non some female model that my friend sent me so that I can test this.\nAs noted the main [age-detection repo](https://github.com/Andrew-Chen-Wang/age-detection),\nfemales are more difficult ot identify in age. The model turned out\nto be in the 8-12 age bracket. I still need further testing though,\nas I only did one.\n\nIn my opinion, it's just a matter of the age detector model used.\nI cannot be conclusive about if multiple images help or not,\nso I'm going to try and find a better age detector model.\n\nBenchmark:\n\nThe reason I wanted to do this was to improve the accuracy of age detection\nusing videos. To put it to the test, you can run `benchmark.py` which\nwill compare the accuracy of just doing a single image test (for an\nentire directory if specified) vs. processing an entire directory.\nThe single image test takes the mean of the accuracies to show\nthe stability of using multiple images for processing instead of one.\n\nHave I looked through all of OpenCV or PyImageSearch? Nope, only one\narticle. But hey, beginner's luck I suppose.\n\n---\n### What's left to be done\n\nAgain, my goal was to test this aggregate data for video streaming\npurposes. Although my purpose of video streaming is to tag people\nand not to train on known people, the concept remains the same\nas the training doesn't affect the age detection (we know the age\ndetection must work if the face detector detects the target person).\n\nSo really, for this repo, it's making the aggregate data function\n(ambiguously) better. For me, it's to learn how to train to detect\nan unknown person and tag him/her with an ID.\n\nThe last thing that needs work, for me, is when a new picture comes\nin. Perhaps at an 87% confidence threshold can you retrain a embedding\nusing this new dataset (that just includes that one new photo). It's\nsimilar to how social media companies do it, but it'd be neat to learn!\n\n---\n### FAQ\n\n**Why am I getting** `ValueError: The number of classes has to be greater than one; got 1 class`?\n\nYou should have at least two different, known people in your dataset directory.\n\n---\n### References\n\nThe code and models largely come Adrian at PyImageSearch.\nThis is my first time learning machine learning and deep\nlearning (not ready for AI yet).\n\nLuckily, in this tutorial, Adrian used DDN and I tweaked a\nbit of code to just be more efficient. Of course, this project\nis not all about one image but multiple to increase accuracy,\nwhich is my code.\n\nI'm grateful for finding this because I couldn't find the models\nmyself lol. So thanks for the tutorials, and I hope this\nmodule actually DOES increase accuracy while maintaining\na good CPU usage level (slight jab at Dlib's HoG).\n\nAdditionally, I used a lot, like a lot, of code from\nAdrian's tutorials, and only tweaked them to be more\nmodern and lean (e.g. pathlib, unnecessary args, personal\nmodifications to suit the project), so a big shout out\nto him for his wonderful work!\n\n---\n### Contact Me\n\nIf I'm doing something wrong (again, I've never learned machine\nlearning before. I only know some basic concepts and ideas),\nplease open a GitHub issue or contact me here:\n\n[Andrew Wang at acwangpython@gmail.com](mailto:acwangpython@gmail.com?subject=[GH%20DL%20Static%20Image])\n\n(If you decide to email me, please leave the prefix subject line. Thank you).\n\n---\n### License\n```\n   Copyright 2020 Andrew Chen Wang\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrew-chen-wang%2Fstatic-image-age-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrew-chen-wang%2Fstatic-image-age-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrew-chen-wang%2Fstatic-image-age-detection/lists"}