{"id":15015494,"url":"https://github.com/ahmedfgad/numpycnnandroid","last_synced_at":"2025-04-12T09:19:09.592Z","repository":{"id":109433201,"uuid":"135581126","full_name":"ahmedfgad/NumPyCNNAndroid","owner":"ahmedfgad","description":"Convolutional Neural Network for Android using Kivy and NumPy","archived":false,"fork":false,"pushed_at":"2023-04-08T19:44:15.000Z","size":24802,"stargazers_count":26,"open_issues_count":1,"forks_count":15,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-12T09:19:00.580Z","etag":null,"topics":["android","artificial-neural-networks","buildozer","cnn","convnet","convolutional-neural-networks","kivy","neural-network","numpy","pil","pillow","python","python-for-android","python3"],"latest_commit_sha":null,"homepage":"https://www.linkedin.com/in/ahmedfgad","language":"Python","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/ahmedfgad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":null,"open_collective":"pygad","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://donate.stripe.com/eVa5kO866elKgM0144","http://paypal.me/ahmedfgad"]}},"created_at":"2018-05-31T12:32:34.000Z","updated_at":"2024-12-10T06:26:50.000Z","dependencies_parsed_at":"2023-04-27T04:31:52.178Z","dependency_job_id":null,"html_url":"https://github.com/ahmedfgad/NumPyCNNAndroid","commit_stats":{"total_commits":15,"total_committers":1,"mean_commits":15.0,"dds":0.0,"last_synced_commit":"3649dae2349f3f8ed5783e42a4d01aa8cf66a103"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmedfgad%2FNumPyCNNAndroid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmedfgad%2FNumPyCNNAndroid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmedfgad%2FNumPyCNNAndroid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmedfgad%2FNumPyCNNAndroid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ahmedfgad","download_url":"https://codeload.github.com/ahmedfgad/NumPyCNNAndroid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248543836,"owners_count":21121838,"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","artificial-neural-networks","buildozer","cnn","convnet","convolutional-neural-networks","kivy","neural-network","numpy","pil","pillow","python","python-for-android","python3"],"created_at":"2024-09-24T19:47:32.757Z","updated_at":"2025-04-12T09:19:09.570Z","avatar_url":"https://github.com/ahmedfgad.png","language":"Python","readme":"# NumPyCNNAndroid\n\nThis project builds Convolutional Neural Network (CNN) for Android using Kivy and NumPy.\n\nIt is based on a previous project called **NumPyCNN (https://github.com/ahmedfgad/NumPyCNN)** but it is now working on Android.\nThe beaty of Kivy is that it not only allows Python code to work on different platforms (Android is one of them), but also to run the code without changes, as long as all requests are already supported by **python-for-android**.\n\n#### IMPORTANT\n**Training CNN on Android devices is deprecated because they can not work with large amounts of data and they are time consuming even for small amounts of data. Thus the main goal of the project is to link NumPy with Android and later a pre-trained CNN using NumPy on a more powerful machine can be used in Android for predictions.**\n\nThe major changes done in the NumPyCNN to create its Android version **NumPyCNN** is using supported modules by python-for-android to do the task. In **NumPyCNN**, the unsupprted used modules are **skimage**, **Matplotlib**, and **sys**. The one used while being supported is NumPy.\nIn **NumPyCNNAndroid**, **python image library (PIL)** is used to do the work by skimage. The GUI inside **Kivy** sufficient to do the job and thus no need to use Matplotlib. Some code changes applied to avoid using **sys**.\n\nInside the project, the important files are as follows:\n1. **main.py** which is the entry point for the application.\n2. **numpycnn.kv** that holds the UI design.\n3. **numpycnn.py** which is taken from NumPyCNN project to implement the CNN.\n4. **buildozer.spec** holding the specifications of the app such as requiremenets, SDK path, NDK path, python-for-android path, title, package name, welcome screen, icon, and other important things that are criticial to successful build of the app.\n\nTo build the project yourself, it is recommended to follow these steps:\n1. Understanding the NumPyCNN project.\n2. Installing Kivy.\n3. Installing Buildozer and python-for-android.\n\nFor **description about the NumPyCNN project**, refer to this article titled **\"Building Convolutional Neural Network using NumPy from Scratch\"**:  \nhttps://www.linkedin.com/pulse/building-convolutional-neural-network-using-numpy-from-ahmed-gad/  \nhttps://www.kdnuggets.com/2018/04/building-convolutional-neural-network-numpy-scratch.html  \nIt is also translated into Chinese: http://m.aliyun.com/yunqi/articles/585741  \n\nFor instructions about **installing Kivy and python-for-android**, read this article titled **\"Python for Android: Start Building Kivy Cross-Platform Applications\"**:  \nhttps://www.linkedin.com/pulse/python-android-start-building-kivy-cross-platform-applications-gad\n\nThe project has the **Android Pckage Kit (APK)** file inside the **/NumPyCNNAndroid/bin/** directory for installation.   \nOnce installed, the application will appear in the applications list as in the following figure:\n\n![screenshot_2018-05-31-14-11-03](https://user-images.githubusercontent.com/16560492/40783856-09969998-64e4-11e8-9746-f9ec13c1b850.png)\n\nJust open the application and wait until loading. Once opened, it will have the following layout in which the original image is shown at the top-left corner. There is also a label giving brief description about the the three layers and their final output size (output of pooling layer).\n\n![screenshot_2018-05-31-14-11-18](https://user-images.githubusercontent.com/16560492/40783916-3ccbf8b2-64e4-11e8-8de2-a9fa18b3232e.png)\n\nAccording to the NumPyCNN project and its article, the CNN example created has the following architecture:\n1. Conv layer with 2 3x3 filters.\n2. ReLU layer.\n3. Pooling layer.\n4. Conv layer with 3 5x5 filters.\n5. ReLU layer.\n6. Pooling layer.\n7. Conv layer with 1 7x7 filter.\n8. ReLU layer.\n9. Pooling layer.\n\nActually the user can not make changes to the app such as using different image, adding, removing, modifiying a layer.   \nThe application is designed to work on each three successive conv-relu-pool layers, show their outputs, return so that the user can execute the next three layers by clikcing a button at the bottom of the screen. The previous result before clicking the button will be used for further processing. \n\nThe result of applying the first conv-relu-pool layers after pressing the button is shown below. The 2 filters used are for detecting horizontal and vertical edges. The filters used in the remaining two conv layers are randomly generated.\n\n![screenshot_2018-05-31-14-11-27](https://user-images.githubusercontent.com/16560492/40784228-54e4c55e-64e5-11e8-8c88-76e535cb1f7f.png)\n\nPressing the button again will make the app go to the next conv-relu-pool layers and show their outputs as in the figure below:\n\n![screenshot_2018-05-31-14-11-48](https://user-images.githubusercontent.com/16560492/40784262-6f8d086c-64e5-11e8-8b18-0fcdbc33a43f.png)\n\nFinally, the last conv-relu-pool layers are executed after pressing the button again and their results are shown as below:\n\n![screenshot_2018-05-31-14-11-55](https://user-images.githubusercontent.com/16560492/40784373-ca6d221c-64e5-11e8-9877-d73747834175.png)\n\nFor more info.: KDnuggets: https://www.kdnuggets.com/author/ahmed-gad  \nLinkedIn: https://www.linkedin.com/in/ahmedfgad  \nFacebook: https://www.facebook.com/ahmed.f.gadd  \nahmed.f.gad@gmail.com  \nahmed.fawzy@ci.menofia.edu.eg\n","funding_links":["https://opencollective.com/pygad","https://donate.stripe.com/eVa5kO866elKgM0144","http://paypal.me/ahmedfgad"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmedfgad%2Fnumpycnnandroid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahmedfgad%2Fnumpycnnandroid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmedfgad%2Fnumpycnnandroid/lists"}