fantaxy's picture
Update app.py
eb8e22c verified
raw
history blame
5.28 kB
import gradio as gr
from gradio_client import Client
import os
import logging
# ๋กœ๊น… ์„ค์ •
logging.basicConfig(level=logging.INFO)
# API ํด๋ผ์ด์–ธํŠธ ์„ค์ •
api_client = Client("http://211.233.58.202:7960/")
def respond(message):
logging.info("Received message: %s", message)
try:
# ์ด๋ฏธ์ง€ ์ƒ์„ฑ ์š”์ฒญ
result = api_client.predict(
prompt=message,
seed=123,
randomize_seed=False,
width=1024,
height=576,
guidance_scale=5,
num_inference_steps=28,
api_name="/infer_t2i"
)
logging.info("API response received: %s", result)
# ๊ฒฐ๊ณผ ํ™•์ธ ๋ฐ ์ฒ˜๋ฆฌ
if isinstance(result, dict) and 'url' in result:
return result['url']
elif isinstance(result, tuple):
logging.error("Unexpected tuple response: %s", result)
return result[0]
else:
raise ValueError("Unexpected API response format")
except Exception as e:
logging.error("Error during API request: %s", str(e))
return "Failed to generate image due to an error."
css = """
footer {
visibility: hidden;
}
"""
# ์ด๋ฏธ์ง€ ์ƒ์„ฑ์„ ์œ„ํ•œ ์˜ˆ์ œ ํ”„๋กฌํ”„ํŠธ
examples = [
["A glamorous young woman with long, wavy blonde hair and smokey eye makeup, posing in a luxury hotel room. Sheโ€™s wearing a sparkly gold cocktail dress and holding up a white card with 'openfree.ai' written on it in elegant calligraphy. Soft, warm lighting creates a luxurious atmosphere. "],
["A fit male fitness influencer with short dark hair and stubble, standing shirtless in a modern gym. He has defined abs and arm muscles, and is holding a protein shake in one hand and a card that says 'openfree.ai' in the other. Bright, clean lighting highlights his physique."],
["A bohemian-style female travel blogger with sun-kissed skin and messy beach waves, sitting on a tropical beach at sunset. Sheโ€™s wearing a flowy white sundress and holding up a weathered postcard with 'openfree.ai' scrawled on it. Golden hour lighting bathes the scene in warm tones. "],
["A trendy male fashion influencer with perfectly styled hair and designer stubble, posing on a city street. Heโ€™s wearing a tailored suit and holding up a sleek black business card with 'openfree.ai' printed in minimalist white font. The background shows blurred city lights, creating a chic urban atmosphere."],
["A fresh-faced young female beauty guru with freckles and natural makeup, sitting at a vanity covered in cosmetics. Sheโ€™s wearing a pastel pink robe and holding up a makeup palette with 'openfree.ai' written on it in lipstick. Soft, flattering lighting enhances her radiant complexion. "],
["A stylish young woman with long, wavy ombre hair and winged eyeliner, posing in front of a neon-lit city skyline at night. Sheโ€™s wearing a sleek black leather jacket over a sparkly crop top and holding up a holographic business card that says 'openfree.ai' in futuristic font. The card reflects the colorful neon lights, creating a cyberpunk aesthetic."],
["Create a surreal advertisement poster for a fictional time travel agency. The background should depict a swirling vortex of clock faces and historical landmarks from different eras. In the foreground, place large, bold text that reads โ€œAI TOURS: YOUR PAST IS OUR FUTUREโ€ in a retro-futuristic font. The text should appear to be partially disintegrating into particles that are being sucked into the time vortex. Include smaller text at the bottom with fictional pricing and the slogan โ€œHistory is just a ticket away!โ€"],
["Photo realistic scene inspired by LOTR: [A tiny red dragon sleeps curled up in a nest on a medieval wizard's table]. Shot with a macro lens (f/2.8, 50mm) and a Canon EOSR5, the soft focus captures [the cozy morning light filtering through a near by window]. The pastel colors and whimsical steam shapes enhance the serene atmosphere, evoking a DnD RPG setting. The image is rendered in 16K and 8K, highlighting [the intricate details and medieval charm]."],
["์ฌ๊ธ€๋ผ์Šค๋ฅผ ์ฐฉ์šฉํ•œ ๊ท€์—ฌ์šด ๊ฐ•์•„์ง€๊ฐ€ 'Openfree.ai'๋ผ๊ณ  ์“ฐ์—ฌ์ง„ ํ‘œ์ง€ํŒ์„ ๋“ค๊ณ ์žˆ๋‹ค."],
["๋ฏธ๋ ˆ์ ์ธ ๋„์‹œ์˜ ํ•ด์ง€๋Š” ํ’๊ฒฝ"],
["๋นจ๊ฐ„์ƒ‰ ๋ฐ•์Šค์— 'openfree.ai'๋ผ๊ณ  ๊ธ€์”จ๊ฐ€ ์“ฐ์—ฌ์žˆ๊ณ , ๊ทธ์œ„์— ๊ฐ•์•„์ง€์™€ ๊ณ ์–‘์ด๊ฐ€ ์•‰์•„์žˆ๋‹ค."],
["A serene landscape with mountains in the background and a clear lake in the foreground."],
["A street scene from Tokyo at night, vibrant and full of lights."],
["An astronaut riding a horse on Mars."],
["A surreal painting of a tree growing books."],
["A cottage in a snowy forest, lit by warm lights."],
["A still life of various fruits and a wine glass on a table."],
["A digital artwork of a neon-lit alley in a cyberpunk city."],
["A fantasy map of a fictional world, with detailed terrain and cities."]
]
# Gradio ์ธํ„ฐํŽ˜์ด์Šค ์„ค์ •
demo = gr.Interface(
fn=respond,
inputs=gr.Textbox(label="Enter your prompt for image generation"),
outputs=gr.Image(label="Generated Image"),
examples=examples,
theme="Nymbo/Nymbo_Theme",
css=css
)
if __name__ == "__main__":
demo.launch()