from diffusers import AutoPipelineForText2Image import torch pipeline = AutoPipelineForText2Image.from_pretrained('dataautogpt3/OpenDalleV1.1', torch_dtype=torch.float16) import gradio as gr def generate_image(ethnicity, gender, age_groups,face_shape, eye_shapes, nose_shapes, eye_colors, eyebrow_types, lip_shapes, hairstyles, hair_colors, ear_types, hair_lengths, facial_hair_styles): # Use the text input to generate an image (you can replace this with your own logic) # For demonstration purposes, we'll just create a simple image with the text on it. 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}' image = pipeline(text_input).images[0] return image ethnicity = ['Indian', 'Pakistani', 'Bangladeshi', 'Chinese', "African", "Asian", "European", "Middle Eastern", "North American", "South American", "Oceanian"] gender = ['Man','Woman'] face_shape = ["Oval", "Round", "Square", "Heart", "Diamond", "Rectangle", "Triangular", "Pear"] eye_shapes = [ "Almond", "Round", "Hooded", "Upturned", "Downturned", "Monolid", "Deep-Set", "Wide-Set", "Close-Set", "Protruding", "Small", "Big" ] nose_shapes = [ "Straight", "Upturned", "Downturned", "Roman", "Button", "Snub", "Wide", "Narrow", "Crooked", "Bulbous", "Hawk", "Celestial" ] eye_colors = [ "Brown", "Blue", "Green", "Hazel", "Amber", "Gray", "Black", "Red", "Violet" ] eyebrow_types = [ "Natural", "Arched", "Straight", "S-shaped", "Rounded", "Flat", "High Arch", "Low Arch", "Tapered", "Angular", "Thick", "Thin" ] lip_shapes = [ "Full", "Thin", "Heart-shaped", "Round", "Wide", "Cupid's bow", "Bow-shaped", "Flat", "Downturned", "Upturned", "Plump", "Straight-across" ] hairstyles = [ "Crew cut", "Quiff", "Buzz cut", "Pompadour", "Slicked back", "Faux hawk", "Undercut", "Taper fade", "Man bun", "Short crop", "Comb over", "Messy spikes", "Side part", "Textured fringe", "Caesar cut", "Ivy League", "Dapper", "Spiky", "Curtain bangs", "Disconnected undercut", "High and tight", "Brushed up", "Wavy", "Surfer hair", "Bald", "Bowl cut", "Dreadlocks", "Mullet", "Afro", "Curls", "Mohawk", "Shaggy", "Classic taper", "Sleek and shiny", "Choppy", "Swept back", "Braided", "Hard part", "Bald fade", "Short and textured", "Combination cut" "Pixie cut", "Bob", "Layered", "Fringe", "Afro", "Dreadlocks", "Ponytail", "Bun", "Top knot", "Cornrows", "Wavy", "Straight", "Curly", "Updo", "Shag", "Braided", "Fishtail braid", "Side-swept", "Spiky", "Long waves", "Messy bun", "Beach waves", "French twist", "Curls", "Balayage", "Curtain bangs", "Feathered", "Mane of curls", "Chignon", "Waterfall braid", "Half-up half-down", "Box braids", "Goddess braids", "Twists", "Sleek and straight", "Pigtails", "Space buns", "Low ponytail", "Vintage curls", "Glamorous updo", "Bouffant", "Bubble ponytail" ] hair_colors = [ "Black", "Brown", "Blonde", "Red", "Auburn", "Caramel", "Silver", "Gray", "Blue", "Green", "Purple", "Pink", "Orange", "Ombre", "Highlights", "Lowlights", "Rose Gold", "Mint Green", "Balayage", "Jet Black" ] ear_types = [ "Attached", "Free-Hanging", "Cupped", "Protruding", "Folded", "Small", "Large", "Elf (Pointed)" ] hair_lengths = [ "Short", "Medium", "Shoulder-length", "Long", "Very Long", "Pixie", "Bob", "Lob (Long Bob)", "Chin-length", "TWA (Teeny Weeny Afro)", "Bald", "Shaved", "Crew cut", "Buzz cut" ] facial_hair_styles = [ "No" "Stubble", "Goatee", "Full Beard", "Circle Beard", "Chin Strap", "Soul Patch", "Van Dyke", "Mutton Chops", "Friendly Mutton Chops", "Hulihee (Huli Huli) Moustache", "Chevron Moustache", "Handlebar Moustache", "Fu Manchu", "Beardstache", "Anchor Beard", "Extended Goatee", "Garibaldi Beard", "Verdi Beard", "Ducktail Beard", "Balbo Beard", "Corporate Beard", "Dali Moustache", "Walrus Moustache", "Pencil Moustache", "Horseshoe Moustache", "Toothbrush Moustache", "Zappa Beard", "Chin Curtain", "Rap Industry Standard Beard", "Lumbersexual Beard", "Yeard (Year Beard)", "Musketeer Beard", "Riker Beard", "The Boxed Beard", "Bandholz Beard", "Friendly Mutton Chops", "Chop Beard", "Friendly Mutton Chops", "Mutton Chops with Goatee", "Moustache with Soul Patch", "Anchor Beard with Chin Strap", "Friendly Mutton Chops with Chin Strap", "Philly" ] age_groups = [ "Teen", "Early 20s", "Mid 20s", "Late 20s", "Early 30s", "Mid 30s", "Late 30s", "Early 40s", "Mid 40s", "Late 40s", "Early 50s", "Mid 50s", "Late 50s", "60s and above" ] iface = gr.Interface( fn=generate_image, # Function to generate image based on text input inputs=[gr.Dropdown(ethnicity), gr.Dropdown(gender),gr.Dropdown(age_groups), gr.Dropdown(face_shape), gr.Dropdown(eye_shapes), gr.Dropdown(nose_shapes), gr.Dropdown(eye_colors), gr.Dropdown(eyebrow_types), gr.Dropdown(lip_shapes), gr.Dropdown(hairstyles), gr.Dropdown(hair_colors), gr.Dropdown(ear_types), gr.Dropdown(hair_lengths), gr.Dropdown(facial_hair_styles)], # Text input outputs="image" # Image output ) iface.launch(debug = True)