ginipick commited on
Commit
e8dc013
·
verified ·
1 Parent(s): 8b8cbb1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +115 -33
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
- # UI 타이틀 및 설명
71
- # ===============================
72
- _TITLE = '''3D Llama'''
73
  _DESCRIPTION = '''
74
- Text와 이미지를 이용하여 3D 모델을 생성할 있습니다.
75
 
 
 
 
 
 
76
  '''
77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  def launch():
79
- # 3D 모델 초기화
80
  model_zoo.init_models()
81
 
82
- # Gradio Blocks 생성 ( 포함)
83
- with gr.Blocks(title=_TITLE) as demo:
84
  with gr.Row():
85
- gr.Markdown('# ' + _TITLE)
86
  gr.Markdown(_DESCRIPTION)
87
 
88
- # 생성: 기존의 Text-to-3D와 새로 추가한 Text-to-IMAGE
89
- with gr.Tabs():
90
-
91
-
92
- with gr.Tab("Text to 3D Style IMAGE"):
93
- # 이미지 생성을 위한 파라미터 입력 컴포넌트 구성
94
- with gr.Row():
95
- height_slider = gr.Slider(label="Height", minimum=256, maximum=2048, step=1, value=1024)
96
- width_slider = gr.Slider(label="Width", minimum=256, maximum=2048, step=1, value=1024)
97
- with gr.Row():
98
- steps_slider = gr.Slider(label="Inference Steps", minimum=1, maximum=100, step=1, value=8)
99
- scales_slider = gr.Slider(label="Guidance Scale", minimum=1.0, maximum=10.0, step=0.1, value=3.5)
100
- prompt_text = gr.Textbox(label="Image Description", placeholder="Enter prompt here", lines=2)
101
- seed_number = gr.Number(label="Seed (optional, leave empty for random)", value=None)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
 
103
- # 'Update Random Seed' 버튼을 누르면 API를 통해 새로운 시드값을 받아 입력란 업데이트
104
- update_seed_button = gr.Button("Update Random Seed")
105
- update_seed_button.click(fn=update_random_seed, inputs=[], outputs=seed_number)
106
 
107
- generate_button = gr.Button("Generate Image")
108
- image_output = gr.Image(label="Generated Image")
 
 
 
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)