-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add demo and misc #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [flake8] | ||
| max-line-length=88 | ||
| extend-ignore=E203 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,183 @@ | ||
| # Byte-compiled / optimized / DLL files | ||
| __pycache__/ | ||
| *.py[cod] | ||
| *$py.class | ||
|
|
||
| # C extensions | ||
| *.so | ||
|
|
||
| # Distribution / packaging | ||
| .Python | ||
| build/ | ||
| develop-eggs/ | ||
| dist/ | ||
| downloads/ | ||
| eggs/ | ||
| .eggs/ | ||
| lib/ | ||
| lib64/ | ||
| parts/ | ||
| sdist/ | ||
| var/ | ||
| wheels/ | ||
| share/python-wheels/ | ||
| *.egg-info/ | ||
| .installed.cfg | ||
| *.egg | ||
| MANIFEST | ||
|
|
||
| # PyInstaller | ||
| # Usually these files are written by a python script from a template | ||
| # before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
| *.manifest | ||
| *.spec | ||
|
|
||
| # Installer logs | ||
| pip-log.txt | ||
| pip-delete-this-directory.txt | ||
|
|
||
| # Unit test / coverage reports | ||
| htmlcov/ | ||
| .tox/ | ||
| .nox/ | ||
| .coverage | ||
| .coverage.* | ||
| .cache | ||
| nosetests.xml | ||
| coverage.xml | ||
| *.cover | ||
| *.py,cover | ||
| .hypothesis/ | ||
| .pytest_cache/ | ||
| cover/ | ||
|
|
||
| # Translations | ||
| *.mo | ||
| *.pot | ||
|
|
||
| # Django stuff: | ||
| *.log | ||
| local_settings.py | ||
| db.sqlite3 | ||
| db.sqlite3-journal | ||
|
|
||
| # Flask stuff: | ||
| instance/ | ||
| .webassets-cache | ||
|
|
||
| # Scrapy stuff: | ||
| .scrapy | ||
|
|
||
| # Sphinx documentation | ||
| docs/_build/ | ||
|
|
||
| # PyBuilder | ||
| .pybuilder/ | ||
| target/ | ||
|
|
||
| # Jupyter Notebook | ||
| .ipynb_checkpoints | ||
|
|
||
| # IPython | ||
| profile_default/ | ||
| ipython_config.py | ||
|
|
||
| # pyenv | ||
| # For a library or package, you might want to ignore these files since the code is | ||
| # intended to run in multiple environments; otherwise, check them in: | ||
| # .python-version | ||
|
|
||
| # pipenv | ||
| # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
| # However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
| # having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
| # install all needed dependencies. | ||
| #Pipfile.lock | ||
|
|
||
| # poetry | ||
| # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. | ||
| # This is especially recommended for binary packages to ensure reproducibility, and is more | ||
| # commonly ignored for libraries. | ||
| # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control | ||
| #poetry.lock | ||
|
|
||
| # pdm | ||
| # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. | ||
| #pdm.lock | ||
| # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it | ||
| # in version control. | ||
| # https://pdm-project.org/#use-with-ide | ||
| .pdm.toml | ||
| .pdm-python | ||
| .pdm-build/ | ||
|
|
||
| # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm | ||
| __pypackages__/ | ||
|
|
||
| # Celery stuff | ||
| celerybeat-schedule | ||
| celerybeat.pid | ||
|
|
||
| # SageMath parsed files | ||
| *.sage.py | ||
|
|
||
| # Environments | ||
| .env | ||
| .venv | ||
| env/ | ||
| venv/ | ||
| ENV/ | ||
| env.bak/ | ||
| venv.bak/ | ||
|
|
||
| # Spyder project settings | ||
| .spyderproject | ||
| .spyproject | ||
|
|
||
| # Rope project settings | ||
| .ropeproject | ||
|
|
||
| # mkdocs documentation | ||
| site | ||
|
|
||
| # mypy | ||
| .mypy_cache/ | ||
| .dmypy.json | ||
| dmypy.json | ||
|
|
||
| # ruff | ||
| .ruff_cache/ | ||
|
|
||
| # Pyre type checker | ||
| .pyre/ | ||
|
|
||
| # pytype static type analyzer | ||
| .pytype/ | ||
|
|
||
| # Cython debug symbols | ||
| cython_debug/ | ||
|
|
||
| # VSCode | ||
| .vscode/ | ||
|
|
||
| # MacOS | ||
| .DS_Store | ||
|
|
||
| # Mlflow | ||
| mlruns/ | ||
| mlflow_store/ | ||
| mlflow_artifacts/ | ||
|
|
||
| # Pytorch Lightning | ||
| lightning_logs/ | ||
|
|
||
| # PyCharm | ||
| # JetBrains specific template is maintained in a separate JetBrains.gitignore that can | ||
| # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore | ||
| # and can be added to the global gitignore or merged into this file. For a more nuclear | ||
| # option (not recommended) you can uncomment the following to ignore the entire idea folder. | ||
| .idea/ | ||
|
|
||
| # Project | ||
| /data | ||
| /demo_* | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| [mypy] | ||
| strict = True | ||
| ignore_missing_imports = True | ||
| disallow_untyped_calls = False | ||
| disable_error_code = no-any-return |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,23 @@ | ||||||||||||||||||||||
| # See https://pre-commit.com for more information | ||||||||||||||||||||||
| # See https://pre-commit.com/hooks.html for more hooks | ||||||||||||||||||||||
| repos: | ||||||||||||||||||||||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||||||||||||||||||||||
| rev: v5.0.0 | ||||||||||||||||||||||
| hooks: | ||||||||||||||||||||||
| - id: check-yaml | ||||||||||||||||||||||
| args: [--unsafe] | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - repo: https://github.com/commitizen-tools/commitizen | ||||||||||||||||||||||
| rev: v3.30.1 | ||||||||||||||||||||||
| hooks: | ||||||||||||||||||||||
| - id: commitizen | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - repo: https://github.com/astral-sh/ruff-pre-commit | ||||||||||||||||||||||
| rev: v0.7.3 | ||||||||||||||||||||||
| hooks: | ||||||||||||||||||||||
|
Comment on lines
+4
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Niekoľko revízií pre pre-commit hooks sa zdá byť nesprávnych alebo odkazujú na neexistujúce/predbežné verzie. To pravdepodobne spôsobí zlyhanie
Prosím, aktualizujte tieto revízie na platné a stabilné tagy. |
||||||||||||||||||||||
| # Run the linter. | ||||||||||||||||||||||
| - id: ruff | ||||||||||||||||||||||
| entry: pdm lint --force-exclude | ||||||||||||||||||||||
| # Run the formatter. | ||||||||||||||||||||||
| - id: ruff-format | ||||||||||||||||||||||
| entry: pdm format --force-exclude | ||||||||||||||||||||||
|
Comment on lines
+19
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: Repository: RationAI/stain-normalization Length of output: 653 Keep the Ruff hooks on Ruff's default entrypoint. Replacing the hook entry with Suggested fix📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| fix = true | ||
| line-length = 88 | ||
| target-version = "py311" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| [format] | ||
| # Enable reformatting of code snippets in docstrings. | ||
| docstring-code-format = true | ||
|
|
||
| [lint] | ||
| unfixable = [ | ||
| "ERA", # do not autoremove commented out code | ||
| ] | ||
| extend-select = [ | ||
| "B", # flake8-bugbear | ||
| "C4", # flake8-comprehensions | ||
| "ERA", # flake8-eradicate/eradicate | ||
| "I", # isort | ||
| "N", # pep8-naming | ||
| "PIE", # flake8-pie | ||
| "PGH", # pygrep | ||
| "RUF", # ruff checks | ||
| "SIM", # flake8-simplify | ||
| "TCH", # flake8-type-checking | ||
| "TID", # flake8-tidy-imports | ||
| "UP", # pyupgrade | ||
| "D", # pydocstyle | ||
| ] | ||
| extend-ignore = [ | ||
| "ERA001", # commented out code | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. V |
||
| "D100", # missing docstring in public module | ||
| "D101", # missing docstring in public class | ||
| "D102", # missing docstring in public method | ||
| "D103", # missing docstring in public function | ||
| "D104", # missing docstring in public package | ||
| "D105", # missing docstring in magic method | ||
| "D106", # missing docstring in public nested class | ||
| "D107", # missing docstring in __init__ | ||
| "N812", # lowercase imported as non lowercase | ||
| "TCH002", # move third-party into a type-checking block | ||
| "F722", # jaxtyping | ||
| ] | ||
|
|
||
| [lint.flake8-tidy-imports] | ||
| ban-relative-imports = "all" | ||
|
|
||
| [lint.isort] | ||
| lines-after-imports = 2 | ||
| known-first-party = ["tests"] | ||
|
|
||
| [lint.pydocstyle] | ||
| convention = "google" | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1 +1,34 @@ | ||||||
| # stain-normalization | ||||||
| # Stain Normalization | ||||||
|
|
||||||
| Tento repozitár slúži ako doplnkový materiál k bakalárskej práci **"Normalizácia farbenia histopatologických snímkov pomocou neuronových sietí"**. | ||||||
|
|
||||||
| Celý kód nie je možné spustiť samostatne, pretože vyžaduje prístup k citlivým dátam a k platforme na správu strojového učenia MLflow. Avšak je možné spustiť demo, ku ktorému je pripravených pár vzoriek na demonštráciu. | ||||||
|
|
||||||
| ## Demo | ||||||
|
|
||||||
| Demo skript umožňuje načítať jeden obrázok alebo celý priečinok, normalizovať ich pomocou predtrénovaného modelu a uložiť výsledné obrázky do určeného priečinka. | ||||||
|
|
||||||
| ## Priložené dáta | ||||||
|
|
||||||
| - **Originálne obrázky** (v priečinku `./demo_data/original`) – referenčné vzorky. | ||||||
| - **Upravené obrázky** (v priečinku `./demo_data/modified`) – referenčné obrázky s modifikovaným sfarbením, ktoré sa následne modelom znormalizujú späť k originálnemu vzhľadu. | ||||||
| - **Obrázky z iného datasetu** (v priečinku `./demo_data/to_predict`) – ukazujú, ako model dokáže prispôsobiť farby vstupov tak, aby zodpovedali farebnému štýlu trénovacích dát. | ||||||
| - **Model checkpoint** | ||||||
|
|
||||||
| ## Spustenie dema | ||||||
|
|
||||||
| Projekt je spravovaný pomocou nástroja **pdm**, ktorý umožňuje jednoduchú správu závislostí a prostredia. Stačí nainštalovať závislosti pomocou: | ||||||
|
|
||||||
| ```bash | ||||||
| pdm install | ||||||
| ``` | ||||||
| a potom spustiť demo skript: | ||||||
|
|
||||||
| ```bash | ||||||
| pdm run python demo.py --input ./demo_data/modified | ||||||
| ``` | ||||||
|
|
||||||
| ## Dostupné arguemnty: | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
| - **input**: cesta k obrázku alebo priečinku s obrázkami na normalizáciu (default ./demo_data/modified) | ||||||
| - **output**: priečinok, kam sa uložia normalizované obrázky (default ./demo_data) | ||||||
| - **use_cpu**: defaultne nadstavené na použitie GPU ak je dostupná, avšak ak by nastali problémy odporúčam použivať iba CPU | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. V slove
Suggested change
Comment on lines
+31
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix the CLI section typos.
🤖 Prompt for AI Agents |
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/demo_*conflicts with the documented demo assets.README.mdtells users to run the demo from./demo_data/..., but this pattern ignores that directory. That prevents the sample inputs/checkpoint from being added or updated in git, which undercuts the demo flow this PR introduces.Suggested fix
🤖 Prompt for AI Agents