Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,25 +3,28 @@ from gradio_client import Client
|
|
| 3 |
import os
|
| 4 |
import logging
|
| 5 |
|
|
|
|
| 6 |
# ๋ก๊น
์ค์
|
| 7 |
logging.basicConfig(level=logging.INFO)
|
| 8 |
|
| 9 |
# API ํด๋ผ์ด์ธํธ ์ค์
|
| 10 |
api_client = Client("http://211.233.58.202:7960/")
|
| 11 |
|
| 12 |
-
def respond(message):
|
| 13 |
-
logging.info("Received message:
|
|
|
|
|
|
|
| 14 |
|
| 15 |
try:
|
| 16 |
# ์ด๋ฏธ์ง ์์ฑ ์์ฒญ
|
| 17 |
result = api_client.predict(
|
| 18 |
prompt=message,
|
| 19 |
-
seed=
|
| 20 |
-
randomize_seed=
|
| 21 |
-
width=
|
| 22 |
-
height=
|
| 23 |
-
guidance_scale=
|
| 24 |
-
num_inference_steps=
|
| 25 |
api_name="/infer_t2i"
|
| 26 |
)
|
| 27 |
logging.info("API response received: %s", result)
|
|
@@ -45,6 +48,7 @@ footer {
|
|
| 45 |
"""
|
| 46 |
|
| 47 |
|
|
|
|
| 48 |
# ์ด๋ฏธ์ง ์์ฑ์ ์ํ ์์ ํ๋กฌํํธ
|
| 49 |
examples = [
|
| 50 |
["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. ", "q1.webp"],
|
|
@@ -78,6 +82,18 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
|
| 78 |
input_text = gr.Textbox(label="Enter your prompt for image generation")
|
| 79 |
output_image = gr.Image(label="Generated Image")
|
| 80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
with gr.Row():
|
| 82 |
for prompt, image_file in examples:
|
| 83 |
with gr.Column():
|
|
@@ -93,7 +109,11 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
|
| 93 |
outputs=input_text
|
| 94 |
)
|
| 95 |
|
| 96 |
-
input_text.submit(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
|
| 98 |
if __name__ == "__main__":
|
| 99 |
demo.launch()
|
|
|
|
| 3 |
import os
|
| 4 |
import logging
|
| 5 |
|
| 6 |
+
|
| 7 |
# ๋ก๊น
์ค์
|
| 8 |
logging.basicConfig(level=logging.INFO)
|
| 9 |
|
| 10 |
# API ํด๋ผ์ด์ธํธ ์ค์
|
| 11 |
api_client = Client("http://211.233.58.202:7960/")
|
| 12 |
|
| 13 |
+
def respond(message, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
|
| 14 |
+
logging.info(f"Received message: {message}, seed: {seed}, randomize_seed: {randomize_seed}, "
|
| 15 |
+
f"width: {width}, height: {height}, guidance_scale: {guidance_scale}, "
|
| 16 |
+
f"num_inference_steps: {num_inference_steps}")
|
| 17 |
|
| 18 |
try:
|
| 19 |
# ์ด๋ฏธ์ง ์์ฑ ์์ฒญ
|
| 20 |
result = api_client.predict(
|
| 21 |
prompt=message,
|
| 22 |
+
seed=seed,
|
| 23 |
+
randomize_seed=randomize_seed,
|
| 24 |
+
width=width,
|
| 25 |
+
height=height,
|
| 26 |
+
guidance_scale=guidance_scale,
|
| 27 |
+
num_inference_steps=num_inference_steps,
|
| 28 |
api_name="/infer_t2i"
|
| 29 |
)
|
| 30 |
logging.info("API response received: %s", result)
|
|
|
|
| 48 |
"""
|
| 49 |
|
| 50 |
|
| 51 |
+
|
| 52 |
# ์ด๋ฏธ์ง ์์ฑ์ ์ํ ์์ ํ๋กฌํํธ
|
| 53 |
examples = [
|
| 54 |
["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. ", "q1.webp"],
|
|
|
|
| 82 |
input_text = gr.Textbox(label="Enter your prompt for image generation")
|
| 83 |
output_image = gr.Image(label="Generated Image")
|
| 84 |
|
| 85 |
+
with gr.Row():
|
| 86 |
+
seed = gr.Slider(minimum=0, maximum=1000000, step=1, label="Seed", value=123)
|
| 87 |
+
randomize_seed = gr.Checkbox(label="Randomize Seed", value=False)
|
| 88 |
+
|
| 89 |
+
with gr.Row():
|
| 90 |
+
width = gr.Slider(minimum=256, maximum=1024, step=64, label="Width", value=1024)
|
| 91 |
+
height = gr.Slider(minimum=256, maximum=1024, step=64, label="Height", value=576)
|
| 92 |
+
|
| 93 |
+
with gr.Row():
|
| 94 |
+
guidance_scale = gr.Slider(minimum=1, maximum=20, step=0.1, label="Guidance Scale", value=5)
|
| 95 |
+
num_inference_steps = gr.Slider(minimum=1, maximum=100, step=1, label="Number of Inference Steps", value=28)
|
| 96 |
+
|
| 97 |
with gr.Row():
|
| 98 |
for prompt, image_file in examples:
|
| 99 |
with gr.Column():
|
|
|
|
| 109 |
outputs=input_text
|
| 110 |
)
|
| 111 |
|
| 112 |
+
input_text.submit(
|
| 113 |
+
fn=respond,
|
| 114 |
+
inputs=[input_text, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
|
| 115 |
+
outputs=output_image
|
| 116 |
+
)
|
| 117 |
|
| 118 |
if __name__ == "__main__":
|
| 119 |
demo.launch()
|