hancav commited on
Commit
09365fc
·
1 Parent(s): 0b9f6c2

Update app1.py

Browse files
Files changed (1) hide show
  1. app1.py +8 -27
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 ocr(img):
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
- sentimento = face_analysis[0]["dominant_emotion"]
23
- genero = face_analysis[0]["dominant_gender"]
24
- idade = face_analysis[0]["age"]
25
- raca = face_analysis[0]["dominant_race"]
26
- return("This is a " + str(genero) + ", " + str(idade) + " years old, " + str(raca) + " race and is " + str(sentimento))
27
- #face_analysis
28
-
29
- cara(ipath+"happy-woman.jpg")
30
 
31
- cara(ipath+"angry-man.jpg")
 
 
 
 
 
 
 
 
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)