Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -66,59 +66,141 @@ def update_random_seed():
|
|
| 66 |
client = Client("http://211.233.58.201:7971/")
|
| 67 |
return client.predict(api_name="/update_random_seed")
|
| 68 |
|
| 69 |
-
#
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
_TITLE = '''3D Llama'''
|
| 73 |
_DESCRIPTION = '''
|
| 74 |
-
|
| 75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
'''
|
| 77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
def launch():
|
| 79 |
-
# 3D 모델 초기화
|
| 80 |
model_zoo.init_models()
|
| 81 |
|
| 82 |
-
|
| 83 |
-
with gr.Blocks(title=_TITLE) as demo:
|
| 84 |
with gr.Row():
|
| 85 |
-
gr.Markdown('# ' + _TITLE)
|
| 86 |
gr.Markdown(_DESCRIPTION)
|
| 87 |
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
|
| 107 |
-
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
| 109 |
|
| 110 |
-
# 'Generate Image' 버튼 클릭 시 text_to_image 함수를 호출하여 결과 이미지를 출력
|
| 111 |
generate_button.click(
|
| 112 |
fn=text_to_image,
|
| 113 |
inputs=[height_slider, width_slider, steps_slider, scales_slider, prompt_text, seed_number],
|
| 114 |
outputs=image_output
|
| 115 |
)
|
| 116 |
|
| 117 |
-
with gr.Tab("Image to 3D"):
|
| 118 |
create_3d_ui("wkl")
|
| 119 |
|
| 120 |
-
# 공유 링크를 생성하기 위해 share=True 설정
|
| 121 |
demo.queue().launch(share=True)
|
| 122 |
-
|
| 123 |
if __name__ == '__main__':
|
| 124 |
-
fire.Fire(launch)
|
|
|
|
| 66 |
client = Client("http://211.233.58.201:7971/")
|
| 67 |
return client.predict(api_name="/update_random_seed")
|
| 68 |
|
| 69 |
+
# (이전 import 구문들은 동일)
|
| 70 |
+
|
| 71 |
+
_TITLE = '''✨ 3D Llama Studio'''
|
|
|
|
| 72 |
_DESCRIPTION = '''
|
| 73 |
+
### Welcome to 3D Llama Studio - Your Advanced 3D Generation Platform
|
| 74 |
|
| 75 |
+
This platform offers two powerful features:
|
| 76 |
+
1. **Text/Image to 3D**: Generate detailed 3D models from text descriptions or reference images
|
| 77 |
+
2. **Text to Styled Image**: Create artistic images that can be used for 3D generation
|
| 78 |
+
|
| 79 |
+
*Note: Both English and Korean prompts are supported (영어와 한글 프롬프트 모두 지원됩니다)*
|
| 80 |
'''
|
| 81 |
|
| 82 |
+
# Custom CSS for dark theme and enhanced UI
|
| 83 |
+
custom_css = """
|
| 84 |
+
.gradio-container {
|
| 85 |
+
background-color: #1a1a1a;
|
| 86 |
+
color: #ffffff;
|
| 87 |
+
}
|
| 88 |
+
.tabs {
|
| 89 |
+
background-color: #2d2d2d;
|
| 90 |
+
border-radius: 10px;
|
| 91 |
+
padding: 10px;
|
| 92 |
+
margin: 10px 0;
|
| 93 |
+
}
|
| 94 |
+
.input-box {
|
| 95 |
+
background-color: #2d2d2d;
|
| 96 |
+
border: 1px solid #404040;
|
| 97 |
+
border-radius: 8px;
|
| 98 |
+
padding: 15px;
|
| 99 |
+
margin: 10px 0;
|
| 100 |
+
}
|
| 101 |
+
.button-primary {
|
| 102 |
+
background-color: #2d5a9e !important;
|
| 103 |
+
border: none !important;
|
| 104 |
+
color: white !important;
|
| 105 |
+
}
|
| 106 |
+
.button-secondary {
|
| 107 |
+
background-color: #404040 !important;
|
| 108 |
+
border: none !important;
|
| 109 |
+
}
|
| 110 |
+
"""
|
| 111 |
+
|
| 112 |
def launch():
|
|
|
|
| 113 |
model_zoo.init_models()
|
| 114 |
|
| 115 |
+
with gr.Blocks(title=_TITLE, css=custom_css, theme=gr.themes.Soft(primary_hue="blue", neutral_hue="slate", font=["Arial", "sans-serif"])) as demo:
|
|
|
|
| 116 |
with gr.Row():
|
| 117 |
+
gr.Markdown('# ' + _TITLE, elem_classes="main-title")
|
| 118 |
gr.Markdown(_DESCRIPTION)
|
| 119 |
|
| 120 |
+
with gr.Tabs() as tabs:
|
| 121 |
+
with gr.Tab("🎨 Text to Styled Image", elem_classes="tab"):
|
| 122 |
+
with gr.Group(elem_classes="input-box"):
|
| 123 |
+
gr.Markdown("### Image Generation Settings")
|
| 124 |
+
with gr.Row():
|
| 125 |
+
with gr.Column():
|
| 126 |
+
height_slider = gr.Slider(
|
| 127 |
+
label="Image Height",
|
| 128 |
+
minimum=256,
|
| 129 |
+
maximum=2048,
|
| 130 |
+
step=64,
|
| 131 |
+
value=1024,
|
| 132 |
+
info="Select image height (pixels)"
|
| 133 |
+
)
|
| 134 |
+
width_slider = gr.Slider(
|
| 135 |
+
label="Image Width",
|
| 136 |
+
minimum=256,
|
| 137 |
+
maximum=2048,
|
| 138 |
+
step=64,
|
| 139 |
+
value=1024,
|
| 140 |
+
info="Select image width (pixels)"
|
| 141 |
+
)
|
| 142 |
+
with gr.Column():
|
| 143 |
+
steps_slider = gr.Slider(
|
| 144 |
+
label="Generation Steps",
|
| 145 |
+
minimum=1,
|
| 146 |
+
maximum=100,
|
| 147 |
+
step=1,
|
| 148 |
+
value=8,
|
| 149 |
+
info="More steps = higher quality but slower"
|
| 150 |
+
)
|
| 151 |
+
scales_slider = gr.Slider(
|
| 152 |
+
label="Guidance Scale",
|
| 153 |
+
minimum=1.0,
|
| 154 |
+
maximum=10.0,
|
| 155 |
+
step=0.1,
|
| 156 |
+
value=3.5,
|
| 157 |
+
info="How closely to follow the prompt"
|
| 158 |
+
)
|
| 159 |
+
|
| 160 |
+
prompt_text = gr.Textbox(
|
| 161 |
+
label="Image Description",
|
| 162 |
+
placeholder="Enter your prompt here (English or Korean)",
|
| 163 |
+
lines=3,
|
| 164 |
+
elem_classes="input-box"
|
| 165 |
+
)
|
| 166 |
+
|
| 167 |
+
with gr.Row():
|
| 168 |
+
seed_number = gr.Number(
|
| 169 |
+
label="Seed",
|
| 170 |
+
value=None,
|
| 171 |
+
placeholder="Random seed if empty",
|
| 172 |
+
elem_classes="input-box"
|
| 173 |
+
)
|
| 174 |
+
update_seed_button = gr.Button(
|
| 175 |
+
"🎲 Random Seed",
|
| 176 |
+
elem_classes="button-secondary"
|
| 177 |
+
)
|
| 178 |
+
|
| 179 |
+
generate_button = gr.Button(
|
| 180 |
+
"🚀 Generate Image",
|
| 181 |
+
elem_classes="button-primary"
|
| 182 |
+
)
|
| 183 |
|
| 184 |
+
with gr.Group(elem_classes="input-box"):
|
| 185 |
+
gr.Markdown("### Generated Result")
|
| 186 |
+
image_output = gr.Image(label="Output Image")
|
| 187 |
|
| 188 |
+
update_seed_button.click(
|
| 189 |
+
fn=update_random_seed,
|
| 190 |
+
inputs=[],
|
| 191 |
+
outputs=seed_number
|
| 192 |
+
)
|
| 193 |
|
|
|
|
| 194 |
generate_button.click(
|
| 195 |
fn=text_to_image,
|
| 196 |
inputs=[height_slider, width_slider, steps_slider, scales_slider, prompt_text, seed_number],
|
| 197 |
outputs=image_output
|
| 198 |
)
|
| 199 |
|
| 200 |
+
with gr.Tab("🎯 Image to 3D", elem_classes="tab"):
|
| 201 |
create_3d_ui("wkl")
|
| 202 |
|
|
|
|
| 203 |
demo.queue().launch(share=True)
|
| 204 |
+
|
| 205 |
if __name__ == '__main__':
|
| 206 |
+
fire.Fire(launch)
|