updated UI code ✅✅
Browse files- mediSync/app.py +59 -30
mediSync/app.py
CHANGED
@@ -698,7 +698,7 @@ def create_interface():
|
|
698 |
|
699 |
with gr.Blocks(
|
700 |
title="MediSync: Multi-Modal Medical Analysis System",
|
701 |
-
theme=gr.themes.Default(),
|
702 |
css="""
|
703 |
/* Modern neumorphic card style for all result containers */
|
704 |
.medisync-card {
|
@@ -730,7 +730,10 @@ def create_interface():
|
|
730 |
.gr-button, .end-consultation-btn {
|
731 |
border-radius: 8px !important;
|
732 |
font-weight: 600 !important;
|
733 |
-
font-size:
|
|
|
|
|
|
|
734 |
transition: background 0.2s, color 0.2s;
|
735 |
}
|
736 |
.end-consultation-btn {
|
@@ -738,6 +741,10 @@ def create_interface():
|
|
738 |
border: none !important;
|
739 |
color: #fff !important;
|
740 |
box-shadow: 0 2px 8px 0 rgba(220,53,69,0.10);
|
|
|
|
|
|
|
|
|
741 |
}
|
742 |
.end-consultation-btn:hover {
|
743 |
background: linear-gradient(90deg, #c82333 60%, #ff7675 100%) !important;
|
@@ -779,6 +786,29 @@ def create_interface():
|
|
779 |
html[data-theme="dark"] #end_consultation_status, html[data-theme="dark"] #end_consultation_status * {
|
780 |
color: #f8fafc !important;
|
781 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
782 |
"""
|
783 |
) as interface:
|
784 |
gr.Markdown(
|
@@ -829,7 +859,7 @@ def create_interface():
|
|
829 |
with gr.Row():
|
830 |
with gr.Column():
|
831 |
multi_img_input = gr.Image(label="Upload X-ray Image", type="pil", elem_id="multi_img_input")
|
832 |
-
multi_img_enhance = gr.Button("Enhance Image"
|
833 |
multi_text_input = gr.Textbox(
|
834 |
label="Enter Medical Report Text",
|
835 |
placeholder="Enter the radiologist's report text here...",
|
@@ -837,7 +867,7 @@ def create_interface():
|
|
837 |
value=example_report if sample_image_path is None else None,
|
838 |
elem_id="multi_text_input"
|
839 |
)
|
840 |
-
multi_analyze_btn = gr.Button("Analyze Image & Text", variant="primary"
|
841 |
with gr.Column():
|
842 |
multi_results = gr.HTML(label="Analysis Results", elem_id="multi_results")
|
843 |
multi_plot = gr.HTML(label="Visualization", elem_id="multi_plot")
|
@@ -852,8 +882,8 @@ def create_interface():
|
|
852 |
with gr.Row():
|
853 |
with gr.Column():
|
854 |
img_input = gr.Image(label="Upload X-ray Image", type="pil", elem_id="img_input")
|
855 |
-
img_enhance = gr.Button("Enhance Image"
|
856 |
-
img_analyze_btn = gr.Button("Analyze Image", variant="primary"
|
857 |
with gr.Column():
|
858 |
img_output = gr.Image(label="Processed Image", elem_id="img_output")
|
859 |
img_results = gr.HTML(label="Analysis Results", elem_id="img_results")
|
@@ -875,7 +905,7 @@ def create_interface():
|
|
875 |
value=example_report,
|
876 |
elem_id="text_input"
|
877 |
)
|
878 |
-
text_analyze_btn = gr.Button("Analyze Text", variant="primary"
|
879 |
with gr.Column():
|
880 |
text_output = gr.Textbox(label="Processed Text", elem_id="text_output")
|
881 |
text_results = gr.HTML(label="Analysis Results", elem_id="text_results")
|
@@ -892,8 +922,7 @@ def create_interface():
|
|
892 |
"End Consultation",
|
893 |
variant="stop",
|
894 |
size="lg",
|
895 |
-
elem_classes=["end-consultation-btn"]
|
896 |
-
icon="🛑"
|
897 |
)
|
898 |
end_consultation_status = gr.HTML(label="Status", elem_id="end_consultation_status")
|
899 |
|
@@ -952,16 +981,16 @@ def create_interface():
|
|
952 |
if result["status"] == "success":
|
953 |
doctors_urls = get_doctors_page_urls()
|
954 |
html_response = f"""
|
955 |
-
<div class='medisync-force-text' style='color: #28a745; padding: 15px; background-color: #e6ffe6; border-radius: 5px; margin: 10px 0;
|
956 |
-
<h3>✅ Consultation Completed Successfully!</h3>
|
957 |
-
<p>{result['message']}</p>
|
958 |
-
<p>Your appointment has been marked as completed.</p>
|
959 |
<button onclick="window.open('{doctors_urls['local']}', '_blank')"
|
960 |
-
style="background-color: #00bfae; color: white; padding:
|
961 |
Return to Doctors Page (Local)
|
962 |
</button>
|
963 |
<button onclick="window.open('{doctors_urls['production']}', '_blank')"
|
964 |
-
style="background-color: #6c63ff; color: white; padding:
|
965 |
Return to Doctors Page (Production)
|
966 |
</button>
|
967 |
</div>
|
@@ -969,27 +998,27 @@ def create_interface():
|
|
969 |
else:
|
970 |
if "Cannot connect to Flask app" in result['message']:
|
971 |
html_response = f"""
|
972 |
-
<div class='medisync-force-text' style='color: #ff9800; padding: 15px; background-color: #fff3cd; border-radius: 5px; margin: 10px 0;
|
973 |
-
<h3>⚠️ Consultation Ready to Complete</h3>
|
974 |
-
<p>Your consultation analysis is complete! However, we cannot automatically mark your appointment as completed because the Flask app is not accessible from this environment.</p>
|
975 |
-
<p><strong>Appointment ID:</strong> {appointment_id.strip()}</p>
|
976 |
-
<p><strong>Next Steps:</strong></p>
|
977 |
<ol>
|
978 |
-
<li>Copy your appointment ID: <code>{appointment_id.strip()}</code></li>
|
979 |
-
<li>Return to your Flask app (doctors page)</li>
|
980 |
-
<li>Manually complete the appointment using the appointment ID</li>
|
981 |
</ol>
|
982 |
<div style="margin-top: 15px;">
|
983 |
<button onclick="window.open('http://127.0.0.1:600/complete_appointment_manual?appointment_id={appointment_id.strip()}', '_blank')"
|
984 |
-
style="background-color: #00bfae; color: white; padding:
|
985 |
Complete Appointment
|
986 |
</button>
|
987 |
<button onclick="window.open('http://127.0.0.1:600/doctors', '_blank')"
|
988 |
-
style="background-color: #6c63ff; color: white; padding:
|
989 |
Return to Doctors Page
|
990 |
</button>
|
991 |
<button onclick="navigator.clipboard.writeText('{appointment_id.strip()}')"
|
992 |
-
style="background-color: #23272f; color: white; padding:
|
993 |
Copy Appointment ID
|
994 |
</button>
|
995 |
</div>
|
@@ -997,10 +1026,10 @@ def create_interface():
|
|
997 |
"""
|
998 |
else:
|
999 |
html_response = f"""
|
1000 |
-
<div class='medisync-force-text' style='color: #dc3545; padding: 15px; background-color: #ffe6e6; border-radius: 5px; margin: 10px 0;
|
1001 |
-
<h3>❌ Error Completing Consultation</h3>
|
1002 |
-
<p>{result['message']}</p>
|
1003 |
-
<p>Please try again or contact support if the problem persists.</p>
|
1004 |
</div>
|
1005 |
"""
|
1006 |
return html_response
|
|
|
698 |
|
699 |
with gr.Blocks(
|
700 |
title="MediSync: Multi-Modal Medical Analysis System",
|
701 |
+
theme=gr.themes.Default(),
|
702 |
css="""
|
703 |
/* Modern neumorphic card style for all result containers */
|
704 |
.medisync-card {
|
|
|
730 |
.gr-button, .end-consultation-btn {
|
731 |
border-radius: 8px !important;
|
732 |
font-weight: 600 !important;
|
733 |
+
font-size: 1rem !important;
|
734 |
+
padding: 8px 18px !important;
|
735 |
+
min-width: 120px !important;
|
736 |
+
min-height: 38px !important;
|
737 |
transition: background 0.2s, color 0.2s;
|
738 |
}
|
739 |
.end-consultation-btn {
|
|
|
741 |
border: none !important;
|
742 |
color: #fff !important;
|
743 |
box-shadow: 0 2px 8px 0 rgba(220,53,69,0.10);
|
744 |
+
font-size: 1.05rem !important;
|
745 |
+
padding: 10px 24px !important;
|
746 |
+
min-width: 160px !important;
|
747 |
+
min-height: 40px !important;
|
748 |
}
|
749 |
.end-consultation-btn:hover {
|
750 |
background: linear-gradient(90deg, #c82333 60%, #ff7675 100%) !important;
|
|
|
786 |
html[data-theme="dark"] #end_consultation_status, html[data-theme="dark"] #end_consultation_status * {
|
787 |
color: #f8fafc !important;
|
788 |
}
|
789 |
+
/* Style for the popup/status after end consultation for visibility */
|
790 |
+
#end_consultation_status, #end_consultation_status * {
|
791 |
+
font-size: 1.08rem !important;
|
792 |
+
font-weight: 500 !important;
|
793 |
+
}
|
794 |
+
html[data-theme="dark"] #end_consultation_status, html[data-theme="dark"] #end_consultation_status * {
|
795 |
+
color: #f8fafc !important;
|
796 |
+
}
|
797 |
+
/* Style the buttons inside the end consultation status popup */
|
798 |
+
#end_consultation_status button {
|
799 |
+
font-size: 1rem !important;
|
800 |
+
font-weight: 600 !important;
|
801 |
+
border-radius: 6px !important;
|
802 |
+
padding: 8px 18px !important;
|
803 |
+
margin-top: 8px !important;
|
804 |
+
margin-bottom: 4px !important;
|
805 |
+
min-width: 120px !important;
|
806 |
+
min-height: 36px !important;
|
807 |
+
box-shadow: 0 1.5px 4px 0 rgba(0,191,174,0.08);
|
808 |
+
}
|
809 |
+
#end_consultation_status button:active, #end_consultation_status button:focus {
|
810 |
+
outline: 2px solid #00bfae !important;
|
811 |
+
}
|
812 |
"""
|
813 |
) as interface:
|
814 |
gr.Markdown(
|
|
|
859 |
with gr.Row():
|
860 |
with gr.Column():
|
861 |
multi_img_input = gr.Image(label="Upload X-ray Image", type="pil", elem_id="multi_img_input")
|
862 |
+
multi_img_enhance = gr.Button("Enhance Image")
|
863 |
multi_text_input = gr.Textbox(
|
864 |
label="Enter Medical Report Text",
|
865 |
placeholder="Enter the radiologist's report text here...",
|
|
|
867 |
value=example_report if sample_image_path is None else None,
|
868 |
elem_id="multi_text_input"
|
869 |
)
|
870 |
+
multi_analyze_btn = gr.Button("Analyze Image & Text", variant="primary")
|
871 |
with gr.Column():
|
872 |
multi_results = gr.HTML(label="Analysis Results", elem_id="multi_results")
|
873 |
multi_plot = gr.HTML(label="Visualization", elem_id="multi_plot")
|
|
|
882 |
with gr.Row():
|
883 |
with gr.Column():
|
884 |
img_input = gr.Image(label="Upload X-ray Image", type="pil", elem_id="img_input")
|
885 |
+
img_enhance = gr.Button("Enhance Image")
|
886 |
+
img_analyze_btn = gr.Button("Analyze Image", variant="primary")
|
887 |
with gr.Column():
|
888 |
img_output = gr.Image(label="Processed Image", elem_id="img_output")
|
889 |
img_results = gr.HTML(label="Analysis Results", elem_id="img_results")
|
|
|
905 |
value=example_report,
|
906 |
elem_id="text_input"
|
907 |
)
|
908 |
+
text_analyze_btn = gr.Button("Analyze Text", variant="primary")
|
909 |
with gr.Column():
|
910 |
text_output = gr.Textbox(label="Processed Text", elem_id="text_output")
|
911 |
text_results = gr.HTML(label="Analysis Results", elem_id="text_results")
|
|
|
922 |
"End Consultation",
|
923 |
variant="stop",
|
924 |
size="lg",
|
925 |
+
elem_classes=["end-consultation-btn"]
|
|
|
926 |
)
|
927 |
end_consultation_status = gr.HTML(label="Status", elem_id="end_consultation_status")
|
928 |
|
|
|
981 |
if result["status"] == "success":
|
982 |
doctors_urls = get_doctors_page_urls()
|
983 |
html_response = f"""
|
984 |
+
<div class='medisync-force-text' style='color: #28a745; padding: 15px; background-color: #e6ffe6; border-radius: 5px; margin: 10px 0;">
|
985 |
+
<h3 style="color: #28a745;">✅ Consultation Completed Successfully!</h3>
|
986 |
+
<p style="color: var(--body-text-color, #222);">{result['message']}</p>
|
987 |
+
<p style="color: var(--body-text-color, #222);">Your appointment has been marked as completed.</p>
|
988 |
<button onclick="window.open('{doctors_urls['local']}', '_blank')"
|
989 |
+
style="background-color: #00bfae; color: white; padding: 8px 18px; border: none; border-radius: 6px; cursor: pointer; margin-top: 10px;">
|
990 |
Return to Doctors Page (Local)
|
991 |
</button>
|
992 |
<button onclick="window.open('{doctors_urls['production']}', '_blank')"
|
993 |
+
style="background-color: #6c63ff; color: white; padding: 8px 18px; border: none; border-radius: 6px; cursor: pointer; margin-top: 10px; margin-left: 10px;">
|
994 |
Return to Doctors Page (Production)
|
995 |
</button>
|
996 |
</div>
|
|
|
998 |
else:
|
999 |
if "Cannot connect to Flask app" in result['message']:
|
1000 |
html_response = f"""
|
1001 |
+
<div class='medisync-force-text' style='color: #ff9800; padding: 15px; background-color: #fff3cd; border-radius: 5px; margin: 10px 0;">
|
1002 |
+
<h3 style="color: #ff9800;">⚠️ Consultation Ready to Complete</h3>
|
1003 |
+
<p style="color: var(--body-text-color, #222);">Your consultation analysis is complete! However, we cannot automatically mark your appointment as completed because the Flask app is not accessible from this environment.</p>
|
1004 |
+
<p style="color: var(--body-text-color, #222);"><strong>Appointment ID:</strong> {appointment_id.strip()}</p>
|
1005 |
+
<p style="color: var(--body-text-color, #222);"><strong>Next Steps:</strong></p>
|
1006 |
<ol>
|
1007 |
+
<li style="color: var(--body-text-color, #222);">Copy your appointment ID: <code>{appointment_id.strip()}</code></li>
|
1008 |
+
<li style="color: var(--body-text-color, #222);">Return to your Flask app (doctors page)</li>
|
1009 |
+
<li style="color: var(--body-text-color, #222);">Manually complete the appointment using the appointment ID</li>
|
1010 |
</ol>
|
1011 |
<div style="margin-top: 15px;">
|
1012 |
<button onclick="window.open('http://127.0.0.1:600/complete_appointment_manual?appointment_id={appointment_id.strip()}', '_blank')"
|
1013 |
+
style="background-color: #00bfae; color: white; padding: 8px 18px; border: none; border-radius: 6px; cursor: pointer; margin-right: 10px;">
|
1014 |
Complete Appointment
|
1015 |
</button>
|
1016 |
<button onclick="window.open('http://127.0.0.1:600/doctors', '_blank')"
|
1017 |
+
style="background-color: #6c63ff; color: white; padding: 8px 18px; border: none; border-radius: 6px; cursor: pointer; margin-right: 10px;">
|
1018 |
Return to Doctors Page
|
1019 |
</button>
|
1020 |
<button onclick="navigator.clipboard.writeText('{appointment_id.strip()}')"
|
1021 |
+
style="background-color: #23272f; color: white; padding: 8px 18px; border: none; border-radius: 6px; cursor: pointer;">
|
1022 |
Copy Appointment ID
|
1023 |
</button>
|
1024 |
</div>
|
|
|
1026 |
"""
|
1027 |
else:
|
1028 |
html_response = f"""
|
1029 |
+
<div class='medisync-force-text' style='color: #dc3545; padding: 15px; background-color: #ffe6e6; border-radius: 5px; margin: 10px 0;">
|
1030 |
+
<h3 style="color: #dc3545;">❌ Error Completing Consultation</h3>
|
1031 |
+
<p style="color: var(--body-text-color, #222);">{result['message']}</p>
|
1032 |
+
<p style="color: var(--body-text-color, #222);">Please try again or contact support if the problem persists.</p>
|
1033 |
</div>
|
1034 |
"""
|
1035 |
return html_response
|