Spaces:
Running
Running
File size: 3,339 Bytes
aa20204 a68b775 aa20204 f9652c8 17d34e6 80bf838 17d34e6 656c922 17d34e6 f9652c8 17d34e6 656c922 c0a6e84 17d34e6 80bf838 656c922 aa20204 |
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 |
import gradio as gr
from infra import image_processing_single, image_processing_batch
with gr.Blocks(theme='freddyaboulton/dracula_revamped', title='Image Generator') as demo:
gr.HTML("""
<h1>Product Image Generator</h1>
<p>1. ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง๋ฅผ ์
๋ก๋ํด์ฃผ์ธ์.<p>
<p>2-1. Single ๋ชจ๋์ ๊ฒฝ์ฐ, ์ด๋ฏธ์ง์ ๋งํฌ๋ฅผ ์
๋ ฅํด์ฃผ์ธ์.<p>
<p>2-2. Batch ๋ชจ๋์ ๊ฒฝ์ฐ, ์ด๋ฏธ์ง ๋งํฌ๋ค์ด ํฌํจ๋ .txt ํ์ผ(ํ์ = ๋งํฌ1(์ํฐ) ๋งํฌ2(์ํฐ) ..)์ ์
๋ก๋ํด์ฃผ์ธ์.<p>
<p>3. Generate Images ๋ฒํผ์ ๋๋ฌ ์ ํ ์ด๋ฏธ์ง๋ฅผ ์์ฑํด์ฃผ์ธ์.<p>
""")
with gr.Row(elem_classes="input_box"):
with gr.Column():
background_image = gr.Image(label="Background Image", type="pil", height=300)
gr.Examples(
examples=[["examples/background_1.png"], ["examples/background_2.png"], ["examples/background_3.png"], ["examples/background_4.png"]], # ์์ ์ด๋ฏธ์ง ๊ฒฝ๋ก ๋ฆฌ์คํธ
inputs=background_image, # ์์ ๋ฅผ ํด๋ฆญํ์ ๋ ํด๋น ์ด๋ฏธ์ง๊ฐ ์ด input์ ์ ์ฉ๋จ
label="์์ ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง")
with gr.Tab("Single Mode"):
with gr.Column():
product_image_size = gr.Slider(512, 1024, value=800, label="์ ํ ์ด๋ฏธ์ง ์ฌ์ด์ฆ")
link = gr.Textbox(label="Image URL")
gr.Examples(
examples=["https://url.kr/yx85be", "https://url.kr/if4wxo"],
inputs=link,
label="์์ ์ด๋ฏธ์ง ๋งํฌ"
)
btn_single = gr.Button("Generate Images")
with gr.Tab("Batch Mode"):
with gr.Column():
product_image_size_batch = gr.Slider(512, 1024, value=800, label="์ ํ ์ด๋ฏธ์ง ์ฌ์ด์ฆ")
gr.HTML("<div>๋งํฌ1(์ํฐ) ๋งํฌ2(์ํฐ) ... ์ผ๋ก ๊ตฌ์ฑ๋ .txt ํ์ผ์ ์
๋ก๋</div>")
links = gr.File(label="Image URLs (.txt file)", height=100)
gr.Examples(
examples=[["examples/links.txt"]],
inputs=links,
label="์์ .txt ํ์ผ"
)
btn_batch = gr.Button("Generate Images")
gr.HTML("""
<br><br>
<h1>์์ฑ ๊ฒฐ๊ณผ ํ์ธ</h1>
<p>์์ฑ์ 1๊ฐ ์ด๋ฏธ์ง ๋น 15~30์ด ์์๋๋ฉฐ(๋ฐฐ๊ฒฝ์ ๊ฑฐ AI ๋ชจ๋ ์ฒ๋ฆฌ์๊ฐ), ๊ฒฐ๊ณผ๋ ๋ค์๊ณผ ๊ฐ์ด ์ ๊ณต๋ฉ๋๋ค.</p>
<p>1. ์ฒซ๋ฒ์งธ ์ด๋ฏธ์ง์ ๋ํ ํ๋ฆฌ๋ทฐ(3๊ฐ ํ์
)</p>
<p>2. ๊ฒฐ๊ณผ ์ด๋ฏธ์ง ์ ์ฒด๊ฐ ๋ด๊ธด ZIP ํ์ผ(results.zip) ๋ค์ด๋ก๋ ๋งํฌ๊ฐ ์ ๊ณต๋ฉ๋๋ค</p>
""")
with gr.Row():
preview = gr.Gallery(label="Generated images", show_label=False, elem_id="gallery", columns=[3], rows=[1], object_fit="contain", height="auto")
output_zip = gr.File(label="Download Result Zip File")
# evnets
btn_single.click(fn=image_processing_single, inputs=[background_image, link, product_image_size], outputs=[preview, output_zip], api_name="image_processing_single")
btn_batch.click(fn=image_processing_batch, inputs=[background_image, links, product_image_size_batch], outputs=[preview, output_zip], api_name="image_processing_batch")
demo.launch() |