CoolFace
Apppublic

SparshRastogi/ImageGeneration

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
app.py305 linesDownload Raw Back to root
1from diffusers import AutoPipelineForText2Image2import torch3 4pipeline = AutoPipelineForText2Image.from_pretrained('dataautogpt3/OpenDalleV1.1', torch_dtype=torch.float16)5import gradio as gr6 7 8def generate_image(ethnicity, gender, age_groups,face_shape, eye_shapes, nose_shapes,9                   eye_colors, eyebrow_types, lip_shapes, hairstyles, hair_colors, ear_types,10                   hair_lengths, facial_hair_styles):11    # Use the text input to generate an image (you can replace this with your own logic)12    # For demonstration purposes, we'll just create a simple image with the text on it.13    text_input = f'A full facial shot of {ethnicity} {gender} {age_groups} with {face_shape} face {eye_shapes} with {eye_colors} iris {eyebrow_types} brows {nose_shapes} nose,{lip_shapes} lips,{ear_types} ears,{hair_colors} {hair_lengths} {hairstyles} and {facial_hair_styles}'14    image = pipeline(text_input).images[0]15    return image16 17ethnicity = ['Indian',18 'Pakistani',19 'Bangladeshi',20 'Chinese',21 "African",22    "Asian",23    "European",24    "Middle Eastern",25    "North American",26    "South American",27    "Oceanian"]28gender = ['Man','Woman']29face_shape = ["Oval", "Round", "Square", "Heart", "Diamond", "Rectangle", "Triangular", "Pear"]30eye_shapes = [31    "Almond",32    "Round",33    "Hooded",34    "Upturned",35    "Downturned",36    "Monolid",37    "Deep-Set",38    "Wide-Set",39    "Close-Set",40    "Protruding",41    "Small",42    "Big"43]44nose_shapes = [45    "Straight",46    "Upturned",47    "Downturned",48    "Roman",49    "Button",50    "Snub",51    "Wide",52    "Narrow",53    "Crooked",54    "Bulbous",55    "Hawk",56    "Celestial"57]58eye_colors = [59    "Brown",60    "Blue",61    "Green",62    "Hazel",63    "Amber",64    "Gray",65    "Black",66    "Red",67    "Violet"68]69eyebrow_types = [70    "Natural",71    "Arched",72    "Straight",73    "S-shaped",74    "Rounded",75    "Flat",76    "High Arch",77    "Low Arch",78    "Tapered",79    "Angular",80    "Thick",81    "Thin"82]83lip_shapes = [84    "Full",85    "Thin",86    "Heart-shaped",87    "Round",88    "Wide",89    "Cupid's bow",90    "Bow-shaped",91    "Flat",92    "Downturned",93    "Upturned",94    "Plump",95    "Straight-across"96]97hairstyles = [98     "Crew cut",99    "Quiff",100    "Buzz cut",101    "Pompadour",102    "Slicked back",103    "Faux hawk",104    "Undercut",105    "Taper fade",106    "Man bun",107    "Short crop",108    "Comb over",109    "Messy spikes",110    "Side part",111    "Textured fringe",112    "Caesar cut",113    "Ivy League",114    "Dapper",115    "Spiky",116    "Curtain bangs",117    "Disconnected undercut",118    "High and tight",119    "Brushed up",120    "Wavy",121    "Surfer hair",122    "Bald",123    "Bowl cut",124    "Dreadlocks",125    "Mullet",126    "Afro",127    "Curls",128    "Mohawk",129    "Shaggy",130    "Classic taper",131    "Sleek and shiny",132    "Choppy",133    "Swept back",134    "Braided",135    "Hard part",136    "Bald fade",137    "Short and textured",138    "Combination cut"139     "Pixie cut",140    "Bob",141    "Layered",142    "Fringe",143    "Afro",144    "Dreadlocks",145    "Ponytail",146    "Bun",147    "Top knot",148    "Cornrows",149    "Wavy",150    "Straight",151    "Curly",152    "Updo",153    "Shag",154    "Braided",155    "Fishtail braid",156    "Side-swept",157    "Spiky",158    "Long waves",159    "Messy bun",160    "Beach waves",161    "French twist",162    "Curls",163    "Balayage",164    "Curtain bangs",165    "Feathered",166    "Mane of curls",167    "Chignon",168    "Waterfall braid",169    "Half-up half-down",170    "Box braids",171    "Goddess braids",172    "Twists",173    "Sleek and straight",174    "Pigtails",175    "Space buns",176    "Low ponytail",177    "Vintage curls",178    "Glamorous updo",179    "Bouffant",180    "Bubble ponytail"181]182hair_colors = [183    "Black",184    "Brown",185    "Blonde",186    "Red",187    "Auburn",188    "Caramel",189    "Silver",190    "Gray",191    "Blue",192    "Green",193    "Purple",194    "Pink",195    "Orange",196    "Ombre",197    "Highlights",198    "Lowlights",199    "Rose Gold",200    "Mint Green",201    "Balayage",202    "Jet Black"203]204ear_types = [205    "Attached",206    "Free-Hanging",207    "Cupped",208    "Protruding",209    "Folded",210    "Small",211    "Large",212    "Elf (Pointed)"213]214hair_lengths = [215    "Short",216    "Medium",217    "Shoulder-length",218    "Long",219    "Very Long",220    "Pixie",221    "Bob",222    "Lob (Long Bob)",223    "Chin-length",224    "TWA (Teeny Weeny Afro)",225    "Bald",226    "Shaved",227    "Crew cut",228    "Buzz cut"229]230facial_hair_styles = [231    "No"232    "Stubble",233    "Goatee",234    "Full Beard",235    "Circle Beard",236    "Chin Strap",237    "Soul Patch",238    "Van Dyke",239    "Mutton Chops",240    "Friendly Mutton Chops",241    "Hulihee (Huli Huli) Moustache",242    "Chevron Moustache",243    "Handlebar Moustache",244    "Fu Manchu",245    "Beardstache",246    "Anchor Beard",247    "Extended Goatee",248    "Garibaldi Beard",249    "Verdi Beard",250    "Ducktail Beard",251    "Balbo Beard",252    "Corporate Beard",253    "Dali Moustache",254    "Walrus Moustache",255    "Pencil Moustache",256    "Horseshoe Moustache",257    "Toothbrush Moustache",258    "Zappa Beard",259    "Chin Curtain",260    "Rap Industry Standard Beard",261    "Lumbersexual Beard",262    "Yeard (Year Beard)",263    "Musketeer Beard",264    "Riker Beard",265    "The Boxed Beard",266    "Bandholz Beard",267    "Friendly Mutton Chops",268    "Chop Beard",269    "Friendly Mutton Chops",270    "Mutton Chops with Goatee",271    "Moustache with Soul Patch",272    "Anchor Beard with Chin Strap",273    "Friendly Mutton Chops with Chin Strap",274    "Philly"275]276age_groups = [277    "Teen",278    "Early 20s",279    "Mid 20s",280    "Late 20s",281    "Early 30s",282    "Mid 30s",283    "Late 30s",284    "Early 40s",285    "Mid 40s",286    "Late 40s",287    "Early 50s",288    "Mid 50s",289    "Late 50s",290    "60s and above"291]292iface = gr.Interface(293    fn=generate_image,  # Function to generate image based on text input294    inputs=[gr.Dropdown(ethnicity), gr.Dropdown(gender),gr.Dropdown(age_groups),295            gr.Dropdown(face_shape), gr.Dropdown(eye_shapes),296            gr.Dropdown(nose_shapes), gr.Dropdown(eye_colors),297            gr.Dropdown(eyebrow_types), gr.Dropdown(lip_shapes),298            gr.Dropdown(hairstyles), gr.Dropdown(hair_colors),299            gr.Dropdown(ear_types), gr.Dropdown(hair_lengths),300            gr.Dropdown(facial_hair_styles)],  # Text input301    outputs="image"  # Image output302)303 304iface.launch(debug = True)305