Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

digital_makeup.py 1.4 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  1. from PIL import Image, ImageDraw
  2. import face_recognition
  3. # Load the jpg file into a numpy array
  4. image = face_recognition.load_image_file("biden.jpg")
  5. # Find all facial features in all the faces in the image
  6. face_landmarks_list = face_recognition.face_landmarks(image)
  7. pil_image = Image.fromarray(image)
  8. for face_landmarks in face_landmarks_list:
  9. d = ImageDraw.Draw(pil_image, 'RGBA')
  10. # Make the eyebrows into a nightmare
  11. d.polygon(face_landmarks['left_eyebrow'], fill=(68, 54, 39, 128))
  12. d.polygon(face_landmarks['right_eyebrow'], fill=(68, 54, 39, 128))
  13. d.line(face_landmarks['left_eyebrow'], fill=(68, 54, 39, 150), width=5)
  14. d.line(face_landmarks['right_eyebrow'], fill=(68, 54, 39, 150), width=5)
  15. # Gloss the lips
  16. d.polygon(face_landmarks['top_lip'], fill=(150, 0, 0, 128))
  17. d.polygon(face_landmarks['bottom_lip'], fill=(150, 0, 0, 128))
  18. d.line(face_landmarks['top_lip'], fill=(150, 0, 0, 64), width=8)
  19. d.line(face_landmarks['bottom_lip'], fill=(150, 0, 0, 64), width=8)
  20. # Sparkle the eyes
  21. d.polygon(face_landmarks['left_eye'], fill=(255, 255, 255, 30))
  22. d.polygon(face_landmarks['right_eye'], fill=(255, 255, 255, 30))
  23. # Apply some eyeliner
  24. d.line(face_landmarks['left_eye'] + [face_landmarks['left_eye'][0]], fill=(0, 0, 0, 110), width=6)
  25. d.line(face_landmarks['right_eye'] + [face_landmarks['right_eye'][0]], fill=(0, 0, 0, 110), width=6)
  26. pil_image.show()
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...