Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -183,7 +183,6 @@ def generate_background(prompt: str, aspect_ratio: str) -> Image.Image:
|
|
183 |
|
184 |
|
185 |
def create_position_grid():
|
186 |
-
"""3x3 ์์น ์ ํ ๊ทธ๋ฆฌ๋๋ฅผ ์์ฑํ๋ HTML"""
|
187 |
return """
|
188 |
<div class="position-grid" style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 150px; margin: auto;">
|
189 |
<button class="position-btn" data-pos="top-left" onclick="updatePosition(this)">โ</button>
|
@@ -208,13 +207,11 @@ def create_position_grid():
|
|
208 |
btn.style.backgroundColor = '#2196F3';
|
209 |
btn.style.color = 'white';
|
210 |
|
211 |
-
//
|
212 |
-
const
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
positionState.dispatchEvent(new Event('change'));
|
217 |
-
}
|
218 |
}
|
219 |
|
220 |
// ์ด๊ธฐ ์ ํ ๋ฒํผ ์คํ์ผ ์ค์
|
@@ -223,8 +220,6 @@ def create_position_grid():
|
|
223 |
</script>
|
224 |
"""
|
225 |
|
226 |
-
|
227 |
-
|
228 |
def calculate_object_position(position: str, bg_size: tuple[int, int], obj_size: tuple[int, int]) -> tuple[int, int]:
|
229 |
"""์ค๋ธ์ ํธ์ ์์น ๊ณ์ฐ"""
|
230 |
bg_width, bg_height = bg_size
|
@@ -486,11 +481,11 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
|
486 |
scale=1
|
487 |
)
|
488 |
|
489 |
-
|
490 |
with gr.Row(visible=False) as object_controls:
|
491 |
with gr.Column(scale=1):
|
492 |
position_grid = gr.HTML(create_position_grid())
|
493 |
-
position = gr.State(value="bottom-center"
|
494 |
with gr.Column(scale=1):
|
495 |
scale_slider = gr.Slider(
|
496 |
minimum=10,
|
@@ -499,7 +494,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
|
499 |
step=10,
|
500 |
label="Object Size (%)"
|
501 |
)
|
502 |
-
|
503 |
|
504 |
|
505 |
process_btn = gr.Button(
|
|
|
183 |
|
184 |
|
185 |
def create_position_grid():
|
|
|
186 |
return """
|
187 |
<div class="position-grid" style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 150px; margin: auto;">
|
188 |
<button class="position-btn" data-pos="top-left" onclick="updatePosition(this)">โ</button>
|
|
|
207 |
btn.style.backgroundColor = '#2196F3';
|
208 |
btn.style.color = 'white';
|
209 |
|
210 |
+
// Gradio์ ์ด๋ฒคํธ ๋ฐ์
|
211 |
+
const event = new CustomEvent('position-update', {
|
212 |
+
detail: { position: btn.dataset.pos }
|
213 |
+
});
|
214 |
+
document.dispatchEvent(event);
|
|
|
|
|
215 |
}
|
216 |
|
217 |
// ์ด๊ธฐ ์ ํ ๋ฒํผ ์คํ์ผ ์ค์
|
|
|
220 |
</script>
|
221 |
"""
|
222 |
|
|
|
|
|
223 |
def calculate_object_position(position: str, bg_size: tuple[int, int], obj_size: tuple[int, int]) -> tuple[int, int]:
|
224 |
"""์ค๋ธ์ ํธ์ ์์น ๊ณ์ฐ"""
|
225 |
bg_width, bg_height = bg_size
|
|
|
481 |
scale=1
|
482 |
)
|
483 |
|
484 |
+
# UI ๋ถ๋ถ์์ position State ๋ถ๋ถ ์์
|
485 |
with gr.Row(visible=False) as object_controls:
|
486 |
with gr.Column(scale=1):
|
487 |
position_grid = gr.HTML(create_position_grid())
|
488 |
+
position = gr.State(value="bottom-center") # elem_id ์ ๊ฑฐ
|
489 |
with gr.Column(scale=1):
|
490 |
scale_slider = gr.Slider(
|
491 |
minimum=10,
|
|
|
494 |
step=10,
|
495 |
label="Object Size (%)"
|
496 |
)
|
497 |
+
|
498 |
|
499 |
|
500 |
process_btn = gr.Button(
|