|
|
import os |
|
|
import random |
|
|
from smolagents import CodeAgent, InferenceClientModel |
|
|
import gradio as gr |
|
|
|
|
|
HF_TOKEN = os.getenv("HF_TOKEN") |
|
|
model_id = "mistralai/Mistral-7B-Instruct-v0.1" |
|
|
|
|
|
client_model = InferenceClientModel( |
|
|
model_id=model_id, |
|
|
token=HF_TOKEN, |
|
|
) |
|
|
|
|
|
agent = CodeAgent( |
|
|
llm=client_model, |
|
|
system_message="You are a prompt generator specialized in hyper-realistic cosplay portrait prompts." |
|
|
) |
|
|
|
|
|
CHARACTER_FEMALES = [ |
|
|
{"name": "Rias Gremory", "series": "High School DxD", "description": "crimson hair styled in long waves, school uniform with a short skirt", "eye_color": "blue", "hair_color": "crimson"}, |
|
|
{"name": "Tifa Lockhart", "series": "Final Fantasy VII", "description": "black hair in ponytail, sporty tank top and mini skirt", "eye_color": "brown", "hair_color": "black"}, |
|
|
{"name": "Mikasa Ackerman", "series": "Attack on Titan", "description": "short black hair, scout uniform, fitted jacket and pants", "eye_color": "gray", "hair_color": "black"}, |
|
|
{"name": "Sailor Moon", "series": "Sailor Moon", "description": "long blonde hair in odango, sailor scout uniform with pleated skirt", "eye_color": "blue", "hair_color": "blonde"}, |
|
|
{"name": "Hinata Hyuga", "series": "Naruto", "description": "dark blue hair, ninja outfit with lavender jacket and pants", "eye_color": "pale lavender", "hair_color": "dark blue"} |
|
|
] |
|
|
|
|
|
SETTINGS = [ |
|
|
"neon-lit office at midnight with hum of computers and scent of rain", |
|
|
"gothic library filled with flickering candlelight and faded parchment scent", |
|
|
"throne room bathed in warm golden light with velvet drapes", |
|
|
"sterile operating room with bright surgical lights and soft beeping sounds", |
|
|
"magical forest with glowing flora and gentle breeze rustling leaves" |
|
|
] |
|
|
|
|
|
ACTIVITIES = [ |
|
|
"reaching for a top-shelf file", |
|
|
"arranging occult tomes on a desk", |
|
|
"casting a subtle spell with glowing magical effects", |
|
|
"serving coffee with graceful movements", |
|
|
"walking confidently down a gothic hallway" |
|
|
] |
|
|
|
|
|
LINGERIE_COLORS = ["black", "red", "white", "navy blue", "deep burgundy"] |
|
|
|
|
|
STOCKING_DETAILS = ["a delicate back seam", "intricate lace pattern", "classic fishnet design", "smooth satin finish", "subtle floral embroidery"] |
|
|
|
|
|
HEEL_DETAILS = ["sharp stiletto heels", "elegant kitten heels", "strappy high heels", "sleek patent leather pumps", "classic pointed toe heels"] |
|
|
|
|
|
POSES = ["confident stance, one hand on hip", "sitting casually on a desk", "leaning slightly forward", "standing with arms crossed", "walking with a playful smile"] |
|
|
|
|
|
EXPRESSIONS = ["a knowing, seductive smile", "a confident, alluring gaze", "a playful smirk", "an intense, focused look", "a soft, inviting smile"] |
|
|
|
|
|
def generate_prompt(character, setting, activity, lingerie_color, stocking_detail, heel_detail, pose, expression, prompt_num): |
|
|
return f"""### Prompt {prompt_num} |
|
|
**{character['name']}** (*{character['series']}*) is captured in a professional Ultra HD 16K (15360x8640) RAW photograph, set in **{setting}**, the ambiance filled with sensory elements. Her flawless cosplay features **{character['hair_color']} hair styled {character['description']}**, accented by **{character['eye_color']} eyes**, cascading over a **{lingerie_color} lace thong** and matching transparent lace bra. **Thigh-high stockings** with **{stocking_detail}** accentuate her legs, paired with **{heel_detail}**. The character is posed in a **{pose}**, her **{expression}** directed at the viewer. Shot from a **low-angle (worm’s eye view)** using a **Canon EOS R5 Cine RAW** with a **Canon RF 85mm f/1.2L USM lens**, the composition emphasizes her dominance and the sensual details of her lingerie. **ARRI SkyPanel S360-C lighting** creates soft, flattering illumination, enhancing realistic skin texture and fabric sheen, while **DaVinci Resolve color grading** adds vibrant, cinematic tones. The full vertical frame (knees to head) ensures no cropping, with perfect depth of field and subtle bokeh background. |
|
|
Negative prompt keywords exclude cartoon, blurry, pixelated, low-resolution, watermark, noise, overexposed, underexposed, unnatural shadows, color banding, oversaturation, artificial textures, and all other disallowed artifacts.""" |
|
|
|
|
|
def chat_with_agent(user_message): |
|
|
if user_message.strip().lower() == "ok": |
|
|
prompts = [] |
|
|
selected_chars = random.sample(CHARACTER_FEMALES, 5) |
|
|
for i, char in enumerate(selected_chars, start=1): |
|
|
prompt = generate_prompt( |
|
|
char, |
|
|
random.choice(SETTINGS), |
|
|
random.choice(ACTIVITIES), |
|
|
random.choice(LINGERIE_COLORS), |
|
|
random.choice(STOCKING_DETAILS), |
|
|
random.choice(HEEL_DETAILS), |
|
|
random.choice(POSES), |
|
|
random.choice(EXPRESSIONS), |
|
|
i |
|
|
) |
|
|
prompts.append(prompt) |
|
|
return "\n\n".join(prompts) |
|
|
else: |
|
|
return "Please enter 'Ok' to generate 5 detailed cosplay prompts." |
|
|
|
|
|
with gr.Blocks() as demo: |
|
|
gr.Markdown("# Automatic Hyper-Realistic Cosplay Prompt Generator") |
|
|
chatbot = gr.Chatbot() |
|
|
msg = gr.Textbox(label="Type 'Ok' to generate 5 automatic prompts") |
|
|
msg.submit(chat_with_agent, msg, chatbot) |
|
|
msg.submit(lambda: "", None, msg) |
|
|
|
|
|
if __name__ == "__main__": |
|
|
demo.launch() |
|
|
|