A Machine Learning App for an Age-Old Debate

Sandwhich

Sandwhich is a mobile app built to solve the sandwich debate by determining if the picture you’ve taken is a sandwich using machine learning,Β Flutter, andΒ TensorFlow Lite.

Screenshots

Built With

Getting Started

Building from Source

Clone the repository

git clone https://github.com/MotionMobs/Sandwhich
cd Sandwhich

Run Sandwhich

flutter run

Train Your Model/ How ToΒ πŸš‹Β Your πŸ₯ͺ

To train your πŸ₯ͺ, you need to installΒ DockerandImageMagick.

brew update && brew install imagemagick

Set up file structure for your images

training_images
β”‚   β”œβ”€β”€ input
β”‚   β”‚   β”œβ”€β”€ not-sandwich
β”‚   β”‚   β”‚   β”œβ”€β”€ processed  # processed not-sandwich images
β”‚   β”‚   β”‚   └── unprocessed  # original, not yet processed not-sandwich images
β”‚   β”‚   β”œβ”€β”€ sandwich
β”‚   β”‚   β”‚   β”œβ”€β”€ processed  # processed sandwich imagess
β”‚   β”‚   β”‚   └── unprocessed  # original, not yet processed sandwich images
β”‚   β”œβ”€β”€ output  # ready for model
β”‚   β”‚   β”œβ”€β”€ not-sandwich  # minimum 20 images to train
β”‚   β”‚   └── sandwich  # minimum 20 images to train
└──

Once original images are loaded into the folders, as described above, process the images

cd training_images
./conversion.sh

After all images have been processed we need to build the Docker image, run the script to retrain the model, and run the script to convert the retrained model to aΒ .tfliteΒ model we can use in the app.

Go back to the root of the project and run:

cd -
./train.sh

Prepare to wait a while.

Testing

To test the new model, runΒ ./test_model.sh $IMAGE_PATHΒ whereΒ $IMAGE_PATHΒ is any path to an image you want to test with. For convenience, you can even drag an image into the terminal to have its path placed at the end of whatever is currently in the terminal.

  • When ready to use the new model, move it to the assets folder and overwrite the old model. Backup old model if desired.
  • Run the app, find some sandwiches, and enjoy!

To release on Android:

flutter build apk --target-platform android-arm64

Credit (github url) :Β https://github.com/MotionMobs/Sandwhich

Next Article :Β https://flutterappdev.com/2019/04/09/a-flutter-accident-reporting-app-working-in-both-ios-and-android/

Leave a Reply

Your email address will not be published.