{"id":21145082,"url":"https://github.com/nandometzger/mlfocallengths","last_synced_at":"2025-07-09T07:31:06.462Z","repository":{"id":137272034,"uuid":"583669605","full_name":"nandometzger/MLFocalLengths","owner":"nandometzger","description":"Estimating the Focal Length from Monocular Images","archived":false,"fork":false,"pushed_at":"2024-08-02T06:23:17.000Z","size":38440,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-02T07:36:13.778Z","etag":null,"topics":["cnn","computer-vision","deep-learning"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nandometzger.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2022-12-30T14:12:08.000Z","updated_at":"2024-08-02T07:36:16.188Z","dependencies_parsed_at":null,"dependency_job_id":"4af72e0b-0431-4ec2-9c52-d7a6252be3bb","html_url":"https://github.com/nandometzger/MLFocalLengths","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nandometzger%2FMLFocalLengths","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nandometzger%2FMLFocalLengths/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nandometzger%2FMLFocalLengths/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nandometzger%2FMLFocalLengths/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nandometzger","download_url":"https://codeload.github.com/nandometzger/MLFocalLengths/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225492420,"owners_count":17482869,"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","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":["cnn","computer-vision","deep-learning"],"created_at":"2024-11-20T08:36:23.205Z","updated_at":"2024-11-20T08:36:23.989Z","avatar_url":"https://github.com/nandometzger.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MLFocalLengths: Estimating the Focal Length of a Single Image\n\nInformation about the focal length with which a photo is taken might be obstructed (internet photos) or not available (vintage photos). Inferring the focal length of a photo solely from a monocular view is an ill-posed task that requires knowledge about the scale of objects and their distance to the camera - e.g. scene understanding. I trained a deep learning model to acquire such scene understanding to predict the focal length and open-source the model with this repository.\n \n![test](img/stone_tagged2.gif)\n\nFocal lengths influence the distortion of an image.\nSource image credits to Reddit user [u/scyshc](https://www.reddit.com/r/photography/comments/48l8uy/a_gif_showing_why_focal_length_matters/)\n\n# Method\n\nI preprocessed the focal lengths of ~15k of my personal image database to convert them to 35mm equivalent using [Jeffrey Friedl's LR Plugin](http://regex.info/blog/lightroom-goodies/focal-length-sort). The images were cropped to a square shape and resampled to 256x256. Using that data, I trained an EfficientNet B4 with log-transformed labels and L1 loss, which showed a mean absolute error of 16mm on the hold-out set.\n\n# Reproducability\n\nSet up a python environment using ``requirements.txt``. Commands for the creation of the dataset, training, and prediction are provided in the [lauch.json file](https://github.com/nandometzger/MLFocalLengths/blob/main/.vscode/launch.json).\nTraining data is available upon request.\n\nThe pretrained model can be accessed [here](https://drive.google.com/file/d/16Yf8dQrIAg-k8RKcy_chRsctrhQ4yzse/view?usp=share_link).\n\n\n# Citation\n\n```\n@misc{Metzger2023MLFocalLengths,\n  author       = {Nando Metzger},\n  title        = {MLFocalLengths: Estimating the Focal Length of a Single Image},\n  year         = {2023},\n  url          = {https://github.com/nandometzger/MLFocalLengths},\n  note         = {GitHub repository}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnandometzger%2Fmlfocallengths","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnandometzger%2Fmlfocallengths","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnandometzger%2Fmlfocallengths/lists"}