GithubHelp home page GithubHelp logo

rishit-dagli / greenathon-plant-ai Goto Github PK

View Code? Open in Web Editor NEW
73.0 6.0 21.0 46.6 MB

Identify Diseases in Plants☘️ with Machine Learning on the web using TFJS

Home Page: https://www.plant-ai.tech/

License: Apache License 2.0

Jupyter Notebook 79.09% HTML 1.46% JavaScript 12.81% CSS 6.64%
machine-learning tensorflow tensorflowjs madewithtfjs react webapp greentech green reactjs tensorflow-js

greenathon-plant-ai's Introduction

Cover Image

Greenathon-Plant-AI🌱 Twitter URL

Launch Web App Models TF Hub Azure Static Web Apps CI/CD Lint Code Base

GitHub license GitHub stars GitHub forks

This is a web application🌐 which could help easily diagnose diseases in plants 🌱 using Machine Learning all on the web, powered by TensorFlow JS.

You can use and test the latest web app from below 👇

Launch Example

About 🔮

  • Creates a TensorFlow Model for identifying plant diseases
  • Creates optimized TensorFlow JS Models
  • Uses TensorFlow JS to perform inferences on-device
  • Creates a fully functional web app using React
  • Exposes a hosted API built with TensorFlow Serving for inferences from the TensorFlow Model

UI Design 🎨

Click to View Plant AI web app Design from below

Plant AI Design

About the Notebooks

Open In Colab Binder

This notebook contains the code to train a model on the PlantVillage dataset to identify diseases from plant images. Here we provide a subset of our experiments on working with this data. Finally we export our model as a TensorFlow SavedModel.

Open In Colab Binder

This notebook shows the the process of converting the TensorFlow SavedModel we built in the prequel notebook to the TFJS format for the Plant AI model. It also shows performing optimizations on this.

Open In Colab Binder

This notebook shows the the process of converting the TensorFlow SavedModel we built in the prequel notebook to the TF Lite format for the Plant AI model.

Run Locally

To get up and running with this web-app, run the following commands, make sure you have Node.js installed. This runs the app in development mode:

git clone https://github.com/Rishit-dagli/Greenathon-Plant-AI # or clone your own fork
cd Greenathon-Plant-AI
npm install
npm start

Your app should now be running on localhost:3000 🚀.

Lint ✅

This project uses GitHub Super Linter which is Combination of multiple linters to install as a GitHub Action.

Following Linters are used internally by super linter (enabled for this project):

Want to Contribute 🙋‍♂️?

Awesome! If you want to contribute to this project, you're always welcome! See Contributing Guidelines. You can also take a look at Greenathon-Plant-AI's Project Status Tracker for getting more information about current or upcoming tasks.

Want to discuss? 💬

Have any questions, doubts or want to present your opinions, views? You're always welcome. You can start discussions.

Contributors

Citations

@misc{hughes2016open,
      title={An open access repository of images on plant health to enable the development of mobile disease diagnostics}, 
      author={David. P. Hughes and Marcel Salathe},
      year={2016},
      eprint={1511.08060},
      archivePrefix={arXiv},
      primaryClass={cs.CY}
}

License

Copyright 2020 Rishit Dagli

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

greenathon-plant-ai's People

Contributors

imgbot[bot] avatar mindninjax avatar rishit-dagli avatar ruchayagnik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

greenathon-plant-ai's Issues

Unhandled Rejection (TypeError): Failed to fetch

Describe the bug
Error when doing

let response = await fetch('https://coverimages.blob.core.windows.net/plantai-tfjs-model/class_indices.json');

To Reproduce
Steps to reproduce the behavior:

  1. Run npm start
  2. Click on "Try now"
  3. See the error

Expected behavior
Idk, this is the first time I'm using this

Screenshots
screenshot

Desktop (please complete the following information):

  • OS: [CHrome OS]
  • Browser [chrome]
  • Version 108.0.5359.172 (Official Build) (64-bit)

Additional context
Add any other context about the problem here.

Demo link not working

Describe the bug
Demo link doesn't work

To Reproduce
Steps to reproduce the behavior:

  1. Go to www.plant-ai.tech/
  2. See error

Expected behavior
I haven't seen the website ever, but the expected behavior is a website.

Screenshots
Screenshot 2023-02-05 8 14 31 AM

I don't think it matters which device.

Minor UI Bugs

After #17 , minor UI bugs were found:

  • Fix "Learn More" Card text vertical alignment
  • Adjust "Learn More" Card image width
  • Result Page Overflow issue in mobile devices
  • Irregular image width issue in the "Learn More" section

Model doesn't predict the correct label even when the input is from the dataset through Phone's Camera

Describe the bug
I am running the model on React Native. I input the image taken from the phone's camera into the model, and almost always get an incorrect label. The Input itself is pictures taken from the dataset via my Phone's Camera.

Steps to Reproduce

  1. I open the picture of the leaf on my laptop screen (from Kaggle)
  2. I take its picture from the phone's camera.
  3. Output is incorrect class index.

Screenshots
I am attaching the inputs to the model as it is.

Input 1

59a4ea4f-d82f-4ff0-926c-562733639b1e

Input 2

ff56aeb9-965e-47b8-a35b-912da6dffbc0

Output of Input 2
image

This should be "32": "Tomato___Septoria_leaf_spot", not "36": "Tomato___Tomato_mosaic_virus".

Am I doing something wrong? Is the input to the model wrong? I am very new to ML, so I have very little idea as to how I can improve the classification. Would other models yield the same incorrect labels?

Smartphone (please complete the following information):

  • Device: Samsung Galaxy A52
  • OS: Android 12
  • Browser: Nope, Bare React Native

Code
`
import React, { useEffect, useState } from 'react';
import { Image, StyleSheet, Alert } from 'react-native';
import * as tf from '@tensorflow/tfjs';
import { fetch, bundleResourceIO, decodeJpeg } from '@tensorflow/tfjs-react-native';
import * as jpeg from 'jpeg-js';
import * as FileSystem from "expo-file-system";

export default function CaptureResult({ navigation, route }) {
const [tfReady, setTfReady] = useState(false);
const [diseaseDetector, setDiseaseDetector] = useState("");

async function loadModel() {

    await tf.setBackend('cpu');
    await tf.ready();
    setTfReady(true);
    console.log("[+] TF Ready!");


    console.log("[+] Loading custom Disease detection model")
    const modelJson = await require("../../assets/model/model.json");
    const modelWeight = await require("../../assets/model/group1-shard.bin");
    // const diseaseDetector = await tf.loadLayersModel(bundleResourceIO(modelJson, modelWeight));
    const diseaseDetector = await tf.loadLayersModel('https://coverimages.blob.core.windows.net/plantai-tfjs-model/model.json');
    console.log("[+] Model Loaded!");

    setDiseaseDetector(diseaseDetector);
}




const getDisease = async () => {


    const fileUri = `file://${route.params.photo}`;
    console.log("[+] Retrieving image  :" + fileUri)
    const imgB64 = await FileSystem.readAsStringAsync(fileUri, {
        encoding: FileSystem.EncodingType.Base64,
    });


    const imgBuffer = tf.util.encodeString(imgB64, "base64").buffer;
    const newData = new Uint8Array(imgBuffer);


    let offset = tf.scalar(255)
    let imageTensor = decodeJpeg(newData).resizeNearestNeighbor([224, 224]).toFloat().expandDims(); // transforms byte array into 3d tensor
    let imageTensor_scaled = imageTensor.div(offset)
    let prediction = await diseaseDetector.predict(imageTensor_scaled).data();

    console.info(prediction);
    let predicted_class = tf.argMax(prediction)
    let class_idxs = Array.from(predicted_class.dataSync());
    console.log(class_idxs)
    let class_idx = class_idxs[0]
    console.log(class_idx) // <--- THIS USUALLY GIVES '7', which I match from the class_indices.json file, which comes out to be corn.

    console.log("[+] Prediction Completed")

}

getDisease()



useEffect(() => {
    loadModel();
}, []);

return (
    <Image source={{ uri: `file://${route.params.photo}` }} style={StyleSheet.absoluteFill} />


);

}`

Set up Linting

For our next code changes, it would be great to set up linting as GitHub Action to:

  • help prevent broken code from being uploaded to the default branch
  • follow best practices
  • streamline code reviews

Website Wireframe

I have created an initial wireframe for our project.

Please have a look & share feedback along with required changes so we can start with the actual fronted build part.

Plant AI Wireframe

The wireframe is interactive and comes with basic navigation & transitions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.