import gradio as gr def translate_text(text): # (Thêm logic dịch văn bản ở đây) return f"Văn bản đã dịch: {text}" def classify_image(image): # (Thêm logic phân loại hình ảnh ở đây) return {"label": "Mèo", "confidence": 0.9} with gr.Blocks() as demo: gr.Markdown("# Ứng dụng đa năng") with gr.Tabs(): with gr.TabItem("Dịch văn bản"): text_input = gr.Textbox(label="Nhập văn bản") text_output = gr.Textbox(label="Kết quả") translate_button = gr.Button("Dịch") translate_button.click(translate_text, inputs=text_input, outputs=text_output) with gr.TabItem("Phân loại hình ảnh"): image_input = gr.Image(type="pil", label="Tải ảnh lên") image_output = gr.Label(num_top_classes=3) classify_button = gr.Button("Phân loại") classify_button.click(classify_image, inputs=image_input, outputs=image_output) demo.launch()