Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
max-line-length=88
extend-ignore=E203
183 changes: 183 additions & 0 deletions .gitignore
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_*
Comment on lines +181 to +183
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

/demo_* conflicts with the documented demo assets.

README.md tells 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
 # Project
 /data
 /demo_*
+!/demo_data/
+!/demo_data/**
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.gitignore around lines 181 - 183, The .gitignore entry '/demo_*'
incorrectly excludes the demo_data directory referenced in README.md; update the
.gitignore by removing or narrowing the '/demo_*' pattern and add an explicit
allow rule for demo_data (e.g., add '!/demo_data/' and '!/demo_data/**') so the
'./demo_data/...' demo assets can be committed; target the '/demo_*' line in
.gitignore and the README.md mention of './demo_data' to verify consistency.

5 changes: 5 additions & 0 deletions .mypy.ini
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
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

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 pre-commit alebo jeho neočakávané správanie.

  • pre-commit-hooks (riadok 5): v5.0.0 nie je platný tag. Posledná stabilná verzia je v4.6.0.
  • commitizen (riadok 11): v3.30.1 nie je platný tag. Posledná stabilná verzia je v3.28.0.
  • ruff-pre-commit (riadok 16): v0.7.3 je predbežná verzia Ruff. Všeobecne sa odporúča používať stabilné verzie (napr. v0.5.0), aby sa predišlo neočakávaným problémom.

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

curl -fsSL https://raw.githubusercontent.com/astral-sh/ruff-pre-commit/v0.7.3/.pre-commit-hooks.yaml \
  | sed -n '/^- id: ruff/,+12p;/^- id: ruff-format/,+8p'

Repository: RationAI/stain-normalization

Length of output: 653


Keep the Ruff hooks on Ruff's default entrypoint.

Replacing the hook entry with pdm lint and pdm format makes the hook depend on pdm being available inside pre-commit's isolated hook environment, where it typically isn't available. This causes hook execution to fail before Ruff even runs. Use the default Ruff entrypoints and pass tool-specific flags via args instead.

Suggested fix
   - repo: https://github.com/astral-sh/ruff-pre-commit
     rev: v0.7.3
     hooks:
       # Run the linter.
       - id: ruff
-        entry: pdm lint --force-exclude
+        args: [--fix, --force-exclude]
       # Run the formatter.
       - id: ruff-format
-        entry: pdm format --force-exclude
+        args: [--force-exclude]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- id: ruff
entry: pdm lint --force-exclude
# Run the formatter.
- id: ruff-format
entry: pdm format --force-exclude
- id: ruff
args: [--fix, --force-exclude]
# Run the formatter.
- id: ruff-format
args: [--force-exclude]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.pre-commit-config.yaml around lines 19 - 23, The pre-commit hooks replaced
Ruff's default entrypoints with `pdm lint` and `pdm format`, which breaks hooks
because `pdm` is not available in pre-commit's isolated environment; change the
`id: ruff` and `id: ruff-format` hook entries back to Ruff's default executables
(`ruff` and `ruff-format`) and move `--force-exclude` into the hook `args` array
so the flags are passed to Ruff without depending on `pdm` in the hook
environment.

51 changes: 51 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
fix = true
line-length = 88
target-version = "py311"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

target-version je nastavená na py311, ale pyproject.toml špecifikuje Python 3.12.5. Aby sa zabezpečilo, že opravy a kontroly Ruff sú kompatibilné s verziou Pythonu vášho projektu, toto by sa malo aktualizovať.

Suggested change
target-version = "py311"
target-version = "py312"


[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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

V extend-select ste vybrali ERA (kontrola zakomentovaného kódu), ale hneď potom ste ignorovali jeho jediné pravidlo, ERA001. Tým sa kontrola v podstate vypne. Ponechanie zakomentovaného kódu sa vo všeobecnosti neodporúča, pretože zahlcuje kódovú základňu a môže zastarať. Je lepšie spoliehať sa na históriu verzovacieho systému. Zvážte odstránenie tohto riadku, aby ste kontrolu povolili.

"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"
35 changes: 34 additions & 1 deletion README.md
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:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

V slove arguemnty je preklep. Správne má byť argumenty.

Suggested change
## Dostupné arguemnty:
## Dostupné argumenty:

- **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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

V slove použivať chýba dĺžeň. Správne má byť používať.

Suggested change
- **use_cpu**: defaultne nadstavené na použitie GPU ak je dostupná, avšak ak by nastali problémy odporúčam použivať iba CPU
- **use_cpu**: defaultne nadstavené na použitie GPU ak je dostupná, avšak ak by nastali problémy odporúčam používať iba CPU

Comment on lines +31 to +34
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix the CLI section typos.

arguemnty and nadstavené are user-facing typos in the only section that explains the flags, so the README reads unfinished right where users are expected to follow it.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@README.md` around lines 31 - 34, Fix the typos in the CLI flags section
header and description: change the header "Dostupné arguemnty:" to "Dostupné
argumenty:" and correct "nadstavené" to "nastavené" in the line describing
"use_cpu"; keep the existing flag names (input, output, use_cpu) and their
default values intact so only spelling is updated.

Loading
Loading