Spaces:
Sleeping
Sleeping
file modified
Browse files
app.py
CHANGED
|
@@ -296,80 +296,82 @@ def chatbot_ui():
|
|
| 296 |
with gr.Blocks() as demo:
|
| 297 |
gr.Markdown("## Dr. SkinCare - Virtual Dermatologist")
|
| 298 |
|
| 299 |
-
|
| 300 |
# Chatbot Tab
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
|
| 342 |
# Predictive Modeling Tab
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
|
|
|
|
|
|
| 373 |
|
| 374 |
|
| 375 |
logger.info("Gradio interface setup complete.")
|
|
|
|
| 296 |
with gr.Blocks() as demo:
|
| 297 |
gr.Markdown("## Dr. SkinCare - Virtual Dermatologist")
|
| 298 |
|
| 299 |
+
with gr.Tabs():
|
| 300 |
# Chatbot Tab
|
| 301 |
+
with gr.Tab("Chatbot"):
|
| 302 |
+
chat_history = gr.State([])
|
| 303 |
+
|
| 304 |
+
with gr.Row():
|
| 305 |
+
with gr.Column(scale=3):
|
| 306 |
+
chatbot = gr.Chatbot(label="Responses", elem_id="chatbot")
|
| 307 |
+
user_input = gr.Textbox(
|
| 308 |
+
label="Ask a health-related question",
|
| 309 |
+
placeholder="Describe your symptoms...",
|
| 310 |
+
elem_id="user-input",
|
| 311 |
+
lines=1,
|
| 312 |
+
)
|
| 313 |
+
with gr.Column(scale=1):
|
| 314 |
+
uploaded_image = gr.Image(label="Upload an Image", type="pil")
|
| 315 |
+
submit_btn = gr.Button("Submit")
|
| 316 |
+
clear_btn = gr.Button("Clear")
|
| 317 |
+
audio_output = gr.Audio(label="Audio Response")
|
| 318 |
+
|
| 319 |
+
def handle_submit(user_query, image, history):
|
| 320 |
+
logger.info("User submitted a query.")
|
| 321 |
+
response, audio = customLLMBot(user_query, image, history)
|
| 322 |
+
return response, audio, None, "", history
|
| 323 |
+
|
| 324 |
+
user_input.submit(
|
| 325 |
+
handle_submit,
|
| 326 |
+
inputs=[user_input, uploaded_image, chat_history],
|
| 327 |
+
outputs=[chatbot, audio_output, uploaded_image, user_input, chat_history],
|
| 328 |
+
)
|
| 329 |
+
|
| 330 |
+
submit_btn.click(
|
| 331 |
+
handle_submit,
|
| 332 |
+
inputs=[user_input, uploaded_image, chat_history],
|
| 333 |
+
outputs=[chatbot, audio_output, uploaded_image, user_input, chat_history],
|
| 334 |
+
)
|
| 335 |
+
|
| 336 |
+
clear_btn.click(
|
| 337 |
+
lambda: ([], "", None, []),
|
| 338 |
+
inputs=[],
|
| 339 |
+
outputs=[chatbot, user_input, uploaded_image, chat_history],
|
| 340 |
+
)
|
| 341 |
|
| 342 |
# Predictive Modeling Tab
|
| 343 |
+
with gr.Tab("Predictive Modeling"):
|
| 344 |
+
gr.Markdown("### Upload Image for Prediction")
|
| 345 |
+
|
| 346 |
+
with gr.Row():
|
| 347 |
+
with gr.Column():
|
| 348 |
+
prediction_image = gr.Image(label="Upload Image", type="pil")
|
| 349 |
+
predict_btn = gr.Button("Predict")
|
| 350 |
+
|
| 351 |
+
with gr.Column():
|
| 352 |
+
gr.Markdown("### Prediction Result")
|
| 353 |
+
prediction_output = gr.Textbox(label="Result", interactive=False)
|
| 354 |
+
gr.Markdown("### Description")
|
| 355 |
+
description_output = gr.Textbox(label="Description", interactive=False)
|
| 356 |
+
clear_prediction_btn = gr.Button("Clear Prediction")
|
| 357 |
+
|
| 358 |
+
def clear_prediction(prediction_image, prediction_output, description_output):
|
| 359 |
+
logger.info("Clearing prediction results.")
|
| 360 |
+
return None, "", ""
|
| 361 |
+
|
| 362 |
+
predict_btn.click(
|
| 363 |
+
predict_image,
|
| 364 |
+
inputs=[prediction_image],
|
| 365 |
+
outputs=[prediction_output, description_output],
|
| 366 |
+
)
|
| 367 |
+
|
| 368 |
+
clear_prediction_btn.click(
|
| 369 |
+
clear_prediction,
|
| 370 |
+
inputs=[prediction_image, prediction_output, description_output],
|
| 371 |
+
outputs=[prediction_image, prediction_output, description_output],
|
| 372 |
+
)
|
| 373 |
+
|
| 374 |
+
|
| 375 |
|
| 376 |
|
| 377 |
logger.info("Gradio interface setup complete.")
|