From c1b350ab7714154ffcb73133999736a5f9363d3c Mon Sep 17 00:00:00 2001 From: Pei-Yun Sun Date: Tue, 20 Oct 2020 01:26:09 +1100 Subject: [PATCH] fix UI --- .../general_controller.cpython-38.pyc | Bin 6207 -> 6207 bytes .../prediction_controller.cpython-38.pyc | Bin 1955 -> 1955 bytes src/controller/general_controller.py | 35 ------------------ src/deepface/DeepFaceLite.py | 14 +++++-- .../__pycache__/DeepFaceLite.cpython-38.pyc | Bin 2465 -> 2572 bytes src/deepface_lite.ipynb | 22 +++++------ .../__pycache__/__init__.cpython-38.pyc | Bin 0 -> 144 bytes .../__pycache__/feedback.cpython-38.pyc | Bin 0 -> 838 bytes .../__pycache__/prediction.cpython-38.pyc | Bin 0 -> 522 bytes src/templates/base.html | 5 +-- src/templates/breedPage.html | 32 ---------------- src/templates/homePage.html | 4 +- .../__pycache__/public_route.cpython-38.pyc | Bin 755 -> 593 bytes src/views/public_route.py | 5 --- 14 files changed, 24 insertions(+), 93 deletions(-) create mode 100644 src/models/__pycache__/__init__.cpython-38.pyc create mode 100644 src/models/__pycache__/feedback.cpython-38.pyc create mode 100644 src/models/__pycache__/prediction.cpython-38.pyc delete mode 100644 src/templates/breedPage.html diff --git a/src/controller/__pycache__/general_controller.cpython-38.pyc b/src/controller/__pycache__/general_controller.cpython-38.pyc index 2623481dd57d21b2bd2037d23c5c46ac20477b3c..f13adf3946a3fd2da3ca4997a1c59fd1a34dad58 100644 GIT binary patch delta 57 zcmdmQu-||$l$V!_0SNxh?Tw$MzL9SSJ0suZmxv!> MSL0w566Rn80O5oW9smFU diff --git a/src/controller/__pycache__/prediction_controller.cpython-38.pyc b/src/controller/__pycache__/prediction_controller.cpython-38.pyc index 6f02c03c635e44cb09a294638662ede9ac012dc6..290ad6e51f20d536642747106653209cc7b6b70b 100644 GIT binary patch delta 19 ZcmZ3?znGsZl$V!_0SK}eZseND4ge{x1Wy0} delta 19 ZcmZ3?znGsZl$V!_0SFp;H*(En2LLI^1W*6~ diff --git a/src/controller/general_controller.py b/src/controller/general_controller.py index 2c8c4ae..1fbee31 100644 --- a/src/controller/general_controller.py +++ b/src/controller/general_controller.py @@ -9,41 +9,6 @@ import copy api = Namespace('general', path='/', description='general information related to app') -# @api.route('/get-breed-info') -# class BreedList(Resource): -# @api.doc('get breed information from csv') -# def get(self): -# """ -# return the breed information, which gets from wikipedia -# :return: list of breed information -# """ -# breed_info = {} -# for animal_type in CONSTANTS['ANIMAL_TYPE']: -# with open('wikiFile/' + animal_type + '.csv') as csv_file: -# csv_reader = csv.reader(csv_file, delimiter=',') -# line_count = 0 -# json_title = [] -# animal_list = [] -# for row in csv_reader: -# if line_count == 0: -# json_title = row -# line_count += 1 -# else: -# info_obj = { -# json_title[0]: row[0], -# json_title[1]: row[1], -# json_title[2]: row[2], -# json_title[3]: row[3], -# json_title[4]: row[4], -# } -# animal_list.append(info_obj) -# line_count += 1 -# csv_file.close() -# breed_info[animal_type] = animal_list - -# return send_json_response(breed_info, 200) - - @api.route('/get-app-info') class AppInfo(Resource): @api.doc('return the app developer information') diff --git a/src/deepface/DeepFaceLite.py b/src/deepface/DeepFaceLite.py index ce78975..3d0c3ff 100644 --- a/src/deepface/DeepFaceLite.py +++ b/src/deepface/DeepFaceLite.py @@ -60,19 +60,24 @@ class DeepFaceLite(object): sum_of_predictions = emotion_predictions.sum() - all_emotions = {} + all_emotions = [] for j in range(0, len(emotion_labels)): emotion_label = emotion_labels[j] emotion_prediction = 100 * emotion_predictions[j] / sum_of_predictions - all_emotions[emotion_label] = emotion_prediction + # all_emotions[emotion_label] = '{:.4f}'.format(emotion_prediction) + max_score = 100 * np.max(emotion_predictions) / sum_of_predictions + + all_emotions.append('{}: {:.4f}'.format(emotion_label, emotion_prediction)) emotion = { 'all': all_emotions, 'dominant': emotion_labels[np.argmax(emotion_predictions)], - 'dominant_score': np.max(emotion_predictions) + 'dominant_score': '{:.4f}'.format(max_score) } + print(emotion) + # --- age --- age_predictions = self.age_model.predict(imgs_224[i])[0,:] apparent_age = Age.findApparentAge(age_predictions) @@ -88,7 +93,8 @@ class DeepFaceLite(object): # resp_obj = json.loads(resp_obj) resp_obj = { - 'age': apparent_age, + 'id': i, + 'age': np.round(apparent_age), 'gender': gender, 'emotion': emotion } diff --git a/src/deepface/__pycache__/DeepFaceLite.cpython-38.pyc b/src/deepface/__pycache__/DeepFaceLite.cpython-38.pyc index 145ab70643ef400b1f5a13535335267ba47c402a..12dad7d8b8369a0988985b6d9e678ce1a3f69382 100644 GIT binary patch delta 573 zcmX|-&x_MQ6vs0&%_L2eG;Py%7gtzWuoQnFx`-5!1w{nuN%j)dC3MnK+a~RF>W|$S zJk-;oBFuHc#Dks%{{X@NB6klSJc&02r&Szy^X7fN-#5&>toG7(_Z`R5)MDwYgAdk6 z_ZYbwsx(#HR55=c-=iB~Pku$$pAR(QGDvKOcxefi@Rs&qPn3Cymp3)x5r^BWldo~- zlqM>~VMc0lI|KhnmAh$?xT(cGUddnvfHphkE-xuxY31A0NLi`X3=r=Gi5jzcZK+&b zd*q}#m+uOG*=KHA=6(i5U13kYEj0HV>kAsH%^txwfZib$(Tx57w7RDENli3)QPB#o zXMi_(jrb=8VR17pa%=sZYuw;wAKug2b&2$ct-y$*1*74Z0yT_pL~V!Gk?3q6buRAq z#UcKiCDX5*F63}Xaug1t91o(HL^L;|Ny3In+^)*cdS?es!lyY7r&FcoxS!BT$O0VF z!HVlsI*ggb_>8I3WD%40hP;HoI6+aV2lHM+BifQb@l|kEo;S9^ZP_)pTd)d!1c43A z-x!-{3s`6idH@3t6m$qo00I1k4f)#Wf?e4yHsudv<^+1Ym`tD1bLu~VoSBUa0qQ-z n9O$EnhI48toP)c8#iDqg(Ed1i5(zS)EG^1SoRkN16G-bL$<|Fqe35S;7k{fnQC zZ~l_{J$Txn`=H`beWiDBq<+!;!zrr#l5nr2(mlgxC0droh;#YOKW9IZ;ks1T%&f}|4ge;qGLyWF?w#NbXT72tZ@~oPsZlK#>K`4 z%y~2N0gEl(s=8_Pp9U9nkGHF?jAU1aJcK+)+ACi=YmCv!p0uPrCQs0?qi&ebJK9Q< z(^AB9f#GMrIW+a%yxFHC8c!0l-hlKmj!sv23h@V5GBUA}i0A`uO+T^BWINNNp;O$-tO3$Q~8_ON}g`kf`;DSco6*jQeq@R+ST9B5QoT^`3l&qhdpOTtWtREkrnU`4-AFo$Xd5gmaC|H`4 MY6mjzGY~TX08fb_F8}}l literal 0 HcmV?d00001 diff --git a/src/models/__pycache__/feedback.cpython-38.pyc b/src/models/__pycache__/feedback.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..36a4019461e9a5ac14cc36f427fefa6949bf8231 GIT binary patch literal 838 zcmZuwy>in)5Wdsz*|CXn$0MkT8t51%Lqd{*aTBLeqmi`hjEsJqJE?G&8EE|=d8KQq zcm*2RlVqa-PIIf>?|#1B{iKKae9CA%9}e*^&e(SojE6(PB~A5~3^3pYD|y5@yJcX3 z{f&W*d~1ERBbyKhTtZwz970_1?pfgfppz`%+JZDQ?s(V~T+&o`WROK1SY)BSb%29) z;E_A>J@Wkl7bAQ!!lz&prK8Vp5Ft&nFIRQdVAZT&xE2zh+FT;6f-^1RxJpWlV?B-I zvWB)W{w$84+N9`Lq(wRDv-?Ko)#FW$1!$+)?@-TENw*&v^z36@7noH2mPNOCRZEFk zQ=wA&9Lu`N>*{o1IRK+gFHA0otusI0g%1j)3U`?A+e(GEd2`pMAt3HHNrs`4Sx6~k zp~B5j=EZI=O)rgH$|x%MY%7E41EBCvw|eijxqL}xMpGF+!3BTCJ8Ttr+N0Yx`D4$z_?xxMSBqm3 X-KqakXz{-PRzA?b!j!3RW-rBWa-h)H literal 0 HcmV?d00001 diff --git a/src/models/__pycache__/prediction.cpython-38.pyc b/src/models/__pycache__/prediction.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ff4ef70f372630d70cef185610fdbdb2bd3a46a2 GIT binary patch literal 522 zcmYjOy-ve05Vn)FxSM9V*IzDg^D4#Y%Hm08IL$;V+IbmpA1~& zOXtIlT=1S*(D|W#Ea29GdD6f`b14|oG}q*iMI2b<00&3$$VG420V=ZQQTG5J5f)p% z2OYYiYyC%!ppr@zx%HDGO|iwt<&HN~(jYXhYDL^6@U4(Ck293g`ch^E)MTTTL zRX8)KO<1COt8){MRdrv_LqIGSae|@INl4N#r7gQwF3UIFyj=4YMvxO+@IH+VI|)47 lO^SS>URvQ|R3vqVd9_LJFK^K)owwqq?f;fHC7X8p?mxlVh!Ow* literal 0 HcmV?d00001 diff --git a/src/templates/base.html b/src/templates/base.html index 2199960..94cb13c 100644 --- a/src/templates/base.html +++ b/src/templates/base.html @@ -2,7 +2,7 @@ - Pet Smile + HappyPeople @@ -23,7 +23,7 @@