Update app.py
Browse files34 unmodified lines35363738394061 unmodified lines10210310410510610710845 unmodified lines1541551561571581591604 unmodified lines16516616716816917017120 unmodified lines19219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327434 unmodified linesif not path.exists(gallery_path):os.makedirs(gallery_path, exist_ok=True)class timer:def __init__(self, method_name="timed process"):self.method = method_name61 unmodified linesexamples = [["A 3D Star Wars Darth Vader helmet, highly detailed metallic finish"],["A 3D Iron Man mask with glowing eyes and metallic red-gold finish"],["A detailed 3D Pokemon Pikachu figure with glossy surface"],["A 3D geometric abstract cube transforming into a sphere, metallic finish"],["A 3D steampunk mechanical heart with brass and copper details"],["A 3D crystal dragon with transparent iridescent scales"],45 unmodified linesdef get_random_seed():return torch.randint(0, 1000000, (1,)).item()def process_example(prompt):return process_and_save_image(height=1024,4 unmodified linesseed=get_random_seed())# Gradio ์ธํฐํ์ด์คwith gr.Blocks(theme=gr.themes.Soft(),20 unmodified lines}""") as demo:gr.HTML("""<div style="text-align: center; max-width: 800px; margin: 0 auto; padding: 20px;"><h1 style="font-size: 2.5rem; color: #2196F3;">3D Style Image Generator</h1><p style="font-size: 1.2rem; color: #666;">Create amazing 3D-style images with AI</p></div>""")with gr.Row(elem_classes="container"):with gr.Column(scale=3):prompt = gr.Textbox(label="Image Description",placeholder="Describe the 3D image you want to create...",lines=3)with gr.Accordion("Advanced Settings", open=False):with gr.Row():height = gr.Slider(label="Height",minimum=256,maximum=1152,step=64,value=1024)width = gr.Slider(label="Width",minimum=256,maximum=1152,step=64,value=1024)with gr.Row():steps = gr.Slider(label="Inference Steps",minimum=6,maximum=25,step=1,value=8)scales = gr.Slider(label="Guidance Scale",minimum=0.0,maximum=5.0,step=0.1,value=3.5)seed = gr.Number(label="Seed (random by default, set for reproducibility)",value=get_random_seed(),precision=0)randomize_seed = gr.Button("๐ฒ Randomize Seed", elem_classes=["generate-btn"])generate_btn = gr.Button("โจ Generate Image",elem_classes=["generate-btn"])with gr.Column(scale=4, elem_classes=["fixed-width"]):output = gr.Image(label="Generated Image",elem_id="output-image",elem_classes=["output-image", "fixed-width"],value="3d.webp")# Examples ์น์ gr.Examples(examples=examples,inputs=prompt,outputs=output,fn=process_example, # ์์ ๋ ํจ์ ์ฌ์ฉcache_examples=False,examples_per_page=5)34 unmodified lines353637383940414243444561 unmodified lines10710810911011111211345 unmodified lines1591601611621631644 unmodified lines16917017117217317420 unmodified lines19519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031134 unmodified linesif not path.exists(gallery_path):os.makedirs(gallery_path, exist_ok=True)# ์ํ ์ด๋ฏธ์ง์ ํ๋กฌํํธ ์ ์SAMPLE_IMAGES = {"3d1.webp": "the most famous hero according to Zhou Qi"}class timer:def __init__(self, method_name="timed process"):self.method = method_name61 unmodified linesexamples = [["A 3D Star Wars Darth Vader helmet, highly detailed metallic finish"],["A 3D Iron Man mask with glowing eyes and metallic red-gold finish"],["A 3D Pokemon Pikachu figure with glossy surface"],["A 3D geometric abstract cube transforming into a sphere, metallic finish"],["A 3D steampunk mechanical heart with brass and copper details"],["A 3D crystal dragon with transparent iridescent scales"],45 unmodified linesdef get_random_seed():return torch.randint(0, 1000000, (1,)).item()def process_example(prompt):return process_and_save_image(height=1024,4 unmodified linesseed=get_random_seed())# Gradio ์ธํฐํ์ด์คwith gr.Blocks(theme=gr.themes.Soft(),20 unmodified lines}""") as demo:with gr.Tabs():# ์ฒซ ๋ฒ์งธ ํญ - Generatorwith gr.Tab("Generator"):gr.HTML("""<div style="text-align: center; max-width: 800px; margin: 0 auto; padding: 20px;"><h1 style="font-size: 2.5rem; color: #2196F3;">3D Style Image Generator</h1><p style="font-size: 1.2rem; color: #666;">Create amazing 3D-style images with AI</p></div>""")with gr.Row(elem_classes="container"):with gr.Column(scale=3):prompt = gr.Textbox(label="Image Description",placeholder="Describe the 3D image you want to create...",lines=3)with gr.Accordion("Advanced Settings", open=False):with gr.Row():height = gr.Slider(label="Height",minimum=256,maximum=1152,step=64,value=1024)width = gr.Slider(label="Width",minimum=256,maximum=1152,step=64,value=1024)with gr.Row():steps = gr.Slider(label="Inference Steps",minimum=6,maximum=25,step=1,value=8)scales = gr.Slider(label="Guidance Scale",minimum=0.0,maximum=5.0,step=0.1,value=3.5)seed = gr.Number(label="Seed (random by default, set for reproducibility)",value=get_random_seed(),precision=0)randomize_seed = gr.Button("๐ฒ Randomize Seed", elem_classes=["generate-btn"])generate_btn = gr.Button("โจ Generate Image",elem_classes=["generate-btn"])with gr.Column(scale=4, elem_classes=["fixed-width"]):output = gr.Image(label="Generated Image",elem_id="output-image",elem_classes=["output-image", "fixed-width"],value="3d.webp")# ๋ ๋ฒ์งธ ํญ - Gallerywith gr.Tab("Gallery"):with gr.Row():gallery_html = "<div style='display: flex; flex-wrap: wrap; gap: 20px; padding: 20px;'>"for img_file, prompt in SAMPLE_IMAGES.items():if os.path.exists(img_file):gallery_html += f"""<div style='border: 1px solid #ddd;border-radius: 10px;padding: 10px;width: 300px;box-shadow: 0 4px 8px rgba(0,0,0,0.1);'><img src='file/{img_file}'style='width: 100%;border-radius: 8px;margin-bottom: 10px;'><p style='margin: 5px 0;font-weight: bold;color: #333;'>Prompt: {prompt}</p></div>"""gallery_html += "</div>"gr.HTML(gallery_html)# Examples ์น์ gr.Examples(examples=examples,inputs=prompt,outputs=output,fn=process_example,cache_examples=False,examples_per_page=5)
app.py+104-67