|
Download README.md from anonymoussubmission257/CropCode: direct link, hf CLI and curl.
- Browser
- Download file 7.23 kB
-
https://huggingface.co/anonymoussubmission257/CropCode/resolve/main/README.md
- Command line
-
hf download hf://anonymoussubmission257/CropCode/README.md
-
curl -L -o README.md https://huggingface.co/anonymoussubmission257/CropCode/resolve/main/README.md
7.23 kB
| license: apache-2.0 | |
| library_name: pytorch | |
| tags: | |
| - plant-phenotyping | |
| - point-cloud | |
| - 3d-reconstruction | |
| - multimodal | |
| - masked-autoencoder | |
| - agriculture | |
| # CropCode: inference models | |
| Models from the CropCode paper for sorghum and maize. Each model reads a photograph, a depth image and a point | |
| cloud of a plant (any one of them is enough) and writes the plant's point cloud and its procedural parameters: | |
| plant height, leaf count and one record per leaf. This repository holds the six models meant for use, sample | |
| inputs for each, and a short script that runs them. Training and evaluation code: | |
| <https://anonymous.4open.science/r/CropCode>. | |
| ## Models | |
| | model | species | what it does | epoch | | |
| |---|---|---|---| | |
| | `sorghum-generalist` | sorghum | Single plant: any one stream (photo, depth or point cloud) in, the plant cloud and its procedural parameters out (Stage 2, distilled generalist) | 100 | | |
| | `sorghum-row` | sorghum | Crop rows: the centre plant reconstructed from a view of the whole row, neighbours included (Stage 3, row fine-tune) | 100 | | |
| | `sorghum-field` | sorghum | Field rows of real plants: the row model fine-tuned on field data; also writes the leaf count | 26 | | |
| | `maize-generalist` | maize | Single plant: any one stream (photo, depth or point cloud) in, the plant cloud and its procedural parameters out (Stage 2, distilled generalist) | 100 | | |
| | `maize-row` | maize | Crop rows: the centre plant reconstructed from a view of the whole row, neighbours included (Stage 3, row fine-tune) | 100 | | |
| | `maize-field` | maize | Field rows of real plants: the row model fine-tuned on field data | 26 | | |
| All models are ViT-Base (114 M parameters, fp32 safetensors, 457 MB each). The `-generalist` models work on a | |
| single isolated plant. The `-row` models reconstruct the centre plant of a crop row with its neighbours in view. | |
| The `-field` models are the row models fine-tuned on field rows of real plants. | |
| ## Quick start | |
| ```bash | |
| pip install -r requirements.txt | |
| python inference.py --list | |
| python inference.py --model sorghum-generalist --sample samples/sorghum/plant_Sorghum_10756 --source rgb | |
| python inference.py --model maize-field --sample samples/maize/field_0204_row0936_stop06 | |
| ``` | |
| `--source all` shows the model every stream at the masked ratio it was trained with; `--source rgb`, `depth` or | |
| `pc` gives it that stream alone. The script writes `pred_cloud.ply` (metres, centred like the input cloud), | |
| `recipe.json` (the procedural parameters) and `summary.json` (Chamfer distance, height and leaf count against the | |
| truth when the sample has it). | |
| ## Samples | |
| One isolated plant, one simulated crop row and one field stop per species, all from held-out test plants. | |
| | species | kind | folder | item | models | | |
| |---|---|---|---|---| | |
| | sorghum | plant | `samples/sorghum/plant_Sorghum_10756` | Sorghum_10756, view 00 (test split) | sorghum-generalist | | |
| | sorghum | row | `samples/sorghum/row_Sorghum_10756_yaw90` | Sorghum_10756, simulated row seen at yaw 90 deg, two neighbours (test split) | sorghum-row | | |
| | sorghum | field | `samples/sorghum/field_p1d2V_329956_row0280_stop10` | field row 280, camera stop 10, middle plant p1d2V_329956 (held-out test plant) | sorghum-row, sorghum-field | | |
| | maize | plant | `samples/maize/plant_0320` | plant_0320, view 00 (test split) | maize-generalist | | |
| | maize | row | `samples/maize/row_plant_0320_yaw90` | plant_0320, simulated row seen at yaw 90 deg, two neighbours (test split) | maize-row | | |
| | maize | field | `samples/maize/field_0204_row0936_stop06` | field row 936, camera stop 6, middle plant 0204 (held-out test plant) | maize-row, maize-field | | |
| Each sample folder holds: | |
| - `inputs.npz`: the tensors the model reads, written by the training loaders. `rgb` (3, 224, 224) is | |
| ImageNet-normalised with the plant on black; `depth` (1, 224, 224) is the encoded depth, 0 for background; `pc` | |
| (N, 3) is the cloud centred and scaled to the unit sphere; `scale` gives metres per unit. When known, the | |
| truth: `gt_pc` (the target plant's cloud in the same frame), `height_m` and `leaves`. | |
| - `raw/`: the original files of the item (photograph, depth image, point clouds, the parameter file or plant table). | |
| - `input_rgb.png` and `preview.png` (input photo, depth and the predicted procedural model). | |
| - `reference/<model>__<source>/`: the outputs of `inference.py` on CPU with seed 0, to check a setup against. A | |
| rerun gives the same numbers; the clouds can differ in the last float digits (a few micrometres) with the | |
| number of CPU threads. | |
| To run a model on your own data, prepare `inputs.npz` the same way. The loaders in the code repository | |
| (`sorghum_dataset_4m.py`, `maize_dataset_4m.py`, `row_dataset.py`, `eval/real_rows.py`) do the conversion. The | |
| procedural parameters are never an input: the script passes zeros in their place. | |
| ## Reference results on the samples | |
| Chamfer distance in 1e-4 m^2 against the truth cloud, height in metres and leaf count as predicted / true. | |
| Rows: all three streams in, and for the isolated plants each stream alone. Full table: | |
| `samples/reference_results.csv`. These are single items, not benchmark numbers; the paper reports the test sets. | |
| | species | kind | model | input | Chamfer | height | leaves | | |
| |---|---|---|---|---|---|---| | |
| | sorghum | plant | `sorghum-generalist` | all | 12.83 | 0.63 / 0.66 | 13 / 13 | | |
| | sorghum | plant | `sorghum-generalist` | rgb | 6.32 | 0.66 / 0.66 | 13 / 13 | | |
| | sorghum | plant | `sorghum-generalist` | depth | 3.22 | 0.65 / 0.66 | 13 / 13 | | |
| | sorghum | plant | `sorghum-generalist` | pc | 7.73 | 0.62 / 0.66 | 12 / 13 | | |
| | sorghum | row | `sorghum-row` | all | 27.9 | 0.73 / 0.66 | 15 / 13 | | |
| | sorghum | field | `sorghum-row` | all | 257.7 | 1.22 / 2.00 | 24 / 14 | | |
| | sorghum | field | `sorghum-field` | all | 56.69 | 1.89 / 2.00 | 13 / 14 | | |
| | maize | plant | `maize-generalist` | all | 5.42 | 1.09 / 1.18 | 11 / 11 | | |
| | maize | plant | `maize-generalist` | rgb | 4.57 | 1.05 / 1.18 | 11 / 11 | | |
| | maize | plant | `maize-generalist` | depth | 2.89 | 1.08 / 1.18 | 11 / 11 | | |
| | maize | plant | `maize-generalist` | pc | 3.3 | 1.11 / 1.18 | 11 / 11 | | |
| | maize | row | `maize-row` | all | 2.41 | 1.13 / 1.18 | 11 / 11 | | |
| | maize | field | `maize-row` | all | 212.46 | 1.01 / 1.91 | 12 / 11 | | |
| | maize | field | `maize-field` | all | 52.37 | 1.77 / 1.91 | 11 / 11 | | |
| ## Notes | |
| - Reconstruction with `--source all` runs in the masked regime the models were trained in (80 % of tokens hidden, | |
| seeded by `--seed`). Different seeds give slightly different clouds. | |
| - The sorghum models read photographs at the brightness they were trained on; the loaders handle this, and the | |
| samples are stored that way. | |
| - The sorghum field model reads a leaf count from its leaf slots (slots longer than 5 cm). The other sorghum | |
| models write 24 leaf slots and derive the count from the stem length, as in the simulated plants. | |
| - Synthetic training data: 15,000 procedurally generated plants per species, ten views each. Field rows: real | |
| plants (maize: 520 scanned plants; sorghum: 51 scans), split by plant for fine-tuning and testing. | |
| ## License | |
| The models, code and samples in this repository are released under the Apache License 2.0 (`LICENSE`). | |
| `SHA256SUMS` lists a checksum for every file. | |