{"id":18439570,"url":"https://github.com/idiap/deepfocus","last_synced_at":"2025-09-11T17:47:46.130Z","repository":{"id":119190812,"uuid":"251224812","full_name":"idiap/deepfocus","owner":"idiap","description":"Pytorch implementation of \"DeepFocus: a Few-Shot Microscope Slide Auto-Focus using a Sample Invariant CNN-based Sharpness Function\"","archived":false,"fork":false,"pushed_at":"2023-07-05T20:44:14.000Z","size":32523,"stargazers_count":22,"open_issues_count":4,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-08T23:02:04.359Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/idiap.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-03-30T06:50:43.000Z","updated_at":"2025-06-06T08:20:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"e2fd5d55-1f19-42cf-b4d9-a66ef8e56528","html_url":"https://github.com/idiap/deepfocus","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/idiap/deepfocus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiap%2Fdeepfocus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiap%2Fdeepfocus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiap%2Fdeepfocus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiap%2Fdeepfocus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/idiap","download_url":"https://codeload.github.com/idiap/deepfocus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiap%2Fdeepfocus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274681442,"owners_count":25330236,"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-11T02:00:13.660Z","response_time":74,"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":[],"created_at":"2024-11-06T06:25:29.205Z","updated_at":"2025-09-11T17:47:46.112Z","avatar_url":"https://github.com/idiap.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DeepFocus\nCode for the PyTorch implementation of \"DeepFocus: a Few-Shot Microscope Slide Auto-Focus using a Sample Invariant CNN-based Sharpness Function\"\n\nhttps://arxiv.org/abs/2001.00667\nTo be published at 2020 IEEE 17th International Symposium on Biomedical Imaging (ISBI)\n\n## Abstract\nAutofocus (AF) methods are extensively used in biomicroscopy, for example to acquire timelapses, where the imaged objects tend to drift out of focus. AF algorithms determine an optimal distance by which to move the sample back into the focal plane. Current hardware-based methods require modifying the microscope and image-based algorithms either rely on many images to converge to the sharpest position or need training data and models specific to each instrument and imaging configuration. Here we propose DeepFocus, an AF method we implemented as a Micro-Manager plugin, and characterize its Convolutional neural network-based sharpness function, which we observed to be depth co-variant and sample-invariant. Sample invariance allows our AF algorithm to converge to an optimal axial position within as few as three iterations using a model trained once for use with a wide range of optical microscopes and a single instrument-dependent calibration stack acquisition of a flat (but arbitrary) textured object. From experiments carried out both on synthetic and experimental data, we observed an average precision, given 3 measured images, of 0.30 +- 0.16 micrometers with a 10x, NA 0.3 objective. We foresee that this performance and low image number will help limit photodamage during acquisitions with light-sensitive samples. \n\n## Requirements\nThe following python libraries are required. We advise the use of the conda package manager.\n\u003e numpy\n\u003e scipy\n\u003e scikit-image\n\u003e scikit-learn\n\u003e pytorch\n\u003e matplotlib\n\u003e numba\n\u003e lmfit\n\u003e grpcio\n\u003e protobuf\n\u003e fastai\n\nFor example, you can install all the requirements by using\n\u003e conda install --file detection/requirements.txt\n\n## Installation\nCopy-paste the contents of `javabinaries` in your Micro-manager main folder.\n\n## How to run\nBefore starting Micro-Manager, run `python detection/run_grpc.py` to launch the processing server.\n\n## Generate figures\nTo generate figures from the paper, run `python detection/calibration_fit.py` then `python detection/simulations_plot.py`\n\n## Citation\nFor any use of the code or parts of the code, please cite:\n\u003e@INPROCEEDINGS{shajkofci2020deepfocus,\n\u003e    title={DeepFocus: a Few-Shot Microscope Slide Auto-Focus using a Sample Invariant CNN-based Sharpness Function},\n\u003e    author={Adrian Shajkofci and Michael Liebling},\n\u003e    year={2020},\n\u003e    isbn = {978-1-5386-9330-8/},\n\u003e    booktitle={2020 IEEE 17th International Symposium on Biomedical Imaging (ISBI)}, \n\u003e    pages={164--168}\n\u003e}\n## Licence\nThis is free software: you can redistribute it and/or modify it under the terms of the BSD-3-Clause licence.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidiap%2Fdeepfocus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidiap%2Fdeepfocus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidiap%2Fdeepfocus/lists"}