{"id":15149094,"url":"https://github.com/neild0/first-mlworkshop","last_synced_at":"2025-10-24T05:31:16.222Z","repository":{"id":129700720,"uuid":"131097749","full_name":"neild0/FIRST-MLWorkshop","owner":"neild0","description":"This project was developed by Neil Deshmukh to teach attendees how to develop an image recognition Convolutional Neural Network and complimentary app, at the 'Using Machine Learning to Build an Image Classification App' workshop at FIRST Detroit on April 26th at 1:30 - 3:30 pm.","archived":false,"fork":false,"pushed_at":"2019-03-13T20:05:00.000Z","size":13420,"stargazers_count":7,"open_issues_count":0,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-30T23:41:49.465Z","etag":null,"topics":["android","convolutional-neural-networks","detroit","first-robotics-competition","image-classification","ios","machine-learning","python","workshop"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/neild0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-26T03:58:35.000Z","updated_at":"2024-08-03T21:11:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"f132715c-9244-4f8d-9e31-425fd582f283","html_url":"https://github.com/neild0/FIRST-MLWorkshop","commit_stats":{"total_commits":37,"total_committers":3,"mean_commits":"12.333333333333334","dds":"0.16216216216216217","last_synced_commit":"8d12127d7e62246b88fd7db6a9f47882f59f58d5"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neild0%2FFIRST-MLWorkshop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neild0%2FFIRST-MLWorkshop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neild0%2FFIRST-MLWorkshop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neild0%2FFIRST-MLWorkshop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neild0","download_url":"https://codeload.github.com/neild0/FIRST-MLWorkshop/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237918710,"owners_count":19387305,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","convolutional-neural-networks","detroit","first-robotics-competition","image-classification","ios","machine-learning","python","workshop"],"created_at":"2024-09-26T13:41:47.913Z","updated_at":"2025-10-24T05:31:11.164Z","avatar_url":"https://github.com/neild0.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FIRST-MLWorkshop\nThis is the workshop github for the 'Using Machine Learning to Build an Image Classification App' presented by Neil Deshmukh at FIRST Detroit on April 26th at 1:30 - 3:30 pm.\n\nIn this workshop, we will first train a ML algorithm to classify between any image classes that we give it, and then secondly integrate it into an application. \n\nThe app integration is optional, but it's a pretty cool direct visualization of the Neural Network in action.\n\nAll that you need is: \n * an internet connection (to download the needed materials)\n * (optional) the development environment for your respective phone:\n   * Xcode for IOS (only on Mac)\n   * Android Studio for Android \n   * Cord to connect the phone and computer\n\n______________________________________________________________________________________________________________________________\n\n\n## Step #0: Setup \n\nDownload Python (if you don't already have it)\n\nONLY Mac Users Developing for IOS: \n\npython2: `sudo pip install --upgrade \\\n https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.4.0-py-none-any.whl`\n\npython 3: `sudo pip3 install --upgrade \\\n https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.4.0-py3-none-any.whl`\n \nDownload tensorflow following the instructions at https://www.tensorflow.org/install/ (the CPU version will be sufficient for this workshop)\n\nDownload google_images_download, if you would like to train the model on the classes that you want it to detect:\n\n`pip install google_images_download`\n\n______________________________________________________________________________________________________________________________\n\n\n# Part 1: Developing ML Classification Algorithm:\n\n## 1. Clone this directory onto your computer: \n\n`git clone https://github.com/QuantumTCode/FIRST-MLWorkshop`\n\n\n\n## 2. cd into the directory, where all of the code will be run:\n\n`cd FIRST-MLWorkshop`\n\n\n\n## 3. Download the classes of images that you would like the algorithm to detect:\n\n`googleimagesdownload -f jpg -k \"[Class 1], [Class 2], [Class 3], [Class 4], [Class 5]\" `\n\nSo an example would be:\n\n`googleimagesdownload -f jpg -k \"train, car, bus, racecar, motorcycle\"`\n\nWhile only 5 classes are downloaded above, you can add more (might decrease accuracy of classification)\n\nCheck the images: \n\n`python scripts/check_images.py`\n\n\n\n## 4. Set up variables for training:\n\n`ARCHITECTURE=\"mobilenet_0.50_224\"`\n\n`tensorboard --logdir tf_files/training_summaries \u0026`\n\nIf you receive an error stating: `TensorBoard attempted to bind to port 6006, but it was already in use` kill the existing TensorBoard instance using `pkill -f \"tensorboard\"`\n\n\n## 5. Time to Initiate Machine Learning!\n\nStart the training of the model using:\n\n```python\npython -m scripts.retrain \\\n  --bottleneck_dir=tf_files/bottlenecks \\\n  --how_many_training_steps=1000 \\\n  --model_dir=tf_files/models/ \\\n  --summaries_dir=tf_files/training_summaries/\"${ARCHITECTURE}\" \\\n  --output_graph=tf_files/retrained_graph.pb \\\n  --output_labels=tf_files/retrained_labels.txt \\\n  --architecture=\"${ARCHITECTURE}\" \\\n  --image_dir=downloads\n  \n  ```\n  \nIf you have time, and want to increase the accuracy of you model, change `--how_many_training_steps=X` to a higher number (4000 is probably the highest you need to go).\n\n\n## 6. Watch Machine Learning in Action:\n\nTo see the real time learning behind the algorithm, go to http://0.0.0.0:6006/ on your computer!\n\n## 7. Test the Accuracy of Your Algorithm:\n```python\npython -m scripts.label_image \\\n    --graph=tf_files/retrained_graph.pb  \\\n    --image=(path_to_image) \n   ```\n    \nFor example:\n\n`python -m scripts.label_image \\\n    --graph=tf_files/retrained_graph.pb  \\\n    --image=downloads/car/car.png`\n  \n______________________________________________________________________________________________________________________________\n\n# Part 2: Implementing ML Algorithm on Phone:\n\n## 1. Setup:\n\n`pip install PILLOW`\n\nIf IOS: `sudo gem install cocoapods`\n\n## 2: Optimize model using TensorFlow Lite Optimizing Converter (TOCO):\n```python\ntoco \\\n  --input_file=tf_files/retrained_graph.pb \\\n  --output_file=tf_files/optimized_graph.pb \\\n  --input_format=TENSORFLOW_GRAPHDEF \\\n  --output_format=TENSORFLOW_GRAPHDEF \\\n  --input_shape=1,224,224,3 \\\n  --input_array=input \\\n  --output_array=final_result \\\n  --mean_value=128 \\\n  --std_value=128 \\\n  --default_range_min=0  \\\n  --default_ranges_max=6\n  ```\n\n## 3: Convert Model to TFLite Format:\n\n```python \ntoco \\\n  --input_file=tf_files/retrained_graph.pb \\\n  --output_file=tf_files/optimized_graph.lite \\\n  --input_format=TENSORFLOW_GRAPHDEF \\\n  --output_format=TFLITE \\\n  --input_shape=1,224,224,3 \\\n  --input_array=input \\\n  --output_array=final_result \\\n  --inference_type=FLOAT \\\n  --input_type=FLOAT \\\n  --mean_value=128 \\\n  --std_value=128 \\\n  --default_range_min=0  \\\n  --default_ranges_max=6\n  ```\n___________________________\n## 4.1: For IOS:\n`cd ios/camera`\n\nUpdate Pods:\n`pod update`\n\nCopy the trained models into the app:\n`cd ../..`\n`cp tf_files/retrained_graph.pb ios/camera/data/retrained_graph.pb`\n\nCopy the labels into the app:\n`cp tf_files/retrained_labels.txt ios/camera/data/retrained_labels.txt`\nOpen the app:\n`open ios/camera/tf_camera_example.xcworkspace`\n\nMake sure to go to Xcode\u003ePreferences and sign in to be able to connect your phone and test the application.\n\n  *  Click on the tflite_photos_example file on the left, and name your Bundle Identifier something unique, for example: com.[your name]\n  * Click on automatically manage signing\n  \nFinally, you should be able to run your app!\n\n___________________________\n## 4.2: For Android:\nSet up Device: https://developer.android.com/studio/debug/dev-options#enable\n\nCopy the labels and models into the app:\n`cp tf_files/optimized_graph.lite android/tflite/app/src/main/assets/graph.lite`\n`cp tf_files/retrained_labels.txt android/tflite/app/src/main/assets/labels.txt`\n\nOpen Android Studio\u003eOpen an existing Android Studio project, open FIRST-MLWorkshop/android/tflite, and click 'OK' for Gradle Sync.\n\nThen run the app!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneild0%2Ffirst-mlworkshop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneild0%2Ffirst-mlworkshop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneild0%2Ffirst-mlworkshop/lists"}