Inspiration

Every year farmers lose billions of dollars in the agricultural industry due to the lack of metrics on their farming methods. Without proper information on the best farming practices given the climate, geographic region, and chemical composition of the soil, many farmers end up growing the wrong type of crop on the wrong type of soil. As a result, they lose thousands of acres of crops each year to bad weather conditions and lack of soil nutrients.

Our app aims to provide a solution to the environmental crisis combatting the inefficiency of food production and the environmental hazards produced by overfarmed and overcultivated plots of land that damage irrigation and sap the soil of nutrients. When given some basic information about the weather and state of the soil, our app predicts which crop will yield the most product when harvested.

Soil erosion often stems from soil mismanagement that often involves the lack of proper crop-rotation, and understanding of the type of crop needed for a specific plot of soil. Through improper soil and water management, a soil's properties may be altered so that its fertility is seriously reduced or lost for good. Excessive cultivation, for example, can wreck the structure of some soils so that they are no longer capable of holding enough moisture for growing plants. Salinization, or the accumulation of salts in the topsoil, can also have a deletrious effect on soil productivity and crop yields. In extreme cases, damage from salinization is so great that it is technically unfeasible or totally uneconomic to reverse the process. Oftentimes, when a plot of farmland is poorly managed the blowing away of top soil can result.

Our app aims to provide a solution to this problem by providing machine-learning aided computational metrics in order to suggest potential crops to the farmer based on the specific geographic layout and chemical composition of his or her farmland. By analyzing a total of 7 factors, including pH values, the concentration of phosphorous, nitrogen, and potassium in the soil, as well as the temperature, humidity, and rainfall unique to the region, we are able to run a predictive model to generate a recommendation for the ideal crop to farm on that specific track of land.

What it does

Our project allows farmers to input typical farming data about soil and weather into our AI model, and our model predicts which food would grow the best based on the data given.

We also offer metrics on air pollution, water usage, as well as possible invasive species threats.

Our second machine learning algorithm also enables farmers to identify plant diseases based on computer vision techniques. When farmers upload an image of a plant into our webserver, we are able to identify between 26 different types of plant diseases and distinguish between healthy plants and infected crops that need to be removed or treated.

** The structure of the ML-model is displayed in the attached images. It is built upon transfer learning using ResNet and attains an accuracy of 99.2%

How we built it

We built our front-end based on two machine learning algorithms: the first algorithm analyzes a total of 7 factors, including pH values, the concentration phosphorous, nitrogen, potassium in the soil, as well as the temperature, humidity, and rainfall unique to the region, to run a predictive model to generate a recommendation for the ideal crop to farm on that specific track of land. We trained this algorithm on 6 different models: Decision Tree, Gaussian Naive Bayes, Logistic Regression, XGBoost, Support Vector Machine, and Random Forest Walk. We ultimately found Random Forest Walk to yield the highest accuracy at 99% for our dataset which we used in our final application.

**A full comparison of the accuracies of each of the 6 models is shown in the attached images.

The second machine learning algorithm analyzes user-input images. Using computer vision imaging software, we are able to extract features from images of plants, fruit trees, and other crops in order to identify them as healthy or pinpoint the specific plant disease based on the visual symptoms shown in the image.

For the backend, we set up a flask server to connect our machine learning algorithm to the live website and take in user text entry fields as the initial parameters to pass into our machine learning algorithm.

Challenges we ran into

The main challenge was getting our website connected to our machine learning algorithm. We tried several server hosting services, including Digital Ocean, flask, and heroku. We encountered some difficulty setting up the Digital Ocean server so we decided to try out flask instead. Implementing the flask localhost server, we were able to connect the machine learning algorithm to our main website and take in user entry fields from the front end, pass it into the machine learning algorithm, and return the computed output. We next attempted to move our localhost server onto a more permanent web server on heroku. However, we encountered some difficulties fully transferring our local functionality to the cloud and will definitely continue to seek improvements in this area in the future.

Another difficulty was related to the structuring of the css and html files due to the nature of the file structures required by heroku and flask. Since both services require a specially formatted file tree with a designated 'static' folder and 'template' folder for css and html respectively, we encountered difficulty getting our website to display properly when integrated with the flask server.

One of our teammates crashed their computer, causing many files to be locked away. We had to completely wipe the hard drive and factory restart the computer and remake most of the lost progress.

Accomplishments that we're proud of

We're proud of how far we have come in this project, being able to finish 6 different machine learning algorithms, build a UI, and launch a server in less than 12 hours is pretty impressive.

What we learned

We learned that oftentimes there are multiple approaches to solving the same problem. By testing out 6 different machine learning models to fit the data, we realized that brute forcing was not the solution and by trying out new ways of thinking, oftentimes we can come up with a model that fits the dataset even more accurately than before.

We also learned how to set up a server and connect the machine learning algorithm to the live website. This was the first time for many of us on the team were exposed to setting up servers and it was really exciting to see our final product come together!

What's next for Harvest

We are looking to continue developing an AI that detects plant diseases in the plants grown. That way, farmers would be aware of the disease and prevent them from infecting many other crops to increase farms' crop output further. We would also like to implement a third machine learning algorithm to estimate crop yield and crop price based on the number of acres of farmland and other geographic factors associated with the crop growth.

Built With

Share this project:

Updates