{"id":29976143,"url":"https://github.com/shama-llama/cropland-mapping","last_synced_at":"2026-05-13T12:33:41.371Z","repository":{"id":279057826,"uuid":"937603963","full_name":"shama-llama/cropland-mapping","owner":"shama-llama","description":"Cropland mapping from multichannel spectral data using deep learning","archived":false,"fork":false,"pushed_at":"2025-08-03T10:56:23.000Z","size":33473,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-03T12:30:34.022Z","etag":null,"topics":["computer-science","conv-lstm","cosc-6041","cropland-mapping","machine-learning"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shama-llama.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-23T13:26:18.000Z","updated_at":"2025-08-03T10:56:26.000Z","dependencies_parsed_at":"2025-02-23T14:29:03.852Z","dependency_job_id":"b742d1d4-4a6a-44f5-8ef0-a9c6a44cdfeb","html_url":"https://github.com/shama-llama/cropland-mapping","commit_stats":null,"previous_names":["shama-llama/crop-mapping","shama-llama/cropland-mapping"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/shama-llama/cropland-mapping","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shama-llama%2Fcropland-mapping","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shama-llama%2Fcropland-mapping/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shama-llama%2Fcropland-mapping/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shama-llama%2Fcropland-mapping/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shama-llama","download_url":"https://codeload.github.com/shama-llama/cropland-mapping/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shama-llama%2Fcropland-mapping/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32982802,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T11:31:52.688Z","status":"ssl_error","status_checked_at":"2026-05-13T11:31:52.072Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computer-science","conv-lstm","cosc-6041","cropland-mapping","machine-learning"],"created_at":"2025-08-04T08:43:00.602Z","updated_at":"2026-05-13T12:33:41.365Z","avatar_url":"https://github.com/shama-llama.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cropland Mapping\n\n[![Python](https://img.shields.io/badge/Python-3.12+-3776AB?logo=python\u0026logoColor=white)](https://docs.python.org/3.12/)\n[![PyTorch](https://img.shields.io/badge/PyTorch-2.7+-EE4C2C?logo=pytorch\u0026logoColor=white)](https://docs.pytorch.org/docs/2.7/)\n[![Scikit-learn](https://img.shields.io/badge/Scikit--learn-1.7+-F7931E?logo=scikit-learn\u0026logoColor=white)](https://scikit-learn.org/stable/whats_new/v1.7.html)\n[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/shama-llama/cropland-mapping/blob/main/notebooks/cmap_msi.ipynb)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nThis project uses a deep learning framework for crop classification using multichannel inputs from Sentinel-2, combining high-resolution RGB imagery with vegetation indices (VIs) such as NDVI and GNDVI to capture both spatial and phenological crop characteristics. The model used is a convolutional long short-term memory (ConvLSTM) architecture to process time-series sequences of fused sensor data that integrates spatial features and temporal dependencies across multiple seasons. Input normalization, channel-wise sensor fusion, and data augmentation are used to mitigate class imbalance inherent in the dataset. It is evaluated on the [Canadian Cropland Dataset](https://github.com/bioinfoUQAM/Canadian-cropland-dataset-github) and the model achieves ~90% classification accuracy.\n\n## Architecture\n\n![Model Architecture](/diagram/diagram.png)\n\n## Findings\n\n| Class | Precision | Recall | F1-Score | Support |\n| :--- | :--- | :--- | :--- | :--- |\n| BARLEY | 0.82 | 0.75 | 0.78 | 36 |\n| CANOLA | 0.94 | 0.97 | 0.96 | 66 |\n| CORN | 0.89 | 0.91 | 0.90 | 55 |\n| MIXEDWOOD | 0.94 | 1.00 | 0.97 | 32 |\n| OAT | 0.91 | 0.88 | 0.89 | 67 |\n| ORCHARD | 0.98 | 0.92 | 0.95 | 51 |\n| PASTURE | 0.86 | 0.91 | 0.89 | 47 |\n| POTATO | 0.90 | 0.94 | 0.92 | 67 |\n| SOYBEAN | 0.94 | 0.89 | 0.92 | 104 |\n| SPRING_WHEAT | 0.56 | 0.71 | 0.62 | 7 |\n| **Accuracy** | | | **0.91** | **532** |\n| **Macro Avg** | **0.87** | **0.89** | **0.88** | **532** |\n| **Weighted Avg** | **0.91** | **0.91** | **0.91** | **532** |\n\n\u003e There is visible overfitting starting from the 4th epoch onwards which should be addressed in later works.\n\n## Project Setup\n\nThis project uses `uv` for package management. `uv` is an extremely fast Python package and project manager, written in Rust that can be used as a drop-in replacement for `pip`, `pip-tools`, `pipx`, `poetry`, `pyenv`, `twine`, `virtualenv`.\n\n- **`uv` Installation**\n\n    ```bash\n    curl -LsSf https://astral.sh/uv/install.sh | sh\n    ```\n\n- **Clone the Repository:**\n\n    ```bash\n    git clone https://github.com/shama-llama/cropland-mapping.git\n    cd cropland-mapping\n    ```\n\n- **Create a Virtual Environment and Install Dependencies with `uv`:**\n\n    ```bash\n    uv venv\n    uv pip install -e .\n    ```\n\n- **Activate the Virtual Environment:**\n\n    ```bash\n    source .venv/bin/activate\n    ```\n\n- **Launch Jupyter Notebook:**\n\n    ```bash\n    jupyter notebook\n    ```\n\n    Navigate to the `notebooks/` directory to run the analysis.\n\n## Notebooks\n\n- `cmap_dataset.ipynb`: Data preparation with minor preprocessing and loading into HDF5 for better portability.\n- `cmap_eda.ipynb`: Exploratory data analysis.\n- `cmap_msi.ipynb`: ConvLSTM model training and evaluation.\n\n## Model\n\nThe trained ConvLSTM model weights are saved in the `models/` directory.\n\n```python\ntorch.device('cuda' if torch.cuda.is_available() else 'cpu')\nmodel.load_state_dict(torch.load('models/best_model.pth', map_location=device))\n```\n\n## References\n\n\u003e A. A. B. Jacques, A. B. Diallo, and E. Lord, “The Canadian Cropland Dataset: A New Land Cover Dataset for Multitemporal Deep Learning Classification in Agriculture,” June 04, 2023, arXiv: arXiv:2306.00114. doi: [10.48550/arXiv.2306.00114](https://doi.org/10.48550/arXiv.2306.00114).\n\u003e\n\u003e M. O. Turkoglu et al., “Crop mapping from image time series: Deep learning with multi-scale label hierarchies,” Remote Sensing of Environment, vol. 264, p. 112603, Oct. 2021, doi: [10.1016/j.rse.2021.112603](https://doi.org/10.1016/j.rse.2021.112603).\n\u003e\n\u003e D. Darwish, “Improving Techniques for Convolutional Neural Networks Performance,” European Journal of Electrical Engineering and Computer Science, vol. 8, pp. 1–16, Jan. 2024. Number: 1.\n\u003e\n\u003e J. M. Johnson and T. M. Khoshgoftaar, “Survey on deep learning with class imbalance,” Journal of Big Data, vol. 6, pp. 1–54, Dec. 2019. Number: 1 Publisher: SpringerOpen.\n\u003e\n\u003e C. Shorten and T. M. Khoshgoftaar, “A survey on Image Data Augmentation for Deep Learning,” Journal of Big Data, vol. 6, pp. 1–48, Dec. 2019. Number: 1 Publisher: SpringerOpen.\n\n## License\n\nThis project is licensed under the terms of the [MIT](LICENSE) open source license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshama-llama%2Fcropland-mapping","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshama-llama%2Fcropland-mapping","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshama-llama%2Fcropland-mapping/lists"}