Initialize PlantGuard AI scaffold: data pipeline, models, experiments, docs, and lint CI - #2
Initialize PlantGuard AI scaffold: data pipeline, models, experiments, docs, and lint CI#2TrstnSnhn wants to merge 3 commits into
Conversation
|
new pull request |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 51f740e8fe
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| python src/data_pipeline.py --action split --seed 42 | ||
|
|
||
| echo "=== Step 3: Train Non-DL Baseline ===" | ||
| python src/train.py --config experiments/configs/baseline_sklearn.yaml |
There was a problem hiding this comment.
Remove unsupported sklearn config from run pipeline
Step 3 runs python src/train.py --config experiments/configs/baseline_sklearn.yaml, but build_model in src/train.py only supports simple_cnn and resnet18 while this config sets architecture: sklearn_rf. With set -e, this deterministic mismatch raises ValueError and aborts the pipeline before later training/evaluation steps, so the documented quick-start flow cannot complete.
Useful? React with 👍 / 👎.
|
|
||
| model = build_model(cfg).to(device) | ||
| criterion = nn.CrossEntropyLoss() | ||
| optimizer = torch.optim.Adam(model.parameters(), lr=cfg["training"].get("lr_unfrozen", 1e-3)) |
There was a problem hiding this comment.
Use frozen-phase learning rate before unfreezing
The initial optimizer is always created with training.lr_unfrozen even though ResNet training immediately freezes the backbone and configs define a separate training.lr_frozen. For example, resnet18_default.yaml provides different frozen/unfrozen rates, so this line runs the frozen phase at the wrong LR and undermines LR-sensitive experiments/ablations.
Useful? React with 👍 / 👎.
| for epoch in range(1, total_epochs + 1): | ||
| if cfg["model"]["architecture"] == "resnet18" and epoch == cfg["model"].get("freeze_epochs", 5) + 1: | ||
| model.unfreeze_backbone() | ||
| optimizer = torch.optim.Adam(model.parameters(), lr=cfg["training"].get("lr_unfrozen", 1e-4)) |
There was a problem hiding this comment.
Rebind scheduler after replacing optimizer
When the model unfreezes, a brand-new optimizer is assigned, but the existing ReduceLROnPlateau scheduler still points to the old optimizer created earlier. From that point onward, scheduler.step(val_loss) updates stale parameter groups while the active optimizer keeps a fixed LR, so LR scheduling stops working during the unfrozen training stage.
Useful? React with 👍 / 👎.
Motivation
Description
README.md,LICENSE(MIT),docs/*placeholders, and Jupyter notebook scaffolds undernotebooks/.data/get_data.pyfor downloading/validating PlantVillage, andsrc/data_pipeline.pyfor splitting and creating dataloaders.src/models/containsresnet_finetune.py,cnn_from_scratch.py,nlp_classifier.py, andsrc/train.py,src/eval.py,src/gradcam.py,src/nlp_pipeline.py,src/rl_agent.pyfor tasks and placeholder outputs.src/utils/, experiment configs underexperiments/configs/, placeholder results inexperiments/results/,requirements.txt, and a top-levelrun.shscript to run the full pipeline; add a GitHub Actions lint workflow/.github/workflows/lint.ymlusingruff.Testing
/.github/workflows/lint.ymlthat runsruff check .(workflow added but not executed in this PR).python src/eval.py --all(wroteexperiments/results/eval_summary.json),python src/gradcam.py(wroteexperiments/results/gradcam_samples.png),python src/nlp_pipeline.py --action train(trained TF-IDF + LogisticRegression on seed data and wroteexperiments/results/nlp_metrics.json), andpython src/rl_agent.py --episodes 5(wroteexperiments/results/rl_learning_curve.png).Codex Task