Spaces:
Sleeping
Sleeping
Update src/app.py
Browse files- src/app.py +139 -35
src/app.py
CHANGED
@@ -76,7 +76,6 @@ def _process(
|
|
76 |
img: Image.Image,
|
77 |
bbox: BoundingBox | None,
|
78 |
) -> tuple[tuple[Image.Image, Image.Image], gr.DownloadButton]:
|
79 |
-
# enforce max dimensions for pymatting performance reasons
|
80 |
if img.width > 2048 or img.height > 2048:
|
81 |
orig_res = max(img.width, img.height)
|
82 |
img.thumbnail((2048, 2048))
|
@@ -117,37 +116,127 @@ def process_bbox(prompts: dict[str, Any]) -> tuple[tuple[Image.Image, Image.Imag
|
|
117 |
def on_change_bbox(prompts: dict[str, Any] | None):
|
118 |
return gr.update(interactive=prompts is not None)
|
119 |
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
|
150 |
-
with gr.Row():
|
151 |
with gr.Column():
|
152 |
annotator = image_annotator(
|
153 |
image_type="pil",
|
@@ -155,12 +244,13 @@ with gr.Blocks() as demo:
|
|
155 |
show_download_button=False,
|
156 |
show_share_button=False,
|
157 |
single_box=True,
|
158 |
-
label="
|
|
|
159 |
)
|
160 |
-
btn = gr.ClearButton(value="
|
161 |
with gr.Column():
|
162 |
-
oimg = ImageSlider(label="
|
163 |
-
dlbt = gr.DownloadButton("
|
164 |
|
165 |
btn.add(oimg)
|
166 |
|
@@ -198,4 +288,18 @@ with gr.Blocks() as demo:
|
|
198 |
cache_examples=True,
|
199 |
)
|
200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
demo.launch(share=False)
|
|
|
76 |
img: Image.Image,
|
77 |
bbox: BoundingBox | None,
|
78 |
) -> tuple[tuple[Image.Image, Image.Image], gr.DownloadButton]:
|
|
|
79 |
if img.width > 2048 or img.height > 2048:
|
80 |
orig_res = max(img.width, img.height)
|
81 |
img.thumbnail((2048, 2048))
|
|
|
116 |
def on_change_bbox(prompts: dict[str, Any] | None):
|
117 |
return gr.update(interactive=prompts is not None)
|
118 |
|
119 |
+
css = '''
|
120 |
+
.gradio-container {
|
121 |
+
max-width: 1100px !important;
|
122 |
+
margin: auto;
|
123 |
+
}
|
124 |
+
|
125 |
+
h1 {
|
126 |
+
text-align: center;
|
127 |
+
font-family: 'Pretendard', sans-serif;
|
128 |
+
color: #EA580C;
|
129 |
+
font-size: 2.5rem;
|
130 |
+
font-weight: 700;
|
131 |
+
margin-bottom: 1.5rem;
|
132 |
+
text-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
133 |
+
}
|
134 |
+
|
135 |
+
.subtitle {
|
136 |
+
text-align: center;
|
137 |
+
color: #4B5563;
|
138 |
+
font-size: 1.1rem;
|
139 |
+
margin-bottom: 2rem;
|
140 |
+
font-family: 'Pretendard', sans-serif;
|
141 |
+
}
|
142 |
+
|
143 |
+
.gr-button-primary {
|
144 |
+
background-color: #F97316 !important;
|
145 |
+
border: none !important;
|
146 |
+
box-shadow: 0 2px 4px rgba(234, 88, 12, 0.2) !important;
|
147 |
+
}
|
148 |
+
|
149 |
+
.gr-button-primary:hover {
|
150 |
+
background-color: #EA580C !important;
|
151 |
+
transform: translateY(-1px);
|
152 |
+
box-shadow: 0 4px 6px rgba(234, 88, 12, 0.25) !important;
|
153 |
+
}
|
154 |
+
|
155 |
+
.footer-content {
|
156 |
+
text-align: center;
|
157 |
+
margin-top: 3rem;
|
158 |
+
padding: 2rem;
|
159 |
+
background: linear-gradient(to bottom, #FFF7ED, white);
|
160 |
+
border-radius: 12px;
|
161 |
+
font-family: 'Pretendard', sans-serif;
|
162 |
+
}
|
163 |
+
|
164 |
+
.footer-content a {
|
165 |
+
color: #EA580C;
|
166 |
+
text-decoration: none;
|
167 |
+
font-weight: 500;
|
168 |
+
transition: all 0.2s;
|
169 |
+
}
|
170 |
+
|
171 |
+
.footer-content a:hover {
|
172 |
+
color: #C2410C;
|
173 |
+
}
|
174 |
+
|
175 |
+
.visit-button {
|
176 |
+
background-color: #EA580C;
|
177 |
+
color: white;
|
178 |
+
padding: 12px 24px;
|
179 |
+
border-radius: 8px;
|
180 |
+
font-weight: 600;
|
181 |
+
text-decoration: none;
|
182 |
+
display: inline-block;
|
183 |
+
transition: all 0.3s;
|
184 |
+
margin-top: 1rem;
|
185 |
+
box-shadow: 0 2px 4px rgba(234, 88, 12, 0.2);
|
186 |
+
}
|
187 |
+
|
188 |
+
.visit-button:hover {
|
189 |
+
background-color: #C2410C;
|
190 |
+
transform: translateY(-2px);
|
191 |
+
box-shadow: 0 4px 6px rgba(234, 88, 12, 0.25);
|
192 |
+
}
|
193 |
+
|
194 |
+
.container-wrapper {
|
195 |
+
background: white;
|
196 |
+
border-radius: 16px;
|
197 |
+
padding: 2rem;
|
198 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
|
199 |
+
}
|
200 |
+
|
201 |
+
.image-container {
|
202 |
+
border-radius: 12px;
|
203 |
+
overflow: hidden;
|
204 |
+
border: 2px solid #F3F4F6;
|
205 |
+
}
|
206 |
+
'''
|
207 |
+
|
208 |
+
with gr.Blocks(
|
209 |
+
theme=gr.themes.Soft(
|
210 |
+
primary_hue=gr.themes.Color(
|
211 |
+
c50="#FFF7ED",
|
212 |
+
c100="#FFEDD5",
|
213 |
+
c200="#FED7AA",
|
214 |
+
c300="#FDBA74",
|
215 |
+
c400="#FB923C",
|
216 |
+
c500="#F97316",
|
217 |
+
c600="#EA580C",
|
218 |
+
c700="#C2410C",
|
219 |
+
c800="#9A3412",
|
220 |
+
c900="#7C2D12",
|
221 |
+
c950="#431407",
|
222 |
+
),
|
223 |
+
secondary_hue="zinc",
|
224 |
+
neutral_hue="zinc",
|
225 |
+
font=("Pretendard", "sans-serif")
|
226 |
+
),
|
227 |
+
css=css
|
228 |
+
) as demo:
|
229 |
+
gr.HTML(
|
230 |
+
"""
|
231 |
+
<h1>끝장AI 이미지 객체 추출기</h1>
|
232 |
+
<div class="subtitle">
|
233 |
+
이미지에서 원하는 객체를 손쉽게 분리하여 투명 배경으로 추출하세요.<br>
|
234 |
+
고품질의 HD 이미지 추출을 지원합니다.
|
235 |
+
</div>
|
236 |
+
"""
|
237 |
+
)
|
238 |
|
239 |
+
with gr.Row(elem_classes="container-wrapper"):
|
240 |
with gr.Column():
|
241 |
annotator = image_annotator(
|
242 |
image_type="pil",
|
|
|
244 |
show_download_button=False,
|
245 |
show_share_button=False,
|
246 |
single_box=True,
|
247 |
+
label="원본 이미지",
|
248 |
+
elem_classes="image-container"
|
249 |
)
|
250 |
+
btn = gr.ClearButton(value="객체 추출하기", interactive=False)
|
251 |
with gr.Column():
|
252 |
+
oimg = ImageSlider(label="추출 결과", show_download_button=False, elem_classes="image-container")
|
253 |
+
dlbt = gr.DownloadButton("이미지 다운로드", interactive=False)
|
254 |
|
255 |
btn.add(oimg)
|
256 |
|
|
|
288 |
cache_examples=True,
|
289 |
)
|
290 |
|
291 |
+
gr.HTML(
|
292 |
+
"""
|
293 |
+
<div class='footer-content'>
|
294 |
+
<p style='font-size: 1.1rem; font-weight: 500; color: #1F2937;'>끝장AI가 제공하는 고급 AI 도구를 더 경험하고 싶으신가요?</p>
|
295 |
+
<a href='https://finalendai.com' target='_blank' class='visit-button'>
|
296 |
+
끝장AI 방문하기
|
297 |
+
</a>
|
298 |
+
<p style='margin-top: 1.5rem; color: #6B7280; font-size: 0.9rem;'>
|
299 |
+
© 2024 끝장AI. All rights reserved.
|
300 |
+
</p>
|
301 |
+
</div>
|
302 |
+
"""
|
303 |
+
)
|
304 |
+
|
305 |
demo.launch(share=False)
|