Update app.py
Browse files
app.py
CHANGED
|
@@ -19,9 +19,11 @@ processor = AutoImageProcessor.from_pretrained(MODEL_NAME)
|
|
| 19 |
GROQ_API_KEY = os.getenv("GROQ_API_KEY", "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")
|
| 20 |
client = Groq(api_key=GROQ_API_KEY)
|
| 21 |
|
| 22 |
-
# Initialize session state for
|
| 23 |
if "disease_name" not in st.session_state:
|
| 24 |
st.session_state.disease_name = None
|
|
|
|
|
|
|
| 25 |
|
| 26 |
# Function to predict skin disease
|
| 27 |
def predict_skin_disease(image):
|
|
@@ -67,23 +69,31 @@ st.image("https://huggingface.co/spaces/your-huggingface-space/logo.png", width=
|
|
| 67 |
st.title("🩺 DermaBot - AI Skin Disease Detector")
|
| 68 |
st.write("Upload an image of a skin condition to get a diagnosis and ask questions about it.")
|
| 69 |
|
| 70 |
-
# Upload image
|
| 71 |
uploaded_image = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
|
| 72 |
|
| 73 |
if uploaded_image:
|
| 74 |
image = Image.open(uploaded_image)
|
| 75 |
-
st.image(image, caption="Uploaded Image", use_container_width=True)
|
| 76 |
|
|
|
|
| 77 |
if st.button("Detect Disease"):
|
| 78 |
with st.spinner("Analyzing..."):
|
| 79 |
disease_name = predict_skin_disease(image)
|
| 80 |
-
st.session_state.disease_name = disease_name # Store in session state
|
| 81 |
disease_info = get_disease_info(disease_name)
|
| 82 |
-
st.success(f"**Detected Disease:** {disease_name}")
|
| 83 |
-
st.write(f"**Details:** {disease_info}")
|
| 84 |
|
| 85 |
-
#
|
| 86 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
user_query = st.text_input("Ask about the detected disease:")
|
| 88 |
|
| 89 |
if st.button("Ask"):
|
|
|
|
| 19 |
GROQ_API_KEY = os.getenv("GROQ_API_KEY", "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")
|
| 20 |
client = Groq(api_key=GROQ_API_KEY)
|
| 21 |
|
| 22 |
+
# Initialize session state for disease details
|
| 23 |
if "disease_name" not in st.session_state:
|
| 24 |
st.session_state.disease_name = None
|
| 25 |
+
if "disease_info" not in st.session_state:
|
| 26 |
+
st.session_state.disease_info = None
|
| 27 |
|
| 28 |
# Function to predict skin disease
|
| 29 |
def predict_skin_disease(image):
|
|
|
|
| 69 |
st.title("🩺 DermaBot - AI Skin Disease Detector")
|
| 70 |
st.write("Upload an image of a skin condition to get a diagnosis and ask questions about it.")
|
| 71 |
|
| 72 |
+
# Step 1: Upload image
|
| 73 |
uploaded_image = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
|
| 74 |
|
| 75 |
if uploaded_image:
|
| 76 |
image = Image.open(uploaded_image)
|
| 77 |
+
st.image(image, caption="Uploaded Image", use_container_width=True)
|
| 78 |
|
| 79 |
+
# Step 2: Detect disease
|
| 80 |
if st.button("Detect Disease"):
|
| 81 |
with st.spinner("Analyzing..."):
|
| 82 |
disease_name = predict_skin_disease(image)
|
|
|
|
| 83 |
disease_info = get_disease_info(disease_name)
|
|
|
|
|
|
|
| 84 |
|
| 85 |
+
# Store results in session state
|
| 86 |
+
st.session_state.disease_name = disease_name
|
| 87 |
+
st.session_state.disease_info = disease_info
|
| 88 |
+
|
| 89 |
+
# Display detected disease information if available
|
| 90 |
+
if st.session_state.disease_name:
|
| 91 |
+
st.success(f"**Detected Disease:** {st.session_state.disease_name}")
|
| 92 |
+
st.write(f"**Details:** {st.session_state.disease_info}")
|
| 93 |
+
|
| 94 |
+
# Step 3: Chatbot
|
| 95 |
+
st.subheader("💬 Ask DermaBot about this disease")
|
| 96 |
+
|
| 97 |
user_query = st.text_input("Ask about the detected disease:")
|
| 98 |
|
| 99 |
if st.button("Ask"):
|