Spaces:
Sleeping
Sleeping
Create app.py
Browse files12345678910111213141516171819202122232425262728293031323334353637383940414243# app.pyimport gradio as gr
def medical_diagnosis(fever, cough, headache, fatigue): """ Rule-based medical diagnosis function for Gradio GUI. Returns diagnosis and recommendation based on symptoms. """ # Nested condition logic if fever: if cough and headache: return "Diagnosis: Possible Flu. π Recommendation: Consult a doctor and rest." elif cough: return "Diagnosis: Possible Cold. π Recommendation: Drink fluids and rest." elif headache: return "Diagnosis: Possible Migraine. π Recommendation: Take pain relief medication." else: return "Diagnosis: Fever of unknown cause. π Recommendation: Monitor and consult doctor if persists." else: if headache and fatigue: return "Diagnosis: Possible Stress or Mild Infection. π Recommendation: Rest and hydrate." elif fatigue: return "Diagnosis: Possible Fatigue due to lack of sleep. π Recommendation: Rest." else: return "Diagnosis: No significant symptoms detected. β
Recommendation: Healthy"
# Gradio interfaceinterface = gr.Interface( fn=medical_diagnosis, inputs=[ gr.Checkbox(label="Fever"), gr.Checkbox(label="Cough"), gr.Checkbox(label="Headache"), gr.Checkbox(label="Fatigue") ], outputs="text", title="π©Ί Interactive Medical Diagnosis System", description="Select your symptoms and click Submit to get a diagnosis and recommendation.")
# Launch the appif __name__ == "__main__": interface.launch()app.pyAdded+43