Spaces:
Running
Running
Commit
·
3897042
1
Parent(s):
1f1b651
Simplify Gradio app layout and remove custom theme
Browse files- Removed custom Gradio theme configuration
- Simplified row and column layouts
- Streamlined filter control and image display components
- Removed unnecessary styling and height constraints
- Maintained core application functionality
app.py
CHANGED
@@ -6,21 +6,7 @@ from filters import *
|
|
6 |
from components import create_filter_controls
|
7 |
|
8 |
def create_app():
|
9 |
-
|
10 |
-
theme = gr.themes.Soft(
|
11 |
-
primary_hue="indigo",
|
12 |
-
secondary_hue="slate",
|
13 |
-
).set(
|
14 |
-
body_background_fill="*background_fill_secondary",
|
15 |
-
block_background_fill="*background_fill_primary",
|
16 |
-
block_border_width="0",
|
17 |
-
block_shadow="*shadow_drop_lg",
|
18 |
-
button_primary_background_fill="*primary_500",
|
19 |
-
button_primary_background_fill_hover="*primary_600",
|
20 |
-
button_primary_text_color="white",
|
21 |
-
)
|
22 |
-
|
23 |
-
with gr.Blocks(theme=theme) as app:
|
24 |
gr.Markdown("""
|
25 |
# 📷 Photo Filter App
|
26 |
### Chỉnh sửa ảnh với các bộ lọc chuyên nghiệp
|
@@ -31,46 +17,31 @@ def create_app():
|
|
31 |
filter_names = list(registry.filters.keys())
|
32 |
filter_groups = controls
|
33 |
|
34 |
-
with gr.Row(
|
35 |
-
with gr.Column(
|
36 |
input_image = gr.Image(
|
37 |
label="Ảnh gốc",
|
38 |
-
type="numpy"
|
39 |
-
height=400
|
40 |
)
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
value="Original",
|
47 |
-
container=False
|
48 |
-
)
|
49 |
-
apply_button = gr.Button(
|
50 |
-
"Áp dụng",
|
51 |
-
variant="primary",
|
52 |
-
size="sm"
|
53 |
-
)
|
54 |
-
|
55 |
-
# Tạo container cho các điều khiển
|
56 |
-
with gr.Box():
|
57 |
-
gr.Markdown("### Tùy chỉnh bộ lọc")
|
58 |
-
control_components = []
|
59 |
-
for filter_name, group in filter_groups.items():
|
60 |
-
for component in group.children:
|
61 |
-
control_components.append(component)
|
62 |
-
|
63 |
-
filter_doc = gr.Markdown(
|
64 |
-
container=False,
|
65 |
-
show_label=False
|
66 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
-
with gr.Column(
|
69 |
-
output_image = gr.Image(
|
70 |
-
|
71 |
-
height=400,
|
72 |
-
show_download_button=True
|
73 |
-
)
|
74 |
|
75 |
# Xử lý cập nhật UI
|
76 |
def update_controls(filter_name):
|
@@ -104,13 +75,6 @@ def create_app():
|
|
104 |
except Exception as e:
|
105 |
return None, gr.update(visible=True, value=f"❌ Lỗi xử lý ảnh: {str(e)}")
|
106 |
|
107 |
-
# Thêm thông báo lỗi
|
108 |
-
error_message = gr.Markdown(
|
109 |
-
visible=False,
|
110 |
-
value="",
|
111 |
-
container=False
|
112 |
-
)
|
113 |
-
|
114 |
# Kết nối sự kiện
|
115 |
filter_select.change(
|
116 |
update_controls,
|
|
|
6 |
from components import create_filter_controls
|
7 |
|
8 |
def create_app():
|
9 |
+
with gr.Blocks() as app:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
gr.Markdown("""
|
11 |
# 📷 Photo Filter App
|
12 |
### Chỉnh sửa ảnh với các bộ lọc chuyên nghiệp
|
|
|
17 |
filter_names = list(registry.filters.keys())
|
18 |
filter_groups = controls
|
19 |
|
20 |
+
with gr.Row():
|
21 |
+
with gr.Column():
|
22 |
input_image = gr.Image(
|
23 |
label="Ảnh gốc",
|
24 |
+
type="numpy"
|
|
|
25 |
)
|
26 |
|
27 |
+
filter_select = gr.Dropdown(
|
28 |
+
label="Chọn bộ lọc",
|
29 |
+
choices=filter_names,
|
30 |
+
value="Original"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
)
|
32 |
+
|
33 |
+
# Các điều khiển bộ lọc
|
34 |
+
control_components = []
|
35 |
+
for filter_name, group in filter_groups.items():
|
36 |
+
for component in group.children:
|
37 |
+
control_components.append(component)
|
38 |
+
|
39 |
+
apply_button = gr.Button("Áp dụng bộ lọc")
|
40 |
+
filter_doc = gr.Markdown()
|
41 |
|
42 |
+
with gr.Column():
|
43 |
+
output_image = gr.Image(label="Ảnh đã chỉnh sửa")
|
44 |
+
error_message = gr.Markdown(visible=False)
|
|
|
|
|
|
|
45 |
|
46 |
# Xử lý cập nhật UI
|
47 |
def update_controls(filter_name):
|
|
|
75 |
except Exception as e:
|
76 |
return None, gr.update(visible=True, value=f"❌ Lỗi xử lý ảnh: {str(e)}")
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
# Kết nối sự kiện
|
79 |
filter_select.change(
|
80 |
update_controls,
|