fffiloni's picture
add gradio info
926db45 verified
import gradio as gr
from gradio_client import Client, handle_file
def get_flux_kontext(image, prompt, token):
client = Client("black-forest-labs/FLUX.1-Kontext-Dev", hf_token=token)
result = client.predict(
input_image=handle_file(image),
prompt=prompt,
seed=0,
randomize_seed=True,
guidance_scale=2.5,
steps=28,
api_name="/infer"
)
print(result)
return result[0]
def infer(robot_img_in, doll_prompt, oauth_token: gr.OAuthToken):
gradio_auth_token = oauth_token.token
doll_prompt = f"keep the robot's head exactly as it is, do not change its shape, size, eyes or antennas. the robot is wearing {doll_prompt}, designed for a white 3D printed plastic torso only, no arms or legs, outfit must be white and minimalist."
gr.Info("Now calling the FLUX.1-Kontext-Dev gradio space with custom prompt ...")
flux_res = get_flux_kontext(robot_img_in, doll_prompt, gradio_auth_token)
return flux_res
robot_outfits = [
"a white chest panel with a sculpted suit front and a miniature tie",
"a pale white vest over a high-collar shirtplate",
"a matte white blazer shell with a raised mock turtleneck",
"a sculpted jacket shell with engraved scarf detail around the neck",
"a glossy formal vest with a crisp bowtie design",
"a smooth white blazer overlay with a collared panel",
"a tailored-look chest piece with a central tie ridge and faux vest cut",
"a belted trench-style wrap with an etched scarf drape",
"a paneled vest with layered chest seams and angled collar",
"a relaxed, soft-textured wrap vest with a button-down front",
"a formal tuxedo panel with notched lapel and sculpted bowtie",
"a structured jacket front with a subtle tie impression and decorative ridge",
"a soft-formed crew neck overlay with a faux-jacket wrap",
"a longline wrap with an embossed scarf flowing down the front",
"a flowing summer-style wrap with floral etchings and a tiny sun visor",
"a hoodie-shaped upper wrap with a smooth neck dome and raised seam",
"a rounded rain-slick wrap with a high collar and umbrella slot",
"a moto-jacket shell with etched fasteners and layered lapels",
"a smooth pullover shell with a wrap-skirt texture embossed in the lower torso",
"a kimono-inspired upper robe with an obi-style belt wrapping the torso",
"a sleeveless dress form with sculpted necklace detail",
"a buttoned cardigan-style wrap with ribbed neck detailing",
"a cargo-style vest with small pouch bumps and belt sculpting",
"a long coat cut with double seams and flowing edge grooves",
"a scoop-collar blouse with skirt panel overlays",
"a bibbed chest wrap with suspender-like ridges",
"a winter parka wrap with a fluffy collar texture and ear muffs",
"a satin-like shirtplate with flowing ridges and embossed neckline",
"a sari-inspired chest drape with brooch detailing",
"a scientific wrap coat with ID tag etching and lapel grooves",
"a chef’s chest wrap with apron panel and a molded hat rim",
"a crisp torso wrap with scarf loops and collar wings",
"a construction vest panel with built-in hard plate and antenna tags",
"a ribbed sweater-like wrap with etched fabric texture",
"a hoodie-style top with kangaroo pocket embossing",
"a tunic shell with side seam ridges and neck cowl",
"a wide plaid wrap panel with faux buckle straps",
"a jumpsuit-style upper shell with a utility belt ridge",
"a vintage-style high collar dress shell with jewelry dot detail",
"a smooth torso panel with medical tag and ID patch",
"a zippered jacket overlay with athletic texture lines",
"a boho-style chest wrap with pendant symbols and wave trim",
"a blazer vest with printed badge and triangular neckline",
"a puffed jacket wrap with head flap and thermal pattern lines",
"a utility jumpsuit chestplate with angled pockets and faux straps",
"a bulky sweater-style wrap with a fuzzy collar edge",
"a single-breasted jacket with vintage lapels and folded collar",
"a short-sleeved collar panel with stitched cargo detail",
"a pinstripe panel with angular tie notch and coat seam",
"a printed dressform with cross-texture jacket layer",
"a deep-winter parka front with embedded scarf and faux fur rim",
"a wide silk scarf wrap with looped ends and collar fold",
"a flowing floral-textured panel with belt ties and subtle edge flare",
"a sports jersey wrap with panel numbers and athletic seams",
"a soft fisherman-style ribbed wrap with beanie detail at the top",
"a utility vest with flannel texture grooves and harness seams",
"a polo-style overlay with button-down collar and ridged torso",
"a formal gown shell with faux clutch bump and neckline curve",
"a lightweight jacket vest with high neck and sculpted zipper",
"a hoodie front with diagonal seams and cargo panel at the base",
"a striped ribbed wrap with faux skirt folds and beltline emboss",
"a long leather-style trench plate with wide turtleneck",
"a sundress panel with leaf trim and small sun hat bump",
"a hanbok-inspired panel with embroidered ribbon curves",
"a cardigan plate with floral trim and soft lapel seams",
"a formal wool-style wrap with scarf insert and collared ridge",
"a sweater vest wrap with shirt collar overlay and center pleats",
"a short dressform with front buttons and folded beltline",
"a zippered fleece front with side panel ribs",
"an apron-style front plate with collar and pouch groove",
"a dashiki-inspired design with patterns pressed into the surface",
"a business panel with high neck collar and slim torso lines",
"a rain poncho front with layered shoulder dips and sealed edges",
"a double-breasted red blazer-inspired shell with smooth tie ridge"
]
more_robot_outfits = [
"a sculpted tuxedo panel with a layered bowtie and lapel flare",
"a minimal robe-style wrap with vertical ribbing down the center",
"a futuristic vest with asymmetrical panels and a mock neck ridge",
"a captain’s uniform overlay with chest emblems and a buttoned collar",
"a royal messenger’s tabard with a sash ridge across the chest",
"a bubble-style vest with quilted dome patterns and air channel seams",
"a white conductor’s panel with a sharp folded bowtie shape",
"a sleek cleric robe wrap with ornamental grooves and high collar",
"a martial arts tunic with cross-wrap panel and belt impression",
"a sculptural cloak clasp overlay with a V-cut neckline",
"a white marching band uniform shell with stripe etchings",
"a renaissance tabard plate with decorative trim and crest bump",
"a glossy explorer’s vest with compass etching and belt hook nods",
"a fashion-forward trench overlay with slanted zipper seams",
"a minimalist overcoat shell with two molded button indents",
"a pageboy vest with collar ruffles and a raised emblem",
"a pilot-style chest piece with double loop badges",
"a vintage waistcoat wrap with faux chain link detail",
"a puffy jacket panel with stitched channel ridges and hood bump",
"a simple ceremonial robe shell with embossed circle patterns",
"a sculpted futuristic biker vest with diagonal grooves",
"a layered fashion poncho with panel drapes on either side",
"a yoga wrap panel with soft curve lines and zen tag indent",
"a theater usher's suit front with large bow and button seams",
"a space academy uniform panel with rank stripe bands",
"a high-fashion sculpted chest corset with vertical edge ridges",
"a garden party vest with floral lace texture etched in",
"a utility tech wrap with tool pocket outlines and belt nubs",
"a bubble-tea barista apron panel with logo plate and button loops",
"a magical apprentice robe wrap with glowing sigil crest",
"a castle guard cuirass panel with rivet detailing",
"a monk-style wrap robe with soft ribbing and angled neckline",
"a streetwear bomber jacket shell with wrist tag emboss",
"a sculptural flight suit chest panel with subtle pad lines",
"a modern dance outfit with criss-cross top texture",
"a contemporary sculpted peacoat overlay with layered ridges",
"a fairy-tale servant tabard with ornamental stitch motifs",
"a sculpted samurai chestplate with cross-hatch grooves",
"a casual hoodie panel with oversized pouch shape",
"a sci-fi emissary's vest with angular lapels and crest inlay",
"a wraparound vest with faux shoulder pads and curved collar line",
"a dramatic opera vest with floral relief pattern",
"a medieval page tunic with pleated bottom edge wrap",
"a glossy fashion jumpsuit front with deep center curve",
"a professor's vest with book clasp bump and lapel groove",
"a time traveler’s coat panel with multi-era detail seams",
"a slick racing vest with speed line embossing",
"a bard’s jacket with swirl embroidery texture and collar ruffle",
"a gemstone merchant's wrap with pouch markings and shimmer panel",
"a floating-collar magician's robe overlay with loop closures"
]
crazy_robot_outfits = [
"a wizard’s tunic with glowing runes and a floating crystal clasp",
"a white disco suit with exaggerated lapels and a holographic chest medallion",
"a knight’s chestplate with a dragon emblem and faux chainmail collar",
"a sushi chef wrap with etched fish symbols and a rice-texture bib",
"a formal toastmaster's vest with tiny champagne flutes etched in",
"a gladiator chestplate with lion-head emboss and belt grooves",
"a vampire noble vest with raised bat-wing patterns and a tiny capelet bump",
"a sci-fi janitor uniform with vacuum hose ports and caution tape seams",
"a gothic poet’s robe with quill etching and mournful folds",
"a retro-futuristic space corset with light speed meter details",
"a snowman costume shell with carrot bump and scarf ring",
"a time-traveling tourist outfit with map-fold impressions and luggage tags",
"a garden gnome tunic with belt buckle bump and mushroom symbol",
"a mad scientist's lab vest with bubbling beaker grooves",
"a circus ringmaster panel with button loops and a bowtie explosion",
"a cardboard box disguise with fake 'FRAGILE' stamp and air holes",
"a knight-in-training padded vest with doodled armor scribbles",
"a fashion week avant-garde torso wrap shaped like a melting ice cube",
"a robot dressed as a snow angel with wings etched on the back",
"a steampunk explorer corset with gear embosses and goggle imprints",
"a cyberpunk vest with glitch lines and microchip filigree",
"a jester tunic with triangle ridges and tiny bell indents",
"a tea-time party vest with teacup outlines and saucer seams",
"a Halloween ghost sheet with smiley face cutouts",
"a baked potato costume wrap with foil texture embossing",
"a rock star outfit with electric guitar outline and stage light imprints",
"a teddy bear onesie panel with plush stitch patterns",
"a superhero uniform with chest emblem crest and cape clasp",
"a deep-sea diver shell with bubble porthole bump and coral grooves",
"a pharaoh's ceremonial panel with sun disk and winged collar ridge",
"a sushi nigiri wrap with a rice-etched base and faux salmon top layer",
"a space cowboy vest with star badge and alien lasso hook",
"a robot-dressed-as-a-hamburger outfit with bun, lettuce, and cheese slices",
"a mime costume with stripe ridges and invisible wall stance lines",
"a cosmic monk robe with solar system orbit etchings",
"a medieval minstrel tunic with lute engraving and musical note filigree",
"a holiday gift box wrap with bow bump and ribbon panel",
"a ramen bowl costume with noodle swirl patterns and chopstick loops",
"a dragon-scale vest with horns peeking from the shoulders",
"a bouncer outfit with club logo tag and earpiece imprint",
"a banana peel costume shell with curve wraps and texture ribs",
"a digital influencer's vest with selfie light frame and clout counter",
"a beekeeper uniform with honeycomb grooves and netting texture",
"a white ghostbuster uniform with proton pack panel and ghost logo etch",
"a sandwich-board-style ad wrap for robot hugs",
"a renaissance fair costume with scroll patterns and coin pouch imprint",
"a martian ambassador's chestpiece with planet orbit detail lines",
"a royal butler’s vest with ruffled bib and tray indent",
"a minimalist tofu cube outfit with soy drizzle pattern"
]
all_robot_outfits = robot_outfits + more_robot_outfits + crazy_robot_outfits
demo_title = "Reachy Mini Doll "
description = "Get an outfit idea for your Reachy Mini"
css = """
#col-container {
margin: 0 auto;
max-width: 980px;
text-align: left;
}
"""
with gr.Blocks(css=css) as demo:
with gr.Column(elem_id="col-container"):
gr.HTML(f"""
<h2 style="text-align: center;">{demo_title}</h2>
<p style="text-align: center;">{description}</p>
""")
with gr.Row():
with gr.Column(scale=1):
gr.LoginButton()
robot_img_in = gr.Image(
label = "Reachy Mini",
value="./reachy_mini.jpeg",
type = "filepath",
elem_id = "robot-img-in",
interactive=False
)
doll_prompt = gr.Dropdown(
label="Doll Outfit Prompt",
choices=all_robot_outfits,
value="a white chest panel with a sculpted suit front and a miniature tie",
interactive=True,
allow_custom_value=True
)
submit_btn = gr.Button("Make an outfit for my Reachy Mini !")
with gr.Column(scale=2):
result = gr.Image(
label = "Outfit propal"
)
submit_btn.click(
fn = infer,
inputs = [
robot_img_in, doll_prompt
],
outputs =[
result
]
)
demo.queue().launch(show_api=False, show_error=True, ssr_mode=False)