Francesco Pochetti commited on
Commit
2cc56c8
1 Parent(s): 593bcb6

adding files

Browse files
Files changed (5) hide show
  1. app.py +35 -0
  2. crowd.jpeg +0 -0
  3. crowd1.jpeg +0 -0
  4. family.jpeg +0 -0
  5. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import face_recognition
2
+ import cv2
3
+ import gradio as gr
4
+ from PIL import Image
5
+ import numpy as np
6
+
7
+ def run(image):
8
+ image.thumbnail((1280, 1280))
9
+ image = np.array(image)
10
+ face_locations = face_recognition.face_locations(image, model="cnn")
11
+
12
+ for top, right, bottom, left in face_locations:
13
+ face_image = image[top:bottom, left:right]
14
+ face_image = cv2.GaussianBlur(face_image, (99, 99), 30)
15
+ image[top:bottom, left:right] = face_image
16
+
17
+ return Image.fromarray(image)
18
+
19
+ content_image_input = gr.inputs.Image(label="Content Image", type="pil")
20
+
21
+ description="Privacy first! Upload an image of a groupf of people and blur their faces automatically."
22
+ article="""
23
+ Demo built with the face_recognition package and opencv, based on
24
+ <a href='https://github.com/ageitgey/face_recognition/blob/master/examples/blur_faces_on_webcam.py' target='_blank'>this</a> example.
25
+ """
26
+ examples = [["family.jpeg"], ["crowd.jpeg"], ["crowd1.jpeg"]]
27
+
28
+ app_interface = gr.Interface(fn=run,
29
+ inputs=[content_image_input],
30
+ outputs="image",
31
+ title="Blurry Faces",
32
+ description=description,
33
+ examples=examples,
34
+ article=article)
35
+ app_interface.launch()
crowd.jpeg ADDED
crowd1.jpeg ADDED
family.jpeg ADDED
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ opencv-python==4.5.5
2
+ face_recognition==1.2.3