Skip to content

🍏 Capstone Project of MSIB Dicoding 2022 Cycle 3. We plan to build a machine learning model to predict fresh fruit. That way, users are expected to be able to easily separate between fresh and rotten fruit.

Notifications You must be signed in to change notification settings

nurmuhimawann/C22-098-Fruity-Website

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

37 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Fruity logo

Fruity App by C22-098

PythonΒ Β  FlaskΒ Β  RailwayΒ Β  Tensorflow


πŸ€– Fruity helps you quickly identify rotten fruit, saving you the hassle of sorting to get fresh fruit.


🌐 Demo Link

In this project, we initially used Railway as a hosting platform for our application. But Railways have limited access. Alternatively, you can visit https://itsfruity.onrender.com/ if the service in https://itsfruity.up.railway.app/ is no longer available.

display website


πŸ“ Table of Contents

  1. Introduction
  2. Demo Link
  3. Table of Contents
  4. About Fruity
    1. Background
    2. Goal & Aim
  5. Quickstart
    1. Built Using
    2. Prerequisite
    3. Installation & Get Started Project
    4. Deploy Machine Learning Model with Flask
  6. How Does the Inference Work?
  7. Project Management Plan
  8. Project Repository Structure
  9. Project Resources
  10. Academic Paper & References
  11. Support
  12. Contributing
  13. Acknowledgments

🌿 About Fruity

Fruity is a website-based machine learning program which is currently under development process for the Capstone Project of Certified Independent Study of MBKM Dicoding Cycle 3 from Machine Learning & Front End Web Development learning path.


πŸ’‘Background

Horticulture is an agricultural sub-sector which is important contribution to agriculture in Indonesia. In 2020, the value of horticultural exports increased by 37.75% compared to 2019. This increase was dominated by fruit commodities during the 2020 COVID-19 pandemic. This indicates that fruits have a high level of demand. Assessment of fruit quality is a major challenge in the agricultural sector. Controlling the external quality of fruit manually may be possible. However, it will take a long time and have implications for productivity. Based on the problems above, we propose a website-based classification system "Fruity" to help identify rotten fruit as a first step for quality control in fruit commodities.


🎯 Goal & Aim

This website aims to help everyone (especially fruit growers and fruit sellers) as an utility to help identify fresh and rotten fruits by uploading the image of the fruits. This feature is expected to increase productivity in detecting defects in agricultural fruits.


⚑️ Quickstart

This section will explain the steps for installing and deploying Fruity to a web service with a short code. This process is divided into 3 parts, the first one introduction and prerequisites, the second is creating the Flask project itself, and the last is the hosting process on the platform as a service. Fyi, initially, we used Heroku. Sadly, since today (starting November 28, 2022), Heroku has eliminated all free services. We are using other alternative platforms, one of which is Fly.io and Railway. In the project, we use Railway. But, Railway has drawbacks, access is limited to 500 hours of use. Therefore, we're looking into how to set up Fly.io as a backup host.


πŸ“¦ Built Using

Fruity is a web-based machine learning program developed by training models using the end-to-end machine learning platform, TensorFlow. And then, the trained model is connected to the web server using Flask.


🎨 Prerequisite

  • Python, one of the top machine learning and AI programming languages.
  • Tensorflow, The core open-source library to help you develop and train ML models. in this package there is Keras. Keras is a deep learning API written in Python, running on top of the machine learning platform TensorFlow.
  • Flask, Flask is a web application framework written in Python.


βš™οΈ Installation & Get Started Project

This step, steps to creating Flask project and setting up in the development environment, which is running on a local server.

🧡 Installation of the Project to Virtual Environment

To be able to push it into a stand-alone virtual environment, follow this step. If you have already done this, step to the next step.

  1. Clone this repository

    $ git clone https://github.com/nurmuhimawann/C22-098-Fruity-Website.git
  2. Install Python Virtual Environment

    $ virtualenv venv
  3. Install All the Requirements Inside "requirements.txt"

    $ pip install -r requirements.txt
  4. Create Flask App Environment Variables & Run Server

    $ env:FLASK_APP = "wsgi"
    
    $ flask run
  5. Open URL referencing LocalHost in your browser

    πŸŽ‰ Yeaay, Congrats. The web app is successfully running on the local server. If you want the application accessible on the internet, you must deploy this app to a web service platform. Let's go to the next step πŸ˜‰.


πŸš€ Deploy Machine Learning Model with Flask

Annotation

You don't have to use both. Just choose either Fly.io or Railway.

Click on the triangle icon to expand

Fly.io

  1. Install Flyctl

    On OS windows, Run the Powershell install script.

    $ iwr https://fly.io/install.ps1 -useb | iex
  2. Login Fly.io

    If it’s your first time using Fly.io, you’ll need to sign up for an account.

    $ flyctl auth signup

    If you already have a Fly.io account, all you need to do is sign in with flyctl. Simply run:

    $ flyctl auth login
  3. Configure the App for Fly

    Each Fly application needs a fly.toml file to tell the system how we'd like to deploy it. That file can be automatically generated.

    $ flyctl launch
  4. Deploying to Fly

    $ flyctl deploy
  5. Viewing the Deployed App

    You can see, the application has been assigned with a DNS hostname.

    $ flyctl status
  6. Connecting to the App

    This will open a browser on the HTTP version of the site.

    $ flyctl open 

    And that’s it! This is everything, now your web application accessible on the internet. Congrats πŸŽ‰


Railway App


This is the easiest way to deploy a web application to a railway because you don't need to type commands on the CLI like Fly.io.

  1. Prerequisite

    You need GitHub and Railway account. If this is your first time using GitHub and Railway, you will need to register both GitHub and Railway. If you already have a Github and Railway account, Make sure to connect your Railway account to GitHub.

  2. Forking a GitHub Repository

    If you have this project in your repository, you can skip this step and proceed to the next step. But, if you don't have it yet, you can go to GitHub, navigate to the nurmuhimawann/C22-098-Fruity-Website repository. In the top-right corner of the page, click Fork.

  3. Go to your railway dashboard and click on New Project Button.

  4. Select the option Deploy from GitHub repo

  5. Provide Railway app to access your GitHub repositories.

  6. Soon, your project should be live.

    On your dashboard, you can see the application has been assigned with a DNS hostname.

    Every time we make changes in our repo, the app will be redeployed. And that’s it. Your project has been completely deployed on Railway and is easily available for public use! Congrats πŸŽ‰


βš› How Does the Inference Work?

  1. User uploads an image to web application.
  2. Gets the user input of images from Flask pages. After that, the application checks file extension to ensure that file uploaded is an image. The uploaded image is stored at static/user_uploads folder.
  3. App extract the image's path.
  4. Load the images using tf.keras.utils.load_img(img_path, target_size=(150, 150)). This function is applied to load image from specified path for preparation before applying image classification. The image is resized into 150x150px resolution.
  5. Because the model can't classify images directly in the initial extension. So, the image is converted first into an array of integers using tf.keras.utils.img_to_array(img).
  6. Expand the dimension of the array in input Tensor using tf.expand_dims(img_array, axis=0).
  7. Use the model to predict the array's class using fresh_rotten_model.predict(img_array). This function returns an array of model's confidence of each label. From the array, the index of maximum value is fetched using np.argmax(prediction).
  8. Cast the label of the prediction using fresh_rotten_label(prediction) to get the result. This integer value is converted into a string based on the JSON labels that matches the value. And the final result will display the predicted, such as β€œFresh Apples”, "Rotten Apples" etc.

πŸ“‘ Project Management Plan


πŸ—ƒοΈ Project Repository Structure

πŸ—‚οΈ Project Structure

<Main Repository>
.
β”œβ”€β”€ app/                        # App Modules
β”‚   β”œβ”€β”€ models/                 # the place where machine learning models are saved
β”‚   β”‚   β”œβ”€β”€ image_dir           # test image files
β”‚   β”‚   β”œβ”€β”€ label_dir           # json label dictionary
β”‚   β”‚   └── model_dir           # models hdf5
β”‚   β”œβ”€β”€ static/                 # the place where JS,Images and CSS files are saved
β”‚   β”‚   β”œβ”€β”€ css                 # CSS files
β”‚   β”‚   β”œβ”€β”€ data                 # JSON files
β”‚   β”‚   β”œβ”€β”€ fonts               # Fonts files
β”‚   β”‚   β”œβ”€β”€ img                 # Image files
β”‚   β”‚   β”œβ”€β”€ js                  # Javascripts files
β”‚   β”‚   └── user_uploads        # Store uploaded Files by users
β”‚   β”œβ”€β”€ templates/              # the place pages & components files are saved
β”‚   β”‚   β”œβ”€β”€ includes            # Page chunks, components
β”‚   β”‚   └── layouts             # App Layouts (the master pages)
β”‚   └── __init__.py             # the place where flask app are initialized
β”‚   └── application.py          # Bundle all above sections, routing and expose the Flask APP 
β”œβ”€β”€ datasets                    # links datasets
β”œβ”€β”€ notebooks                   # baseline models .ipynb
β”œβ”€β”€ readme-assets               # Contains thumbs used in documentation (README.md)
β”œβ”€β”€ .gitignore                  # Specifies file intentionally untracked files
β”œβ”€β”€ Procfile                    # List of process types in an app
β”œβ”€β”€ README.md                   # Information about a repository
β”œβ”€β”€ requirements.txt            # Application dependencies
β”œβ”€β”€ runtime.txt                 # Specify the version of Python
β”œβ”€β”€ set-env.txt                 # Setting for enviroment python
└── wsgi.py                     # Start the app in development and production

πŸ’Ύ Project Repository & Branch

This repository is divided into a main and two development branches as follows:

  • Main Branch (main)

    Main branch is used as an integration between fe-development and ml-development. The flask framework is used to build and integrate models with the front-end.

  • Front-End Development Branch (fe-development)

    A branch used exclusively for front-end development. In its development, written in HTML, CSS, and JS.

  • Machine Learning Development Branch (ml-development)

    A branch is used exclusively for machine learning development. It's written in Jupyter Notebook using most libraries like Keras and Tensorflow.


πŸ“‚ Project Resources

Progamming Languange

PythonΒ Β  HTMLΒ Β  CSSΒ Β  JavascriptΒ Β 


Datasets:


Framework, Library & Utility:

TensorflowΒ Β  FlaskΒ Β  BootstrapΒ Β  jQueryΒ Β  VSCodeΒ Β  GitΒ Β  GithubΒ Β 


Design Tools:

FigmaΒ Β  Adobe PhotoshopΒ Β  Adobe IllustratorΒ Β 


Project Management Tools:


πŸ“– Academic Paper & References


πŸ’– Like this project ?

Leave a ⭐ If you think this project is cool.

Share with the world


πŸ‘₯ Contributing

Sarah Salsabilla - Our lovely adviser

Thank you for being such an amazing advisor! You are so understanding, kind and helpful. we very lucky to have you as our advisor teams, and you give a lot of help. A thousand words cannot express our gratitude to you. we really really appreciate you! Thanks kak.

Nur Muhammad Himawan - Team Leader

Instagram BadgeΒ Β  Twitter BadgeΒ Β  LinkedIn BadgeΒ Β  GitHub BadgeΒ Β 

Putri Nur Aini Mahfudz - Machine Learning Developer

Instagram BadgeΒ Β  Twitter BadgeΒ Β  LinkedIn BadgeΒ Β  GitHub BadgeΒ Β 

Laily Farkhah Adhimah - Machine Learning Developer

Instagram BadgeΒ Β  Twitter BadgeΒ Β  LinkedIn BadgeΒ Β  GitHub BadgeΒ Β 

Mohamad Ilman Huda - Front-End Web Developer

Instagram BadgeΒ Β  LinkedIn BadgeΒ Β  GitHub BadgeΒ Β 


πŸŽ‰ Acknowledgements

  • Dicoding Academy
  • My Supervisor - Mr. Fahrobby Adnan, S.Kom.,MMSI
  • My Advisor - Sarah Salsabilla
  • My Mentor - Ahmad Sholihin
  • M05 Class
  • Inspiration
  • References

About

🍏 Capstone Project of MSIB Dicoding 2022 Cycle 3. We plan to build a machine learning model to predict fresh fruit. That way, users are expected to be able to easily separate between fresh and rotten fruit.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published