Quét PDF Y khoa → Dịch trực tiếp sang tiếng Việt (Streaming)
Model: https://huggingface.co/pnnbao-ump/MedCrab-1.5B
Dataset: https://huggingface.co/datasets/pnnbao-ump/MedCrab
GitHub Repository: https://github.com/pnnbao97/MedCrab
Tác giả: Phạm Nguyễn Ngọc Bảo
""") with gr.Row(): with gr.Column(scale=1): gr.Markdown("### 📤 Tải file lên") file_in = gr.File(label="PDF hoặc Hình ảnh", file_types=["image", ".pdf"], type="filepath") input_img = gr.Image(label="Xem trước", type="pil", height=300) page_input = gr.Textbox(label="Số trang (chỉ dùng cho PDF, mặc định: 1)", value="1", placeholder="Nhập số trang...") mode = gr.Dropdown(list(MODEL_CONFIGS.keys()), value="Crab", label="Chế độ OCR") gr.Markdown("### 🦀 Quét và Dịch") process_btn = gr.Button("🚀 Quét OCR + Dịch tiếng Việt", variant="primary", size="lg") with gr.Column(scale=2): gr.Markdown("### 📄 Kết quả dịch tiếng Việt (Streaming)") translation_output = gr.HTML(label="", value="") with gr.Accordion("📚 Ví dụ mẫu", open=True): gr.Markdown("**Thử ngay với các ví dụ có sẵn:**") gr.Examples( examples=[ ["images/example1.png", "Crab", "1"], ["images/example2.png", "Crab", "1"], ], inputs=[file_in, mode, page_input], outputs=[translation_output], fn=ocr_and_translate_streaming, cache_examples=False, label="Nhấp vào ví dụ để thử" ) with gr.Accordion("⚖️ Giấy phép & Liên hệ", open=False): gr.Markdown(""" ### ⚖️ Giấy phép sử dụng MedCrab được phát hành theo giấy phép: **Creative Commons Attribution–NonCommercial 4.0 International (CC BY-NC 4.0)** ### ✅ Được phép - Sử dụng cho mục đích cá nhân - Nghiên cứu học thuật - Giảng dạy, học tập, minh họa - Thử nghiệm nội bộ (không phục vụ vận hành thực tế) ### ❌ Không được phép - Sử dụng cho mục đích thương mại dưới mọi hình thức - Tích hợp vào hệ thống sản xuất (production system) - Triển khai tại bệnh viện, phòng khám, cơ sở y tế - Cung cấp như một dịch vụ trả phí / SaaS - Bán lại, cho thuê, nhượng quyền phần mềm ### 💼 Nhu cầu sử dụng thương mại Nếu bạn đại diện cho: - Bệnh viện / phòng khám - Công ty công nghệ y tế - Viện nghiên cứu có hoạt động thương mại hóa - Startup, doanh nghiệp triển khai sản phẩm y tế Vui lòng liên hệ trực tiếp tác giả để trao đổi về **giấy phép thương mại**: 👤 **Phạm Nguyễn Ngọc Bảo** 📧 Facebook: https://www.facebook.com/bao.phamnguyenngoc.5/ --- ⚠️ **Lưu ý pháp lý:** Phần mềm này chỉ phục vụ cho mục đích nghiên cứu và tham khảo, **không thay thế cho chẩn đoán hoặc quyết định y khoa.** """) # Events file_in.change(load_image, [file_in, page_input], [input_img]) file_in.change(update_page_info, [file_in], [page_input]) page_input.change(load_image, [file_in, page_input], [input_img]) process_btn.click(ocr_and_translate_streaming, [file_in, mode, page_input], [translation_output]) # Load default example into both file_in (filepath) and input_img (PIL) when UI starts demo.load( load_default_example, inputs=None, outputs=[file_in, input_img] ) if __name__ == "__main__": print("🚀 Starting MedCrab Translation on Hugging Face Spaces...") demo.queue(max_size=20).launch()