{"id":25794248,"url":"https://github.com/generic-matrix/dogbreed-classification","last_synced_at":"2026-06-16T16:31:14.658Z","repository":{"id":150440187,"uuid":"594988686","full_name":"generic-matrix/DogBreed-Classification","owner":"generic-matrix","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-30T09:23:07.000Z","size":11688,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-28T09:41:23.597Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/generic-matrix.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":"2023-01-30T06:39:42.000Z","updated_at":"2025-05-21T05:46:29.000Z","dependencies_parsed_at":"2023-04-09T03:00:50.065Z","dependency_job_id":null,"html_url":"https://github.com/generic-matrix/DogBreed-Classification","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/generic-matrix/DogBreed-Classification","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/generic-matrix%2FDogBreed-Classification","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/generic-matrix%2FDogBreed-Classification/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/generic-matrix%2FDogBreed-Classification/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/generic-matrix%2FDogBreed-Classification/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/generic-matrix","download_url":"https://codeload.github.com/generic-matrix/DogBreed-Classification/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/generic-matrix%2FDogBreed-Classification/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34415240,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-16T02:00:06.860Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-02-27T13:56:59.942Z","updated_at":"2026-06-16T16:31:14.634Z","avatar_url":"https://github.com/generic-matrix.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dependencies\n\n* Python 3.6\n* TensorFlow 2.1\n* Android Studio\n\n# Outputs\n\n\nGerman Shepard       |  Pug\n:-------------------------:|:-------------------------:\n![german_shepard](https://github.com/generic-matrix/DogBreed-Classification/blob/main/Output/german_shepard.png?raw=true)  |  ![Pug](https://github.com/generic-matrix/DogBreed-Classification/blob/main/Output/pug.png?raw=true)\n\n\n\n# Project Structure\n\nThe project has 4 folders\n\n* Android App -\u003e The Android App code\n* Labels -\u003e It has labels.txt\n* APK -\u003e The apk.app which can be installed onto a compatible Android device\n* Training -\u003e It has Training.ipynb whci can be opened in Google Colab\n* Output -\u003e The Output Video is in here\n\n# How to build the Android App\n\n* git clone \u003c\u003e\n* cd Android App (Also download the model.tflite from the below link and paste it in the assets folder)\n* Open the same on the Android Studio\n\n# APK can be downloaded from the [Link](https://drive.google.com/file/d/1RM5MZsdvZRtQnZOu7a-nhcYXtnitGVya/view?usp=sharing)\n\n\n# Steps Followed\n\nWe are using NASNetLarge model , refer training.ipynb in the training folder\n\n1) convert classes.json to labels.txt and classes.json\n```\nwhere {\"A\": 0, \"B\": 1,\"C\":2}\n```\nwe need to convert the above json  to labels.txt like below\n```\nA\nB\nC\n```\n\n```\nimport json\ndata=json.loads('\u003ccontent in classes.json\u003e')\ntext_file = open(\"labels.txt\", \"w\")\n#write string to file\ntext_file.write('\\n'.join(data.keys()))\n#close file\ntext_file.close()\n```\n\n2) Download model.tflite from [Link](https://drive.google.com/file/d/1mYw36XgrNCya98B2Vx1QU601_Q5YJJs4/view?usp=sharing) \n\n\n3) Create android app from android studio \n\n3) Add com.otaliastudios:cameraview and tflite as dependencies\n\n```\n    implementation 'org.tensorflow:tensorflow-lite:0.0.0-nightly'\n    implementation 'org.tensorflow:tensorflow-lite-gpu:0.0.0-nightly'\n    implementation 'org.tensorflow:tensorflow-lite-support:0.0.0-nightly'\n    implementation 'com.github.esafirm.android-image-picker:imagepicker:2.3.1'\n    implementation 'com.github.bumptech.glide:glide:4.5.0'\n    implementation 'com.google.android.gms:play-services-vision:20.0.0'\n    api 'com.otaliastudios:cameraview:2.6.2'\n```\n\n\n4) In the layout add\n\n```\n\u003ccom.camerakit.CameraKitView\n    android:id=\"@+id/camera\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"wrap_content\"\n    android:adjustViewBounds=\"true\"\n    android:keepScreenOn=\"true\"   \u003c!-- keep screen awake while CameraKitView is active --\u003e\n    app:camera_flash=\"auto\"\n    app:camera_facing=\"back\"\n    app:camera_focus=\"continuous\"\n    app:camera_permissions=\"camera\" /\u003e\n```\n\n\n5) Check activity_main.xml \n\n    5.1) Add CameraView , ProgressBar , A button and two text views\n\n6) Paste labels.txt and model.tflite onto the assets folder \n\n7) Review MainActivity.kt\n\n    7.1) Set the cameraview life cycle owner\n\n    ```\n    cameraView.setLifecycleOwner(this)\n    ```\n\n    7.2) Button onClick , add frameprocessor on the camera view\n\n    ```\n    val button = findViewById\u003cButton\u003e(R.id.get_breed)\n        button.setOnClickListener {\n            cameraView.addFrameProcessor{ frame -\u003e\n            }\n    }\n    ```\n\n    7.3) From frame convert to bitmap and send it to predict function \n\n    where predit function is \n\n    ```\n    private fun predict(input: Bitmap): MutableMap\u003cString, Float\u003e {\n            // load model\n            val modelFile = FileUtil.loadMappedFile(this, \"model.tflite\")\n            val model = Interpreter(modelFile, Interpreter.Options()) \n            val labels = FileUtil.loadLabels(this, \"labels.txt\")\n\n            // data type\n            val imageDataType = model.getInputTensor(0).dataType() \n            val inputShape = model.getInputTensor(0).shape() \n\n            val outputDataType = model.getOutputTensor(0).dataType() \n            val outputShape = model.getOutputTensor(0).shape() \n\n            var inputImageBuffer = TensorImage(imageDataType)\n            val outputBuffer = TensorBuffer.createFixedSize(outputShape, outputDataType) \n\n            // preprocess\n            val cropSize = kotlin.math.min(input.width, input.height)\n            val imageProcessor = ImageProcessor.Builder()\n                .add(ResizeWithCropOrPadOp(cropSize, cropSize)) \n                .add(ResizeOp(inputShape[1], inputShape[2], ResizeOp.ResizeMethod.NEAREST_NEIGHBOR)) \n                .add(NormalizeOp(127.5f, 127.5f)) \n                .build()\n\n            // load image\n            inputImageBuffer.load(input) \n            inputImageBuffer = imageProcessor.process(inputImageBuffer) \n\n            // run model\n            model.run(inputImageBuffer.buffer, outputBuffer.buffer.rewind())\n\n            // get output\n            val labelOutput = TensorLabel(labels, outputBuffer) \n\n            val label = labelOutput.mapWithFloatValue\n            return label\n    }\n    ```\n    The predict function returs the probablity for each and every classes\n\n    7.4) Parse the probablity key value pair\n\n    ```\n        val label = predict(bitmap)\n        val maxEntry = label.maxWith(Comparator { x, y -\u003e x.value.compareTo(y.value)})\n        val prediction = findViewById\u003cTextView\u003e(R.id.label)\n        val confidence = findViewById\u003cTextView\u003e(R.id.confidence)\n        if(maxEntry?.value!! \u003c0.2){\n            prediction.text = \"No dog found\"\n            confidence.text = \"--\"\n        }else{\n            prediction.text = maxEntry?.key.toString()\n            confidence.text = (maxEntry?.value?.times(100)).toString()+\" %\"\n        }\n    ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeneric-matrix%2Fdogbreed-classification","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeneric-matrix%2Fdogbreed-classification","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeneric-matrix%2Fdogbreed-classification/lists"}