Upload README.md
Browse files
README.md
CHANGED
|
@@ -1,26 +1,60 @@
|
|
| 1 |
-
|
| 2 |
-
tags:
|
| 3 |
-
- ml-intern
|
| 4 |
-
---
|
| 5 |
|
| 6 |
-
|
| 7 |
|
| 8 |
-
|
| 9 |
-
## Generated by ML Intern
|
| 10 |
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
|
| 14 |
-
- Source code: https://github.com/huggingface/ml-intern
|
| 15 |
|
| 16 |
-
|
|
|
|
| 17 |
|
| 18 |
-
|
| 19 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
```
|
| 25 |
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 籽粒分类模型(大米品种分类) / Grain Seed Classification Model
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
This repository contains the training script and (eventually) the fine-tuned model for classifying **rice grain varieties** from seed images.
|
| 4 |
|
| 5 |
+
## Dataset
|
|
|
|
| 6 |
|
| 7 |
+
- **Source:** [`nateraw/rice-image-dataset`](https://huggingface.co/datasets/nateraw/rice-image-dataset)
|
| 8 |
+
- **Size:** 75,000 RGB images (250×250)
|
| 9 |
+
- **Classes (5):**
|
| 10 |
+
1. Arborio
|
| 11 |
+
2. Basmati
|
| 12 |
+
3. Ipsala
|
| 13 |
+
4. Jasmine
|
| 14 |
+
5. Karacadag
|
| 15 |
+
- **License:** CC0-1.0
|
| 16 |
|
| 17 |
+
## Model
|
|
|
|
| 18 |
|
| 19 |
+
- **Architecture:** ResNet-18 (`microsoft/resnet-18`) — ~11M parameters, lightweight and fast
|
| 20 |
+
- **Task:** Multi-class image classification
|
| 21 |
|
| 22 |
+
## How to train
|
|
|
|
| 23 |
|
| 24 |
+
Run the provided script on a GPU (e.g. a10g-large or t4-small via Hugging Face Jobs, or Google Colab):
|
| 25 |
+
|
| 26 |
+
```bash
|
| 27 |
+
pip install transformers datasets torch accelerate evaluate pillow trackio
|
| 28 |
+
|
| 29 |
+
export HF_MODEL_REPO=chaosbee997/rice-seed-classifier
|
| 30 |
+
export HF_TOKEN=your_huggingface_token
|
| 31 |
+
|
| 32 |
+
python train.py
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
Or submit via Hugging Face Jobs (requires GPU credits):
|
| 36 |
+
|
| 37 |
+
```bash
|
| 38 |
+
huggingface-cli job run \
|
| 39 |
+
--script train.py \
|
| 40 |
+
--hardware a10g-large \
|
| 41 |
+
--timeout 4h \
|
| 42 |
+
--dependencies "transformers,datasets,torch,accelerate,evaluate,pillow,trackio"
|
| 43 |
```
|
| 44 |
|
| 45 |
+
## Expected results
|
| 46 |
+
|
| 47 |
+
- Typical fine-tuning on this dataset with ResNet-18 yields **> 95% accuracy** within 3-5 epochs.
|
| 48 |
+
|
| 49 |
+
## Extending to other crops
|
| 50 |
+
|
| 51 |
+
The same script works for any `datasets.ImageFolder`-style dataset. To add peanut, corn, wheat, etc.:
|
| 52 |
+
|
| 53 |
+
1. Collect or find an image dataset with folder-per-class structure.
|
| 54 |
+
2. Upload it to Hugging Face Hub or point `load_dataset` to a local path.
|
| 55 |
+
3. Update `MODEL_NAME` if you want a different backbone (e.g. `microsoft/resnet-34`, `google/mobilenet_v2_1.0_224`).
|
| 56 |
+
4. Run `train.py`.
|
| 57 |
+
|
| 58 |
+
## License
|
| 59 |
+
|
| 60 |
+
Apache-2.0
|