Awesome Avatar Generator in Python
Avatar Generator in Python: We gonna generate our own custom avatar with python. So let’s jump into in.
Installation
To generate avatars we use py-avataaars python module. Using this you can generate avatars in PNG and SVG formats.
pip install py-avataaars
Code
Example #1: Basic
from py_avataaars import PyAvataaar
avatar = PyAvataaar()
avatar.render_png_file('avatar1.png')
#follow @code_snail
Output
Default avatar
Example 2: Specify each part of the avatar
import py_avataaars as pa
avatar = pa.PyAvataaar(
style=pa.AvatarStyle.CIRCLE,
skin_color=pa.SkinColor.LIGHT,
hair_color=pa.HairColor.BROWN,
facial_hair_type=pa.FacialHairType.DEFAULT,
facial_hair_color=pa.FacialHairColor.BLACK,
top_type=pa.TopType.SHORT_HAIR_SHORT_FLAT,
hat_color=pa.ClotheColor.BLACK,
mouth_type=pa.MouthType.SMILE,
eye_type=pa.EyesType.DEFAULT,
eyebrow_type=pa.EyebrowType.DEFAULT,
nose_type=pa.NoseType.DEFAULT,
accessories_type=pa.AccessoriesType.DEFAULT,
clothe_type=pa.ClotheType.GRAPHIC_SHIRT,
clothe_color=pa.ClotheColor.HEATHER,
clothe_graphic_type=pa.ClotheGraphicType.BAT,
)
avatar.render_png_file('avatar2.png')
#follow @code_snail
Output
Options
classes | Options |
---|---|
**AvatarStyle** | |
style= |
| AvatarStyle.CIRCLE
|
| AvatarStyle.TRANSPARENT
|
| **SkinColor**
skin_color=
| SkinColor.TANNED
|
| SkinColor.YELLOW
|
| SkinColor.PALE
|
| SkinColor.LIGHT
|
| SkinColor.BROWN
|
| SkinColor.DARK_BROWN
|
| SkinColor.BLACK
|
| **HairColor**
hair_color=
| HairColor.AUBURN
|
| HairColor.BLACK
|
| HairColor.BLONDE
|
| HairColor.BLONDE_GOLDEN
|
| HairColor.BROWN
|
| HairColor.BROWN_DARK
|
| HairColor.PASTEL_PINK
|
| HairColor.PLATINUM
|
| HairColor.RED
|
| HairColor.SILVER_GRAY
|
| **TopType**
top_type=
| TopType.NO_HAIR
|
| TopType.EYE_PATCH
|
| TopType.HAT
|
| TopType.HIJAB
|
| TopType.TURBAN
|
| TopType.WINTER_HAT1
|
| TopType.WINTER_HAT2
|
| TopType.WINTER_HAT3
|
| TopType.WINTER_HAT4
|
| TopType.LONG_HAIR_BIG_HAIR
|
| TopType.LONG_HAIR_BOB
|
| TopType.LONG_HAIR_BUN
|
| TopType.LONG_HAIR_CURLY
|
| TopType.LONG_HAIR_CURVY
|
| TopType.LONG_HAIR_DREADS
|
| TopType.LONG_HAIR_FRIDA
|
| TopType.LONG_HAIR_FRO
|
| TopType.LONG_HAIR_FRO_BAND
|
| TopType.LONG_HAIR_NOT_TOO_LONG
|
| TopType.LONG_HAIR_SHAVED_SIDES
|
| TopType.LONG_HAIR_MIA_WALLACE
|
| TopType.LONG_HAIR_STRAIGHT
|
| TopType.LONG_HAIR_STRAIGHT2
|
| TopType.LONG_HAIR_STRAIGHT_STRAND
|
| TopType.SHORT_HAIR_DREADS_01
|
| TopType.SHORT_HAIR_DREADS_02
|
| TopType.SHORT_HAIR_FRIZZLE
|
| TopType.SHORT_HAIR_SHAGGY_MULLET
|
| TopType.SHORT_HAIR_SHORT_CURLY
|
| TopType.SHORT_HAIR_SHORT_FLAT
|
| TopType.SHORT_HAIR_SHORT_ROUND
|
| TopType.SHORT_HAIR_SHORT_WAVED
|
| TopType.SHORT_HAIR_SIDES
|
| TopType.SHORT_HAIR_THE_CAESAR
|
| TopType.SHORT_HAIR_THE_CAESAR_SIDE_PART
|
| **FacialHairColor**
facial_hair_color=
| FacialHairColor.AUBURN
|
| FacialHairColor.BLACK
|
| FacialHairColor.BLONDE
|
| FacialHairColor.BLONDE_GOLDEN
|
| FacialHairColor.BROWN
|
| FacialHairColor.BROWN_DARK
|
| FacialHairColor.PLATINUM
|
| FacialHairColor.RED
|
| **FacialHairType**
facial_hair_type=
| FacialHairType.DEFAULT
|
| FacialHairType.BEARD_MEDIUM
|
| FacialHairType.BEARD_LIGHT
|
| FacialHairType.BEARD_MAJESTIC
|
| FacialHairType.MOUSTACHE_FANCY
|
| FacialHairType.MOUSTACHE_MAGNUM
|
| **ClotheType**
clothe_type=
| ClotheType.BLAZER_SHIRT
|
| ClotheType.BLAZER_SWEATER
|
| ClotheType.COLLAR_SWEATER
|
| ClotheType.GRAPHIC_SHIRT
|
| ClotheType.HOODIE
|
| ClotheType.OVERALL
|
| ClotheType.SHIRT_CREW_NECK
|
| ClotheType.SHIRT_SCOOP_NECK
|
| ClotheType.SHIRT_V_NECK
|
| **ClotheGraphicType**
clothe_graphic_type=
| ClotheGraphicType.BAT
|
| ClotheGraphicType.CUMBIA
|
| ClotheGraphicType.DEER
|
| ClotheGraphicType.DIAMOND
|
| ClotheGraphicType.HOLA
|
| ClotheGraphicType.PIZZA
|
| ClotheGraphicType.RESIST
|
| ClotheGraphicType.SELENA
|
| ClotheGraphicType.BEAR
|
| ClotheGraphicType.SKULL_OUTLINE
|
| ClotheGraphicType.SKULL
|
| **ClotheColor**
clothe_color=
hat_color=
| ClotheColor.BLACK
|
| ClotheColor.BLUE_01
|
| ClotheColor.BLUE_02
|
| ClotheColor.BLUE_03
|
| ClotheColor.GRAY_01
|
| ClotheColor.GRAY_02
|
| ClotheColor.HEATHER
|
| ClotheColor.PASTEL_BLUE
|
| ClotheColor.PASTEL_GREEN
|
| ClotheColor.PASTEL_ORANGE
|
| ClotheColor.PASTEL_RED
|
| ClotheColor.PASTEL_YELLOW
|
| ClotheColor.PINK
|
| ClotheColor.RED
|
| ClotheColor.WHITE
|
| **MouthType**
mouth_type=
| MouthType.DEFAULT
|
| MouthType.CONCERNED
|
| MouthType.DISBELIEF
|
| MouthType.EATING
|
| MouthType.GRIMACE
|
| MouthType.SAD
|
| MouthType.SCREAM_OPEN
|
| MouthType.SERIOUS
|
| MouthType.SMILE
|
| MouthType.TONGUE
|
| MouthType.TWINKLE
|
| MouthType.VOMIT
|
| **NoseType**
nose_type=
| NoseType.DEFAULT
|
| **EyesType**
eye_type=
| EyesType.DEFAULT
|
| EyesType.CLOSE
|
| EyesType.CRY
|
| EyesType.DIZZY
|
| EyesType.EYE_ROLL
|
| EyesType.HAPPY
|
| EyesType.HEARTS
|
| EyesType.SIDE
|
| EyesType.SQUINT
|
| EyesType.SURPRISED
|
| EyesType.WINK
|
| EyesType.WINK_WACKY
|
| **EyebrowType**
eyebrow_type=
| EyebrowType.DEFAULT
|
| EyebrowType.DEFAULT_NATURAL
|
| EyebrowType.ANGRY
|
| EyebrowType.ANGRY_NATURAL
|
| EyebrowType.FLAT_NATURAL
|
| EyebrowType.RAISED_EXCITED
|
| EyebrowType.RAISED_EXCITED_NATURAL
|
| EyebrowType.SAD_CONCERNED
|
| EyebrowType.SAD_CONCERNED_NATURAL
|
| EyebrowType.UNI_BROW_NATURAL
|
| EyebrowType.UP_DOWN
|
| EyebrowType.UP_DOWN_NATURAL
|
| EyebrowType.FROWN_NATURAL
|
| **AccessoriesType**
accessories_type=
| AccessoriesType.DEFAULT
|
| AccessoriesType.KURT
|
| AccessoriesType.PRESCRIPTION_01
|
| AccessoriesType.PRESCRIPTION_02
|
| AccessoriesType.ROUND
|
| AccessoriesType.SUNGLASSES
|
| AccessoriesType.WAYFARERS
|
You can also explore py-avataaars options at Avatars Generator
I hope you like this awesome avatar generator in python. Generate your avatar and post in your Instagram story and tag me (@code_snail).
Also see,