Update app.py
Browse files
app.py
CHANGED
|
@@ -1,16 +1,18 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from pubmed_rag import search_pubmed, fetch_pubmed_abstracts, summarize_text
|
| 3 |
from image_pipeline import analyze_medical_image
|
| 4 |
-
from models import
|
| 5 |
|
| 6 |
st.set_page_config(page_title="Advanced Medical AI", layout="wide")
|
| 7 |
|
|
|
|
| 8 |
def main():
|
| 9 |
st.title("Advanced Medical AI")
|
| 10 |
st.sidebar.title("Features")
|
| 11 |
task = st.sidebar.selectbox("Choose a task:", ["PubMed Q&A", "Medical Image Analysis"])
|
| 12 |
|
| 13 |
if task == "PubMed Q&A":
|
|
|
|
| 14 |
st.subheader("PubMed Question Answering")
|
| 15 |
query = st.text_input("Enter your medical question:", "What are the latest treatments for diabetes?")
|
| 16 |
max_results = st.slider("Number of PubMed articles to retrieve:", 1, 10, 5)
|
|
@@ -30,22 +32,28 @@ def main():
|
|
| 30 |
for pmid, summary in summaries.items():
|
| 31 |
st.write(f"**PMID {pmid}**: {summary}")
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
with st.spinner("Generating answer..."):
|
| 36 |
-
answer = chat_with_openai(system_message, user_message)
|
| 37 |
st.subheader("AI-Powered Answer")
|
| 38 |
st.write(answer)
|
| 39 |
|
| 40 |
elif task == "Medical Image Analysis":
|
|
|
|
| 41 |
st.subheader("Medical Image Analysis")
|
| 42 |
uploaded_file = st.file_uploader("Upload a medical image (PNG/JPG):", type=["png", "jpg", "jpeg"])
|
|
|
|
| 43 |
if uploaded_file:
|
|
|
|
| 44 |
st.image(uploaded_file, caption="Uploaded Image", use_column_width=True)
|
|
|
|
|
|
|
| 45 |
with st.spinner("Analyzing image..."):
|
| 46 |
result = analyze_medical_image(uploaded_file)
|
|
|
|
|
|
|
| 47 |
st.subheader("Diagnostic Insight")
|
| 48 |
st.write(result)
|
| 49 |
|
|
|
|
| 50 |
if __name__ == "__main__":
|
| 51 |
-
main()
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from pubmed_rag import search_pubmed, fetch_pubmed_abstracts, summarize_text
|
| 3 |
from image_pipeline import analyze_medical_image
|
| 4 |
+
from models import query_medical_text
|
| 5 |
|
| 6 |
st.set_page_config(page_title="Advanced Medical AI", layout="wide")
|
| 7 |
|
| 8 |
+
|
| 9 |
def main():
|
| 10 |
st.title("Advanced Medical AI")
|
| 11 |
st.sidebar.title("Features")
|
| 12 |
task = st.sidebar.selectbox("Choose a task:", ["PubMed Q&A", "Medical Image Analysis"])
|
| 13 |
|
| 14 |
if task == "PubMed Q&A":
|
| 15 |
+
# PubMed Q&A Section
|
| 16 |
st.subheader("PubMed Question Answering")
|
| 17 |
query = st.text_input("Enter your medical question:", "What are the latest treatments for diabetes?")
|
| 18 |
max_results = st.slider("Number of PubMed articles to retrieve:", 1, 10, 5)
|
|
|
|
| 32 |
for pmid, summary in summaries.items():
|
| 33 |
st.write(f"**PMID {pmid}**: {summary}")
|
| 34 |
|
| 35 |
+
with st.spinner("Querying the medical reasoning model..."):
|
| 36 |
+
answer = query_medical_text(query)
|
|
|
|
|
|
|
| 37 |
st.subheader("AI-Powered Answer")
|
| 38 |
st.write(answer)
|
| 39 |
|
| 40 |
elif task == "Medical Image Analysis":
|
| 41 |
+
# Medical Image Analysis Section
|
| 42 |
st.subheader("Medical Image Analysis")
|
| 43 |
uploaded_file = st.file_uploader("Upload a medical image (PNG/JPG):", type=["png", "jpg", "jpeg"])
|
| 44 |
+
|
| 45 |
if uploaded_file:
|
| 46 |
+
# Display the uploaded image
|
| 47 |
st.image(uploaded_file, caption="Uploaded Image", use_column_width=True)
|
| 48 |
+
|
| 49 |
+
# Analyze the medical image
|
| 50 |
with st.spinner("Analyzing image..."):
|
| 51 |
result = analyze_medical_image(uploaded_file)
|
| 52 |
+
|
| 53 |
+
# Display the result
|
| 54 |
st.subheader("Diagnostic Insight")
|
| 55 |
st.write(result)
|
| 56 |
|
| 57 |
+
|
| 58 |
if __name__ == "__main__":
|
| 59 |
+
main()
|