{"id":16509599,"url":"https://github.com/joonb14/tfliteclassification","last_synced_at":"2026-04-13T12:02:03.834Z","repository":{"id":111832744,"uuid":"345547134","full_name":"joonb14/TFLiteClassification","owner":"joonb14","description":"TensorFlow Lite Image Classification Python Implementation","archived":false,"fork":false,"pushed_at":"2021-03-09T02:19:07.000Z","size":40159,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-13T07:26:02.982Z","etag":null,"topics":["classification","classification-model","computer-vision","efficientnet","image-classification","interpreter","mobilenet","python","tensorflow","tensorflow-lite","tflite","tflite-models","vision"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joonb14.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2021-03-08T06:00:03.000Z","updated_at":"2025-03-11T14:37:45.000Z","dependencies_parsed_at":"2023-06-04T09:02:04.604Z","dependency_job_id":null,"html_url":"https://github.com/joonb14/TFLiteClassification","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/joonb14/TFLiteClassification","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joonb14%2FTFLiteClassification","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joonb14%2FTFLiteClassification/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joonb14%2FTFLiteClassification/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joonb14%2FTFLiteClassification/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joonb14","download_url":"https://codeload.github.com/joonb14/TFLiteClassification/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joonb14%2FTFLiteClassification/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31751705,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T09:16:15.125Z","status":"ssl_error","status_checked_at":"2026-04-13T09:16:05.023Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["classification","classification-model","computer-vision","efficientnet","image-classification","interpreter","mobilenet","python","tensorflow","tensorflow-lite","tflite","tflite-models","vision"],"created_at":"2024-10-11T15:51:22.266Z","updated_at":"2026-04-13T12:02:03.813Z","avatar_url":"https://github.com/joonb14.png","language":"Jupyter Notebook","readme":"# TensorFlow Lite Image Classification in Python\n\nThis code snipset is heavily based on \u003cb\u003e\u003ca href=\"https://www.tensorflow.org/lite/examples/image_classification/overview\"\u003eTensorFlow Lite Image Classification\u003c/a\u003e\u003c/b\u003e\u003cbr\u003e\nThe segmentation model can be downloaded from above link.\u003cbr\u003e\nFor the realtime implementation on Android look into the \u003ca href=\"https://github.com/tensorflow/examples/tree/master/lite/examples/image_classification/android\"\u003eAndroid Image Classification Example\u003c/a\u003e\u003cbr\u003e\nFollow the \u003ca href=\"https://github.com/joonb14/TFLiteClassification/blob/main/classification.ipynb\"\u003eclassification.ipynb\u003c/a\u003e to get information about how to use the TFLite model in your Python environment.\u003cbr\u003e\n\n### Details\nThe \u003cb\u003emobilenet_v1_1.0_224_quant.tflite\u003c/b\u003e file's input takes normalized 224x224x3 shape image. And the output is 1001x1 where the 1001 denotes labels in below order, contains the probabilty of the image belongs to the class.. The specific labels of the 1001 classes are stored in the \u003cb\u003elabels_mobilenet_quant_v1_224.txt\u003c/b\u003e file in below  order\u003cbr\u003e\n```python\nlineList = ['background', 'tench', 'goldfish', 'great white shark', 'tiger shark', 'hammerhead', 'electric ray', 'stingray', 'cock', 'hen', 'ostrich', 'brambling', 'goldfinch', 'house finch', 'junco', 'indigo bunting', ...]\n```\nFor model inference, we need to load, resize, typecast the image.\u003cbr\u003e\nThe mobileNet model uses uint8 format so typecast numpy array to uint8.\u003cbr\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/30307587/110282617-23097d80-8022-11eb-8ca3-4bf23b1a6b68.png\" width=800px/\u003e\u003cbr\u003e\nThen if you follow the correct instruction provided by Google in \u003ca href=\"https://www.tensorflow.org/lite/guide/inference#load_and_run_a_model_in_python\"\u003eload_and_run_a_model_in_python\u003c/a\u003e, you would get output in below shape\u003cbr\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/30307587/110282313-9eb6fa80-8021-11eb-9668-87ef47202c59.png\" width=300px/\u003e\u003cbr\u003e\nNow we need to process this output to use it for classification\u003cbr\u003e\n\n```python\nimport pandas as pd\nimport numpy as np\n\nclassification_prob = []\nclassification_label = []\ntotal = 0\nfor index,prob in enumerate(output_data[0]):\n    if prob != 0:\n        classification_prob.append(prob)\n        total += prob\n        classification_label.append(index)\nlabel_names = [line.rstrip('\\n') for line in open(\"labels_mobilenet_quant_v1_224.txt\")]\nfound_labels = np.array(label_names)[classification_label]\n\ndf = pd.DataFrame(classification_prob/total, found_labels)\nsorted_df = df.sort_values(by=0,ascending=False)\nsorted_df\n```\n\u003cimg src=\"https://user-images.githubusercontent.com/30307587/110282542-010ffb00-8022-11eb-8746-7047a7386787.png\" width=300px/\u003e\u003cbr\u003e\n\nThe other models such as \n```\nefficientnet-lite0-fp32.tflite, \nefficientnet-lite0-int8.tflite, \nmobilenet_v1_1.0_224.tflite\n``` \nare from the \u003ca href=\"https://github.com/tensorflow/examples/tree/master/lite/examples/image_classification/android\"\u003eAndroid Image Classification Example\u003c/a\u003e Take a look at the github and consider changing the TFLite model if you want.\u003cbr\u003e\nI believe you can modify the rest of the code as you want by yourself.\u003cbr\u003e\nThank you!\u003cbr\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoonb14%2Ftfliteclassification","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoonb14%2Ftfliteclassification","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoonb14%2Ftfliteclassification/lists"}