Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Sprint 7 merge #130

Merged
merged 71 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
8202243
Added a fork of google_maps with groundOverlays
RD211 Mar 18, 2023
8b5248e
Fix type id issue
nadinekuo Mar 18, 2023
c03b253
added simple ground overlay stretching for polygon
RD211 Mar 18, 2023
7471496
added logo
RD211 Mar 20, 2023
f2320d1
Fixed insights and timeline
RD211 Mar 22, 2023
61f1afc
Merge branch '113-firestore-data-achitecture-changes' of https://gith…
RD211 Mar 22, 2023
32aceef
Adding print for drawing markers
nadinekuo Mar 22, 2023
697b0c7
Merge branch '113-firestore-data-achitecture-changes' of https://gith…
nadinekuo Mar 22, 2023
2d8bcb3
fix eslint issue
nadinekuo Mar 22, 2023
4eb0c3e
dummy display of details
nadinekuo Mar 22, 2023
a509970
set initial camera position to delft
nadinekuo Mar 23, 2023
952e7bb
Display localized insights data
nadinekuo Mar 23, 2023
6224bc1
small changes trying to fix overlays
RD211 Mar 23, 2023
b5ace82
Fix nutrient deficiency display
nadinekuo Mar 23, 2023
8bad2b4
fix crop type list
nadinekuo Mar 23, 2023
bfda515
Merge branch '113-firestore-data-achitecture-changes' of https://gith…
RD211 Mar 23, 2023
fdc1c07
Made ui changes in every screen
RD211 Mar 23, 2023
28fc82f
added app icon
RD211 Mar 23, 2023
20c13d5
changed name of app
RD211 Mar 23, 2023
e414f8f
Merge pull request #124 from GDSC-Delft-Dev/119-app-general-redesign
nadinekuo Mar 24, 2023
dda5425
fix trailing field insights app bar
nadinekuo Mar 24, 2023
5276f96
hotfix overflowing map legend
nadinekuo Mar 24, 2023
e65b221
hotfix menu drawer
nadinekuo Mar 24, 2023
b61aff2
hotfix: coherent font sizes
nadinekuo Mar 24, 2023
6a8d9d5
add planting date to field model
nadinekuo Mar 24, 2023
36194c3
date picker for planting date
nadinekuo Mar 24, 2023
c90d921
set planting date
nadinekuo Mar 24, 2023
eaa8d75
save timestamp to firestore
nadinekuo Mar 24, 2023
d0e2889
remove print
nadinekuo Mar 24, 2023
5a8e6a3
update readme
nadinekuo Mar 24, 2023
e92d681
Merge pull request #125 from GDSC-Delft-Dev/110-date-of-planting
nadinekuo Mar 24, 2023
c3a7865
hotfix: remove hardcoded insight data
nadinekuo Mar 24, 2023
ea245c4
Merge branch 'dev' of https://github.com/GDSC-Delft-Dev/apa into 25-u…
RD211 Mar 24, 2023
52613e4
update readme
nadinekuo Mar 24, 2023
4d28982
turn off debug mode
nadinekuo Mar 24, 2023
2af654b
add more insight map options
nadinekuo Mar 24, 2023
887a772
Made switching ground overlays smoother
RD211 Mar 24, 2023
9c8ef4a
Merge pull request #126 from GDSC-Delft-Dev/25-user-can-select-insigh…
nadinekuo Mar 24, 2023
7d07943
added chatgpt and fixed memory hog
RD211 Mar 24, 2023
6a74ad0
Updated readme
RD211 Mar 25, 2023
c9f54f8
Added insight information
RD211 Mar 25, 2023
b4dfd9b
remove debug flag
nadinekuo Mar 25, 2023
06bb552
Merge branch 'chat_gpt_extra' of https://github.com/GDSC-Delft-Dev/ap…
nadinekuo Mar 25, 2023
2f5fe1d
Merge pull request #127 from GDSC-Delft-Dev/chat_gpt_extra
nadinekuo Mar 25, 2023
5419e00
initial setup
mirceatlx Mar 28, 2023
f30815c
insight creation
mirceatlx Mar 28, 2023
3edd9c0
disease insight
mirceatlx Mar 28, 2023
d463cb3
add docs
mirceatlx Mar 28, 2023
58ed8d8
fix mypy
mirceatlx Mar 28, 2023
757c325
change README
mirceatlx Mar 28, 2023
914fef7
modify background login screen
nadinekuo Mar 28, 2023
573823c
add index map for TCARI
nadinekuo Mar 29, 2023
15af79a
hotfix: adjust index map legends
nadinekuo Mar 29, 2023
d890de2
hotfix: new screenshots in frontend readme
nadinekuo Mar 29, 2023
078b900
hotfix: new screenshots in frontend readme
nadinekuo Mar 29, 2023
a22ab44
restructure
mirceatlx Mar 29, 2023
65617cf
create pipeline for disease detection
mirceatlx Mar 30, 2023
04ea685
fix mypy
mirceatlx Mar 30, 2023
3c76c15
add comments
mirceatlx Mar 30, 2023
f125d38
Merge branch 'dev' into 109-detect-pests-and-diseases-from-close-up-i…
mirceatlx Mar 30, 2023
5dd8b51
Merge pull request #128 from GDSC-Delft-Dev/109-detect-pests-and-dise…
mirceatlx Mar 30, 2023
8ecb113
training files
mirceatlx Mar 30, 2023
40b5572
add module
mirceatlx Mar 30, 2023
627275e
pylint fix
mirceatlx Mar 30, 2023
0164e71
add tests
mirceatlx Mar 30, 2023
160c37c
cloud training
mirceatlx Apr 3, 2023
e8a5db5
fix mypy and pylint
mirceatlx Apr 4, 2023
3e6fb93
fix mypy and pylint
mirceatlx Apr 4, 2023
e901136
Merge pull request #129 from GDSC-Delft-Dev/111-detect-pests-and-dise…
paulmis Apr 4, 2023
82a85e0
revamp main readme
paulmis Apr 4, 2023
8146971
move backend readme
paulmis Apr 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ src/backend/pipeline/data
.vscode
*json
nutrient_masks.npy
PlantVillage
.vscode
.idea
169 changes: 120 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,97 +3,168 @@

![example workflow](https://github.com/GDSC-Delft-Dev/apa/actions/workflows/pipeline.yml/badge.svg)

## About
Terrafarm is an autonomous farming solution provides a comprehensive way to monitor crops at any scale. We provide farmers with the ability to scrutinize every square inch of their fields for a wide range of issues. By detecting crop diseases before they spread, Terrafarm can reduce the usage of harmful chemicals by up to 90% and eradicate invasive species regionally. As the application provides health reports, farmers can optimize fertilizer use and reduce preventive pesticide, herbicide, and fungicide use.

### Problem we solving
Growing (high-quality) crops sustainably for an ever-increasing population is one of the biggest challenges we face today, as farmers all over the world are faced with complex decision making problems for a vast amount of crops. To this end, a variety of parameters need to be traced - think of application of fertilizer, soil humidity or availability of nutrients.
Want to know more? Read our wiki [**here**](../../wiki).

In traditional agriculture, fields are treated as homogeneous entities, which generally leads to sub-optimal treatment due to lack of (localized) traceability. This is problematic, as oversupply of agricultural inputs leads to environmental pollution. Moreover, unnecessary large quantities can go to waste if produce are not harvested at their optimal time. Finally, this clearly leads to low yield density and hence missed profits for farmers.
## Getting Started

[Precision agriculture](https://en.wikipedia.org/wiki/Precision_agriculture) on the other hand, aims to produce more crops with fewer resources while maintaining quality. This sustainable agricultural model utilizes IT solutions to allow for localized treatment to a much finer degree. This paradigm shift is becoming increasingly urgent because of the worldwide increase in food demands for example: the number of people who will require food in 2050 is estimated at nine billion.
Our code can be found in the `src` directory. Read below to learn how to explore, run, and modify the backend and frontend, or play with the notebooks in the `notebooks` directory.

### Our solution
Our **mobile app Terrafarm** allows farmers to perform **smart monitoring, analysis and planning** in an intuitive and affordable manner. In fact, our system uses **image processing and deep learning** to extact **actionable insights** from multispectral drone images. These insights - think of pest infestations, moisture content or nutrient deficiencies - are visualized to users, thereby providing full transparancy. We aim to target both small- and medium-scale farmers. Detailed information about our image processing pipeline and Flutter mobile app can be found under `apa/src/backend` and `apa/src/frontend` respectively.
### Backend

<div>
<img src="assets/Terrafarm-poster-0.jpg" alt="Image 1" width="500" style="display:inline-block;">
<img src="assets/Terrafarm-poster-1.jpg" alt="Image 2" width="500" style="display:inline-block;">
</div>
The backend comprises of the image processing pipleline that processes mutlispectral images from farms. You can run it locally, or remotely on GCP (in a container). If you'd like to know more about the pipeline, read our wiki [**here**](../../wiki/Pipeline).

<p style="text-align:center;">Figure: Information poster presenting Terrafarm</p>
#### Local setup
Run the image processing pipeline locally. Tested on linux (`Ubuntu 20`) and Mac (`Ventura 13`). Components that do not involve ML training can also be run on `Windows 10`.

1. Install [**Python 3.10**](https://www.python.org/downloads/)

2. Clone the repo

# Build Tools
```
git clone https://github.com/GDSC-Delft-Dev/apa.git
```

![image](https://img.shields.io/badge/Flutter-02569B?style=for-the-badge&logo=flutter&logoColor=white)
</br>
![image](https://img.shields.io/badge/Dart-0175C2?style=for-the-badge&logo=dart&logoColor=white)
</br>
![image](https://img.shields.io/badge/Python-FFD43B?style=for-the-badge&logo=python&logoColor=blue)
</br>
![image](https://img.shields.io/badge/firebase-ffca28?style=for-the-badge&logo=firebase&logoColor=black)
</br>
![image](https://img.shields.io/badge/Google_Cloud-4285F4?style=for-the-badge&logo=google-cloud&logoColor=white)
</br>
![image](https://img.shields.io/badge/TensorFlow-FF6F00?style=for-the-badge&logo=tensorflow&logoColor=white)
</br>
![image](https://img.shields.io/badge/OpenCV-27338e?style=for-the-badge&logo=OpenCV&logoColor=white)
</br>
![image](https://img.shields.io/badge/GitHub_Actions-2088FF?style=for-the-badge&logo=github-actions&logoColor=white)
Note that this might take a while.

# Getting Started
3. Setup the Python virtual environment
```
pip install virtualenv
virtualenv env
source env/bin/activate (linux, mac)
source env/Scripts/activate (windows)
```

4. Install Python requirements
```
cd src/backend
pip install -r requirements.txt
```

5. Run the pipeline
```
py main.py
```

The supported arguments for `main.py` are:
- `mode` (`local`/`cloud`) - specify if the input images are already in the cloud or need to be uploaded first from the local filesystem
- `path` - path to the input images, relative to the local/cloud root
- `name` - a unique name for the created job

Run the pipeline with images already in the cloud:
```
py main.py --path path/to/images --mode cloud
```

Run the pipeline with images on your local filesystem:
```
py main.py --path path/to/images --mode local
```

Follow these steps to set up your project locally.
#### Cloud setup
To use infrastructure, please request the GCP service account key at `pawel.mist@gmail.com`.

Clone the repo
1. Clone the repo
```
git clone https://github.com/GDSC-Delft-Dev/apa.git
```

## Setup backend
Note that this might take a while.

Setup virtual python environment
2. Set the GCP service account environmental variable
```
pip install virtualenv
virtualenv env
export GCP_FA_PRIVATE_KEY=<key> (linux, mac)
set GCP_FA_PRIVATE_KEY=<key> (windows)
```

Activate on MacOS or Linux
3. Trigger the pipeline

Manual triggers allow you to run the latest pipeline builds from the Artifact Registry with custom input data using Cloud Run. You can run a job with either input data from your local file system or input data that already resides in the cloud.

```bash
cd src/backend
sudo chmod +x trigger.sh
./trigger.sh
```

The supported arguments for `trigger.sh` are:
- `l` - path to the local images
- `c` - path to the images on the cloud (Cloud Storage)
- `n` - a unique name for the pipeline job

Note that local inputs are first copied to a staging directory in Cloud Storage, and will only be removed if the job succeeeds.

Provide input data from a local filesystem

```bash
./trigger.sh -l /path/to/data/ -n name-of-the-job
```
source env/bin/activate

Provide input data from Cloud Storage

```bash
./trigger.sh -c /path/to/data/ -n name-of-the-job
```

Activate on Windows
### Testing
To executed the automated tests, run `pytest` unit tests:

```
source env/Scripts/activate
python -m pytest
```
Install Python requirements

You can find our tests in `src\backend\pipeline\test\unit`.

### Static analysis
Our project uses `mypy` and `pylint` to assert the quality of the code. You can run these with:

```
pip install -r requirements.txt
python -m mypy . --explicit-package-bases
python -m pylint ./pipeline
```
Please refer to `apa/src/backend/README.md` for detailed information on the image processing pipeline.
<!-- TODO: Perhaps more info? -->

## Setup frontend
Please refer to `apa/src/frontend/README.md`.
### CI/CD
The CI/CD pushes the build from the latest commit to the `pipelines-dev` repository in the Google Artifact Registry. Note that only the backend is covered.

You can find the pipeline declaration in `.github\workflows\pipeline.yml`.

## Frontend setup
Please refer to `apa/src/frontend/README.md`.

# Contributing
## Contributing
Anyone who is eager to contribute to this project is very welcome to do so. Simply take the following steps:
1. Fork the project
2. Create your own feature branch
3. Commit your changes
4. Push to the `dev` branch and open a PR

# Datasets
## Datasets
You can play with the datasets in the `notebooks` folder.

## Build Tools

![image](https://img.shields.io/badge/Flutter-02569B?style=for-the-badge&logo=flutter&logoColor=white)
</br>
![image](https://img.shields.io/badge/Dart-0175C2?style=for-the-badge&logo=dart&logoColor=white)
</br>
![image](https://img.shields.io/badge/Python-FFD43B?style=for-the-badge&logo=python&logoColor=blue)
</br>
![image](https://img.shields.io/badge/firebase-ffca28?style=for-the-badge&logo=firebase&logoColor=black)
</br>
![image](https://img.shields.io/badge/Google_Cloud-4285F4?style=for-the-badge&logo=google-cloud&logoColor=white)
</br>
![image](https://img.shields.io/badge/TensorFlow-FF6F00?style=for-the-badge&logo=tensorflow&logoColor=white)
</br>
![image](https://img.shields.io/badge/OpenCV-27338e?style=for-the-badge&logo=OpenCV&logoColor=white)
</br>
![image](https://img.shields.io/badge/GitHub_Actions-2088FF?style=for-the-badge&logo=github-actions&logoColor=white)


# License
## License
Distributed under the MIT License. See `LICENSE.txt` for more information.

# Contact
## Contact
- Google Developers Student Club Delft - dsc.delft@gmail.com
- Paul Misterka - pawel.mist@gmail.com
- Mircea Lica - mirceatlx@gmail.com
Expand Down
Binary file added assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/logo_with_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
127 changes: 0 additions & 127 deletions src/backend/README.md

This file was deleted.

4 changes: 2 additions & 2 deletions src/backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import argparse
from pipeline.mat import Mat
from google.cloud import storage
from pipeline.templates import full_pipeline, default_pipeline, training_pipeline, nutrient_pipeline
from pipeline.templates import full_pipeline, default_pipeline, training_pipeline, nutrient_pipeline, disease_pipeline
import asyncio
from pipeline.config import CloudConfig
from typing import Any
Expand Down Expand Up @@ -55,7 +55,7 @@ def main(args: Any):
imgs = [Mat.read(file) for file in sorted(glob.glob("pipeline/data/D*.JPG"))]

# Get test data
imgs = imgs[:3]
imgs = imgs[:min(len(imgs), 3)]

# Run the pipeline
pipeline = nutrient_pipeline(cloud=cloud_config)
Expand Down
Loading