Spaces:
Runtime error
Runtime error
File size: 6,227 Bytes
a4f0d2c b8f716b a4f0d2c | 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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | 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)
|