Reshmarb commited on
Commit
a5bcf71
·
1 Parent(s): 51c47b3

file modified

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