nitishkumargundapu793 commited on
Commit
b8bfccf
1 Parent(s): 83bd616
Files changed (2) hide show
  1. app.py +25 -3
  2. requirements.txt +3 -1
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import tensorflow as tf
2
  import gradio as gr
 
3
 
4
  json_file=open(r"dark_s.json","r")
5
  loaded_model_json=json_file.read()
@@ -20,6 +21,24 @@ loaded_model2 = tf.keras.models.model_from_json(loaded_model_json)
20
  loaded_model2.load_weights("wrinkl.h5")
21
 
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  def classifier(Imgarr):
25
  l = []
@@ -45,10 +64,13 @@ def classifier(Imgarr):
45
  else:
46
  l.append("wrinkles on face")
47
 
48
- return Imgarr
 
 
 
49
 
50
- interface = gr.Interface(classifier,gr.inputs.Image(shape=(300,300)),
51
- outputs = "image",
52
  description="Classifier of Aging Signs of Images",
53
  title="Aging Signs Classifier",
54
  examples=[['42.jpg'],['778.jpg'],['1836.png'],['71.jpg'],['56.jpg']])
 
1
  import tensorflow as tf
2
  import gradio as gr
3
+ import cv2
4
 
5
  json_file=open(r"dark_s.json","r")
6
  loaded_model_json=json_file.read()
 
21
  loaded_model2.load_weights("wrinkl.h5")
22
 
23
 
24
+ def image_bounder(img1):
25
+ face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades +'haarcascade_frontalface_default.xml')
26
+ eye_cascade = cv2.CascadeClassifier(cv2.data.haarcascades +'haarcascade_eye.xml')
27
+ gray = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY)
28
+ faces = face_cascade.detectMultiScale(gray, 1.3, 5)
29
+
30
+ for (x,y,w,h) in faces:
31
+ cv2.rectangle(img1,(x,y),(x+w,y+h),(255,255,0),2)
32
+ roi_gray = gray[y:y+h, x:x+w]
33
+ roi_color = img1[y:y+h, x:x+w]
34
+
35
+ eyes = eye_cascade.detectMultiScale(roi_gray)
36
+
37
+ for (ex,ey,ew,eh) in eyes:
38
+ cv2.rectangle(roi_color,(ex,ey),(ex+ew,ey+eh),(0,127,255),2)
39
+
40
+ return img1
41
+
42
 
43
  def classifier(Imgarr):
44
  l = []
 
64
  else:
65
  l.append("wrinkles on face")
66
 
67
+ return "Predictions are : "+str(l)
68
+
69
+ def out(Imgarr):
70
+ return [image_bounder(Imgarr),classifier(Imgarr)]
71
 
72
+ interface = gr.Interface(out,gr.inputs.Image(shape=(300,300)),
73
+ outputs = ["image","text"],
74
  description="Classifier of Aging Signs of Images",
75
  title="Aging Signs Classifier",
76
  examples=[['42.jpg'],['778.jpg'],['1836.png'],['71.jpg'],['56.jpg']])
requirements.txt CHANGED
@@ -1,3 +1,5 @@
1
  tensorflow
2
  gradio
3
- numpy
 
 
 
1
  tensorflow
2
  gradio
3
+ numpy
4
+ cv2
5
+ opencv-python