Download app.py from HoangHa/Demo: direct link, hf CLI and curl.
- Browser
- Download file 2.01 kB
-
https://huggingface.co/spaces/HoangHa/Demo/resolve/main/app.py
- Command line
-
hf download hf://spaces/HoangHa/Demo/app.py
-
curl -L -o app.py https://huggingface.co/spaces/HoangHa/Demo/resolve/main/app.py
2.01 kB
| import streamlit as st | |
| from ocr import perform_ocr, correction | |
| from chat import meptic_copilot | |
| from translate import translation_prescription, translation_QA | |
| import tempfile | |
| st.set_page_config(page_title="MeptiC") | |
| # Define your Streamlit app | |
| def main(): | |
| st.title("MeptiC - Medical Virtual Assistant (DEMO APP)") | |
| # Use st.sidebar to create a sidebar | |
| sidebar = st.sidebar | |
| # Upload image file | |
| image_file = sidebar.file_uploader("Upload an image file", type=["jpg", "png"]) | |
| if image_file is not None: | |
| # Save the uploaded file to a temporary file | |
| with tempfile.NamedTemporaryFile(delete=False) as temp_file: | |
| temp_file.write(image_file.read()) | |
| image_file_path = temp_file.name | |
| # Perform OCR on the image file | |
| ocr_text = perform_ocr(image_file_path) | |
| user_text = correction(ocr_text) | |
| # Perform MeptiC | |
| output_text = meptic_copilot(user_text) | |
| # Translate MeptiC output | |
| translated_text = translation_prescription(output_text) | |
| st.write("MeptiC:") | |
| st.markdown(translated_text) | |
| # User feedback | |
| st.markdown("Phản hồi của MeptiC như thế nào? :smile: Đúng, :confused: Sai") | |
| else: | |
| with st.form(key='Tên thuốc'): | |
| user_input = st.text_input("Nhập tên thuốc bạn cần thông tin:") | |
| submitted = st.form_submit_button("Tìm kiếm") | |
| # Check if the submit button is clicked and user_input is not empty | |
| if submitted and user_input: | |
| # Perform MeptiC | |
| output_text = meptic_copilot(user_input) | |
| # Translate MeptiC output | |
| translated_text = translation_QA(output_text) | |
| st.write("MeptiC:") | |
| st.markdown(translated_text) | |
| # User feedback | |
| st.markdown("Phản hồi của MeptiC như thế nào? :smile: Đúng, :confused: Sai") | |
| if __name__ == "__main__": | |
| main() | |