{"id":19179774,"url":"https://github.com/robi56/faceemr","last_synced_at":"2025-05-07T22:04:42.064Z","repository":{"id":86523264,"uuid":"131168056","full_name":"robi56/FaceEMR","owner":"robi56","description":"Facial Expression Recognition in android where the predictive model built in tensorflow using convolutional neural network","archived":false,"fork":false,"pushed_at":"2018-04-27T21:08:04.000Z","size":53543,"stargazers_count":32,"open_issues_count":0,"forks_count":15,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-07T22:03:29.310Z","etag":null,"topics":["android","convolutional-neural-networks","deep-learning","face-recognition","facial-expression-recognition","image-processing","java","python","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Java","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/robi56.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":"2018-04-26T14:29:58.000Z","updated_at":"2024-06-05T05:42:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"7aade4a3-9ce3-497f-98fb-237a3378ee35","html_url":"https://github.com/robi56/FaceEMR","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robi56%2FFaceEMR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robi56%2FFaceEMR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robi56%2FFaceEMR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robi56%2FFaceEMR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robi56","download_url":"https://codeload.github.com/robi56/FaceEMR/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252961819,"owners_count":21832194,"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","deep-learning","face-recognition","facial-expression-recognition","image-processing","java","python","tensorflow"],"created_at":"2024-11-09T10:44:37.605Z","updated_at":"2025-05-07T22:04:42.037Z","avatar_url":"https://github.com/robi56.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FaceEMR\n## Emotion Recognition from Facial Expression \n\nThe project aims to train a model using tensorflow for facial emotion detection and used the trained model \nas predictor in android facial expression recongnition app.\n\nThe model is trained using  tensorflow python framework and used in android application where the basic langauge is java. \n\nBasically tensorflow provides a c++ api, that can be used in android application. The trained model by python langauge can be integrated with android project  after inclduing tensorflow c++ framework dependencies and using native interface the model can be loaded and called in java class. This is the whole thing. \n\nThe total work of this project is divided into two parts \n1) Devlop  a model in tensoflow using python langauge\n  \n   **KaggleFaceEmotionRecognition** folder contains the work \n2) Devlop an android appication for facial expression recongtion \n  \n   **FaceEMR** folder contains the work \n\n\n### Part 1. Facial Expression Recongition Model developed in Tensorflow \n\nIn this work , I have used a simple Convolutional Neural Network Architecture to train a facial expression dataset.\n\n**1. DataSet:** The dataset is collected from Facial xpression recognition challenge  in kaggle\nThe challenge link https://www.kaggle.com/c/challenges-in-representation-learning-facial-expression-recognition-challenge/\n\nThe data consists of 48x48 pixel grayscale images of faces.The dataset contains facial expression  of seven categories (0=Angry, 1=Disgust, 2=Fear, 3=Happy, 4=Sad, 5=Surprise, 6=Neutral\n\n**2. Model:** \n\n    In this work I have used the below CNN model \n    \n      input_image-\u003econv2d-\u003epooling-\u003econv2d-\u003epooling-\u003econv2d-\u003epooling-\u003edropout-\u003esoftmax\n      \n   The code fragment\n   \n    ```\n    x_image = tf.reshape(x, [-1, 48, 48, 1])\n        #48*48*1\n        conv1 = tf.layers.conv2d(x_image, 64, 3, 1, 'same', activation=tf.nn.relu)\n        #48*48*64\n        pool1 = tf.layers.max_pooling2d(conv1, 2, 2, 'same')\n        #24*24*64\n        conv2 = tf.layers.conv2d(pool1, 128, 3, 1, 'same', activation=tf.nn.relu)\n        #24*24*128\n        pool2 = tf.layers.max_pooling2d(conv2, 2, 2, 'same')\n        #12*12*128\n        conv3 = tf.layers.conv2d(pool2, 256, 3, 1, 'same', activation=tf.nn.relu)\n        #12*12*256\n        pool3 = tf.layers.max_pooling2d(conv3, 2, 2, 'same')\n        #6*6*256\n        flatten = tf.reshape(pool3, [-1, 6*6*256])\n        fc = tf.layers.dense(flatten, 1536, activation=tf.nn.relu)\n        dropout = tf.nn.dropout(fc, keep_prob)\n        logits = tf.layers.dense(dropout, 7)\n        outputs = tf.nn.softmax(logits, name=output_node_name)\n        ```\n  \n**3. Result:** I have used 5000 iterations with batch size 100 and restore the model in protocal buffer file\n\n### Part 2.  Facial Expression Recongition Application in Android\n\nI have used Android Studio for this application. \n\nIntegrating tensorflow dependency in android is really a tedious thing. the good news is that the latest news that android studio manages all dependencis related to tensorflow after adding the dependencies in *build.gradle(Module:app)* file \n\n```\ndependencies {\n    compile 'org.tensorflow:tensorflow-android:+' \n}\n\n```\n\nThe final dependency part looks like \n\n```\ndependencies {\n    implementation fileTree(dir: 'libs', include: ['*.jar'])\n    implementation 'com.android.support:appcompat-v7:26.1.0'\n    implementation 'com.android.support.constraint:constraint-layout:1.1.0'\n    testImplementation 'junit:junit:4.12'\n    androidTestImplementation 'com.android.support.test:runner:1.0.1'\n    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'\n    compile 'org.tensorflow:tensorflow-android:+'\n}\n```\n\n\n\n**1. Designing the UI Components**\n\nHome Screen look like this\n![Home Screen ](/images/home.png)\n\nAfter taking a picture \n![Home Screen ](/images/camera.png)\n\nAnd the final result \n![Home Screen ](/images/detect.png)\n\n\n\n**2. Interacting with the Tensorflow Native Api**\n\nThe *org.tensorflow.contrib.android.TensorFlowInferenceInterface* handles all necessary operation to interact with native api. See more details in https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/android\n\n**3. Finalizing the work** \n\nThere are lots of options for improvement.\n 1. Adding some cool features and increasing model performance using another models\n 2. Tuning the hyperparameters of used cnn model \n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobi56%2Ffaceemr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobi56%2Ffaceemr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobi56%2Ffaceemr/lists"}