import streamlit as st from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM # Load models models = { "FAWMED": "FawadHaider2/FAWMED", "WADMED": "FawadHaider2/WADMED", "PastelMed": "harishussain12/PastelMed", "LynxMed": "harishussain12/LynxMed" } # Disease-specific information with more details diseases_info = { "Cancer": """ Cancer is a broad term for a group of diseases characterized by uncontrolled cell growth and spread to other parts of the body. It starts when abnormal cells begin to divide without stopping and spread into surrounding tissues. These cancer cells can also invade nearby blood vessels, lymph vessels, and nerves. As cancer grows, it may spread to other parts of the body through the blood and lymphatic systems. There are more than 100 types of cancer, including: - **Breast Cancer**: Develops in the cells of the breast and can occur in both men and women. - **Lung Cancer**: Affects the lungs and is often associated with smoking or exposure to secondhand smoke. - **Colorectal Cancer**: Starts in the colon or rectum and is one of the most common types of cancer. - **Prostate Cancer**: A cancer that begins in the prostate, a small gland that produces seminal fluid in men. - **Leukemia**: Cancer of the blood-forming tissues, including the bone marrow and lymphatic system. Risk factors for cancer include smoking, diet, family history, genetics, exposure to certain chemicals or radiation, and lack of physical activity. Symptoms of cancer can vary depending on the type but often include unexplained weight loss, fatigue, pain, and changes in bowel or bladder habits. Treatment options include surgery, radiation therapy, chemotherapy, immunotherapy, and targeted therapies, depending on the type and stage of cancer. """, "Alzheimer's Disease": """ Alzheimer's Disease is a progressive neurodegenerative disorder that affects memory, thinking, and behavior. It is the most common cause of dementia, which is a general term for the severe decline in cognitive function. The disease is characterized by the build-up of amyloid plaques and tau tangles in the brain, which disrupt normal communication between brain cells. The symptoms of Alzheimer's disease typically begin with mild memory loss and confusion, eventually progressing to severe cognitive impairment and inability to perform daily activities. Symptoms include: - Memory loss that disrupts daily life (forgetting names or appointments). - Difficulty planning or solving problems. - Challenges completing familiar tasks at home, work, or leisure. - Confusion with time or place. - Trouble understanding visual images and spatial relationships. Alzheimer's is a progressive disease, meaning symptoms will get worse over time. There is no known cure, but treatments can help manage symptoms and improve quality of life for a time. Medications like cholinesterase inhibitors (Donepezil, Rivastigmine) and glutamate regulators (Memantine) are commonly prescribed to slow down the progression of symptoms. Risk factors for Alzheimer's disease include age, family history, genetics (such as the APOE-e4 gene), and cardiovascular conditions like high blood pressure and diabetes. """, "Parkinson's Disease": """ Parkinson's Disease is a progressive neurological disorder that affects movement. It occurs when nerve cells in the brain that produce dopamine, a neurotransmitter that helps control movement, begin to deteriorate or die. This leads to a variety of symptoms including tremors, stiffness, slowness of movement, and balance problems. Symptoms of Parkinson’s Disease include: - **Tremors**: Shaking or trembling, often beginning in one hand. - **Bradykinesia**: Slowness of movement. - **Rigidity**: Muscle stiffness, which can limit range of motion. - **Postural instability**: Difficulty maintaining balance and walking. - **Shuffling walk**: Taking small steps while walking. The disease is divided into five stages, with each stage representing a more severe decline in motor abilities and overall functioning. Parkinson's Disease is typically diagnosed based on medical history, symptoms, and neurological examination. Although Parkinson's disease cannot be cured, treatments focus on managing symptoms and improving the quality of life. Common treatments include: - **Levodopa (L-DOPA)**: A medication that helps replenish dopamine in the brain. - **Dopamine Agonists**: Drugs that mimic dopamine's effects in the brain. - **Physical therapy**: To help improve mobility and muscle strength. - **Deep brain stimulation (DBS)**: A surgical procedure that involves implanting a device in the brain to help control symptoms. Genetics and environmental factors, including exposure to pesticides, are believed to play a role in the development of Parkinson's disease. """ } # Function to load selected model def load_model(model_name): tokenizer = AutoTokenizer.from_pretrained(models[model_name]) model = AutoModelForCausalLM.from_pretrained(models[model_name]) pipe = pipeline("text-generation", model=model, tokenizer=tokenizer) return pipe # Function to generate information based on disease input def generate_information(disease_info, model_name): if not disease_info.strip(): return "Please enter disease information!" # Load selected model pipe = load_model(model_name) # Generate information result = pipe(disease_info, max_length=200, num_return_sequences=1) return result[0]['generated_text'] # Create Streamlit Interface with Sidebar def create_interface(): # Custom CSS for background color, font, and modern design st.markdown( """ """, unsafe_allow_html=True ) # Upper Navigation Bar st.markdown('
', unsafe_allow_html=True) # Initialize page state if "page" not in st.session_state: st.session_state.page = "Home" # Layout for the main content if st.session_state.page == "Home": st.title("Medical GPT Application") st.markdown("### Enter disease information and select a model to generate information.") # Card container for model selection with st.container(): st.markdown('