andt123 commited on
Commit
dcc7302
·
verified ·
1 Parent(s): 4098679

Create main.py

Browse files
Files changed (1) hide show
  1. main.py +26 -0
main.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def translate_text(text):
4
+ # (Thêm logic dịch văn bản ở đây)
5
+ return f"Văn bản đã dịch: {text}"
6
+
7
+ def classify_image(image):
8
+ # (Thêm logic phân loại hình ảnh ở đây)
9
+ return {"label": "Mèo", "confidence": 0.9}
10
+
11
+ with gr.Blocks() as demo:
12
+ gr.Markdown("# Ứng dụng đa năng")
13
+ with gr.Tabs():
14
+ with gr.TabItem("Dịch văn bản"):
15
+ text_input = gr.Textbox(label="Nhập văn bản")
16
+ text_output = gr.Textbox(label="Kết quả")
17
+ translate_button = gr.Button("Dịch")
18
+ translate_button.click(translate_text, inputs=text_input, outputs=text_output)
19
+
20
+ with gr.TabItem("Phân loại hình ảnh"):
21
+ image_input = gr.Image(type="pil", label="Tải ảnh lên")
22
+ image_output = gr.Label(num_top_classes=3)
23
+ classify_button = gr.Button("Phân loại")
24
+ classify_button.click(classify_image, inputs=image_input, outputs=image_output)
25
+
26
+ demo.launch()