Spaces:
Sleeping
Sleeping
Download analysis/params.py from DmitryPlant/plants-analysis-api: direct link, hf CLI and curl.
- Browser
- Download file 1.43 kB
-
https://huggingface.co/spaces/DmitryPlant/plants-analysis-api/resolve/main/analysis/params.py
- Command line
-
hf download hf://spaces/DmitryPlant/plants-analysis-api/analysis/params.py
-
curl -L -o params.py https://huggingface.co/spaces/DmitryPlant/plants-analysis-api/resolve/main/analysis/params.py
1.43 kB
| from dataclasses import dataclass, asdict | |
| from typing import Any | |
| def _force_odd(n: int) -> int: | |
| return n if n % 2 == 1 else n + 1 | |
| class AnalysisParams: | |
| hue_low: int = 10 | |
| hue_high: int = 35 | |
| min_hue_fraction: float = 0.05 | |
| shrink_factor: float = 0.95 | |
| use_bilateral: bool = True | |
| bilateral_d: int = 9 | |
| sigma_color: int = 75 | |
| sigma_space: int = 75 | |
| v_mode: str = "otsu" | |
| s_mode: str = "otsu" | |
| v_threshold: int = 150 | |
| s_threshold: int = 50 | |
| v_otsu_offset: int = 0 | |
| s_otsu_offset: int = 0 | |
| bright_keep_threshold: int = 180 | |
| max_area_fraction: float = 0.30 | |
| use_hue_filter: bool = True | |
| hue_filter_low: int = 8 | |
| hue_filter_high: int = 28 | |
| small_kernel: int = 3 | |
| large_kernel: int = 7 | |
| close_iters: int = 2 | |
| open_iters: int = 1 | |
| smooth_kernel: int = 9 | |
| min_component_area: int = 50 | |
| h: int = 5 | |
| min_seed_area: int = 5 | |
| use_merge: bool = True | |
| merge_area_threshold: int = 500 | |
| proximity_threshold: int = 15 | |
| color_similarity_threshold: int = 30 | |
| min_area: int = 100 | |
| def __post_init__(self) -> None: | |
| for f in ("bilateral_d", "small_kernel", "large_kernel", "smooth_kernel"): | |
| setattr(self, f, _force_odd(getattr(self, f))) | |
| def to_dict(self) -> dict[str, Any]: | |
| return asdict(self) | |
| DEFAULT_PARAMS = AnalysisParams() | |