hancav commited on
Commit
da905ba
·
1 Parent(s): 73610f9

Create app1.py

Browse files
Files changed (1) hide show
  1. app1.py +31 -0
app1.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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")