From 368aa71658f9ee10fb8be40deec2361042220c4d Mon Sep 17 00:00:00 2001 From: zase414 <118931761+zase414@users.noreply.github.com> Date: Fri, 27 Nov 2026 16:47:43 +0100 Subject: [PATCH] idk --- .gitignore | 4 ++ GUIDE.md | 13 ++-- confs/config.yml | 12 ++-- model.py | 104 ++++++++++++++++++++----------- pyproject.toml | 22 ++++--- train.py | 116 ++++++++++++++++++++++------------- uv.lock | 156 ++++++++++++++++++++++++++++++++++++++++++++++- 7 files changed, 328 insertions(+), 99 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..122313c --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +Data/* +__pycache__ +__MACOSX +.venv diff --git a/GUIDE.md b/GUIDE.md index a8dd7db..a63d50b 100644 --- a/GUIDE.md +++ b/GUIDE.md @@ -292,7 +292,9 @@ class FruitDataset(Dataset): ### Check -Temporarily add this at the bottom of `train.py`, or run it in a Python shell from the repo folder: +> **First make the files importable.** `from train import FruitDataset` makes Python read the *whole* `train.py`, which in turn imports `model.py`. Any line that still reads `x = # ‼️ ...` with nothing after the `=` is a `SyntaxError`, so the import fails even though your Dataset is fine. Until you fill those lines in, give them a placeholder value, e.g. `species_criterion = None # ‼️ ...` (and `embedding_bank, all_labels = None, None`). Do this in **both** `train.py` and `model.py`. + +Run this in a Python shell from the repo folder (`uv run python` or `python`): ```python import yaml @@ -300,10 +302,10 @@ from train import FruitDataset cfg = yaml.safe_load(open("confs/config.yml")) ds = FruitDataset(cfg["data_dir"], cfg) img, mask, name, label, idx = ds[0] -print(len(ds), len(ds.class_names)) # ~1969, 30 +print(len(ds), len(ds.class_names)) # 1584, 30 print(img.shape, img.min().item(), img.max().item()) # [3, 64, 64], ≈ -1, ≈ 1 print(mask.shape, mask.unique()) # [1, 64, 64], tensor([0., 1.]) -print(name, label) # e.g. Apple_Braeburn tensor(0) +print(name, label) # Apple_Gala tensor(0) ``` If `mask.unique()` shows only `0.` for most samples, the mask threshold or the file pairing is wrong. Fix that now, not after a 30-minute training run. @@ -788,13 +790,14 @@ Change **one thing at a time**. Each run gets its own `experiments/experiment_