Spaces:
Runtime error
Runtime error
Update app1.py
Browse files
app1.py
CHANGED
@@ -1,31 +1,12 @@
|
|
1 |
-
|
2 |
-
!sudo apt-get install tesseract-ocr
|
3 |
-
!pip install pytesseract
|
4 |
-
!pip install -q gradio
|
5 |
-
import pytesseract
|
6 |
-
import gradio
|
7 |
-
!pip install DeepFace
|
8 |
from deepface import DeepFace
|
|
|
9 |
|
10 |
-
def
|
11 |
-
text = pytesseract.image_to_string(img)
|
12 |
-
return(text)
|
13 |
-
|
14 |
-
ipath="/content/drive/MyDrive/Deep-Learning/Face-Analysis/"
|
15 |
-
|
16 |
-
ocr(ipath+'image2ocr.jpg')
|
17 |
-
|
18 |
-
gradio.Interface(ocr,"image","text").launch(share=True)
|
19 |
-
|
20 |
-
def cara(img):
|
21 |
face_analysis = DeepFace.analyze(img_path = img)
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
return("This is a " + str(
|
27 |
-
#face_analysis
|
28 |
-
|
29 |
-
cara(ipath+"happy-woman.jpg")
|
30 |
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from deepface import DeepFace
|
2 |
+
import gradio as gr
|
3 |
|
4 |
+
def face_analysis(img):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
face_analysis = DeepFace.analyze(img_path = img)
|
6 |
+
emotion = face_analysis[0]["dominant_emotion"]
|
7 |
+
gender = face_analysis[0]["dominant_gender"]
|
8 |
+
age = face_analysis[0]["age"]
|
9 |
+
race = face_analysis[0]["dominant_race"]
|
10 |
+
return("This is a " + str(gender) + ", " + str(age) + " years old, " + str(race) + " race and is " + str(emotion))
|
|
|
|
|
|
|
11 |
|
12 |
+
gr.Interface(face_analysis,"image","text").launch(share=True)
|