Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -49,8 +49,11 @@ def construct_process_message(
|
|
| 49 |
# if overall_units_total != 0
|
| 50 |
# else 0
|
| 51 |
# )
|
|
|
|
|
|
|
|
|
|
| 52 |
return (
|
| 53 |
-
|
| 54 |
disable_component() if not final_output else enable_component(), # run_btn
|
| 55 |
hide_component() if not final_output else show_component(), # file_input
|
| 56 |
final_output, # pdf_download
|
|
@@ -89,16 +92,32 @@ def show_component():
|
|
| 89 |
|
| 90 |
|
| 91 |
def render_about_markdowns():
|
| 92 |
-
with gr.
|
| 93 |
gr.Markdown("# 🧪 How It Works")
|
| 94 |
gr.Markdown(
|
| 95 |
"""
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
)
|
|
|
|
| 102 |
|
| 103 |
return group
|
| 104 |
|
|
@@ -221,6 +240,40 @@ with gr.Blocks(
|
|
| 221 |
theme=gr.themes.Ocean(),
|
| 222 |
title="SHEAMI",
|
| 223 |
css="""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
#transparent_textbox input,
|
| 225 |
#transparent_textbox textarea {
|
| 226 |
color: #00FF00; /* classic terminal green */
|
|
@@ -287,29 +340,42 @@ with gr.Blocks(
|
|
| 287 |
|
| 288 |
with gr.Column(visible=False) as status_container:
|
| 289 |
with gr.Column(visible=False) as final_report_container:
|
| 290 |
-
gr.Markdown("# ✅
|
| 291 |
-
pdf_download = gr.File(label="Click to download")
|
| 292 |
-
generate_another_btn = gr.Button(
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 313 |
|
| 314 |
def hide_slider_if_0_or_100(progress_value):
|
| 315 |
if progress_value == 0 or progress_value == 100:
|
|
|
|
| 49 |
# if overall_units_total != 0
|
| 50 |
# else 0
|
| 51 |
# )
|
| 52 |
+
message = message.replace("\n","<br>")
|
| 53 |
+
formatted_message = f"<div class='transparent_div'>{message}<br><span class='dots'></span></div>" if not final_output else f"<div class='transparent_div'>{message}</div>"
|
| 54 |
+
|
| 55 |
return (
|
| 56 |
+
formatted_message, # logs_textbox
|
| 57 |
disable_component() if not final_output else enable_component(), # run_btn
|
| 58 |
hide_component() if not final_output else show_component(), # file_input
|
| 59 |
final_output, # pdf_download
|
|
|
|
| 92 |
|
| 93 |
|
| 94 |
def render_about_markdowns():
|
| 95 |
+
with gr.Column() as group:
|
| 96 |
gr.Markdown("# 🧪 How It Works")
|
| 97 |
gr.Markdown(
|
| 98 |
"""
|
| 99 |
+
- ℹ️ Sheami™ is designed to assist users by providing automated analysis and insights.
|
| 100 |
+
- 📄 Upload one or more lab reports to get **AI-powered insights** for the individual.
|
| 101 |
+
- ⏱️ Reports are retained on our server **only for a few minutes** while processing.
|
| 102 |
+
- 📈 If you upload multiple reports for the same person, we can show **short-term trends** to help track changes over time.
|
| 103 |
+
- 🔒 **No data is stored permanently**—all uploaded reports are deleted automatically after processing.
|
| 104 |
+
""",
|
| 105 |
+
show_copy_button=False,
|
| 106 |
+
)
|
| 107 |
+
gr.Markdown("---")
|
| 108 |
+
gr.Markdown(
|
| 109 |
"""
|
| 110 |
+
> ⚠️ **Disclaimer**
|
| 111 |
+
> This application is intended solely for informational and educational purposes.
|
| 112 |
+
> It is **not** a substitute for professional medical advice, diagnosis, or treatment.
|
| 113 |
+
> Always seek the guidance of a qualified healthcare provider with any questions
|
| 114 |
+
> you may have regarding a medical condition. Never disregard professional advice
|
| 115 |
+
> or delay seeking it because of information provided by this app.
|
| 116 |
+
|
| 117 |
+
""",
|
| 118 |
+
show_copy_button=False,
|
| 119 |
)
|
| 120 |
+
gr.Markdown("---")
|
| 121 |
|
| 122 |
return group
|
| 123 |
|
|
|
|
| 240 |
theme=gr.themes.Ocean(),
|
| 241 |
title="SHEAMI",
|
| 242 |
css="""
|
| 243 |
+
.dots {
|
| 244 |
+
display: inline-block;
|
| 245 |
+
min-width: 1.5em; /* enough space for 3 dots */
|
| 246 |
+
text-align: left;
|
| 247 |
+
color: #00FF00;
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
.dots::after {
|
| 251 |
+
content: " .";
|
| 252 |
+
min-width : 100px;
|
| 253 |
+
animation: dots 1.5s steps(3, end) infinite;
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
@keyframes dots {
|
| 257 |
+
0% { content: " "; }
|
| 258 |
+
33% { content: " ."; }
|
| 259 |
+
66% { content: " .."; }
|
| 260 |
+
100% { content: " ..."; }
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
div.transparent_div {
|
| 264 |
+
color: #00FF00; /* classic terminal green */
|
| 265 |
+
background-color: #111111; /* softer black background */
|
| 266 |
+
font-family: monospace; /* console-like font */
|
| 267 |
+
font-size: 14px;
|
| 268 |
+
line-height: 1.4;
|
| 269 |
+
border: none; /* clean console feel */
|
| 270 |
+
outline: none;
|
| 271 |
+
resize: none;
|
| 272 |
+
padding: 8px;
|
| 273 |
+
max-height: 200px;
|
| 274 |
+
overflow: auto;
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
#transparent_textbox input,
|
| 278 |
#transparent_textbox textarea {
|
| 279 |
color: #00FF00; /* classic terminal green */
|
|
|
|
| 340 |
|
| 341 |
with gr.Column(visible=False) as status_container:
|
| 342 |
with gr.Column(visible=False) as final_report_container:
|
| 343 |
+
gr.Markdown("# ✅Your health trends report is ready!")
|
| 344 |
+
pdf_download = gr.File(label="Click on the link below to download 📊", scale=0)
|
| 345 |
+
generate_another_btn = gr.Button(
|
| 346 |
+
"Upload more reports", variant="primary", scale=0
|
| 347 |
+
)
|
| 348 |
+
with gr.Row():
|
| 349 |
+
with gr.Column():
|
| 350 |
+
overall_progress_bar = gr.Slider(
|
| 351 |
+
interactive=False,
|
| 352 |
+
show_reset_button=False,
|
| 353 |
+
label="",
|
| 354 |
+
visible=False,
|
| 355 |
+
)
|
| 356 |
+
gr.Row() # spacer
|
| 357 |
+
logs_textbox = gr.HTML(
|
| 358 |
+
label="Logs",
|
| 359 |
+
# lines=1,
|
| 360 |
+
# max_lines=10,
|
| 361 |
+
container=True,
|
| 362 |
+
elem_id="transparent_textbox",
|
| 363 |
+
visible=False,
|
| 364 |
+
# show_copy_button=True,
|
| 365 |
+
)
|
| 366 |
+
milestone_df = gr.DataFrame(
|
| 367 |
+
value=[],
|
| 368 |
+
headers=[
|
| 369 |
+
"Step",
|
| 370 |
+
"Status",
|
| 371 |
+
"Start Time",
|
| 372 |
+
"End Time",
|
| 373 |
+
"Duration (s)",
|
| 374 |
+
],
|
| 375 |
+
datatype=["str", "str", "str", "str", "str"],
|
| 376 |
+
interactive=False,
|
| 377 |
+
visible=True,
|
| 378 |
+
)
|
| 379 |
|
| 380 |
def hide_slider_if_0_or_100(progress_value):
|
| 381 |
if progress_value == 0 or progress_value == 100:
|
graph.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import markdown2
|
|
|
|
| 2 |
from reportlab.platypus import Table, TableStyle
|
| 3 |
import asyncio
|
| 4 |
from datetime import datetime
|
|
@@ -9,7 +10,7 @@ import pandas as pd
|
|
| 9 |
from langchain_core.prompts import ChatPromptTemplate
|
| 10 |
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Image
|
| 11 |
from reportlab.lib.pagesizes import A4
|
| 12 |
-
from reportlab.lib.styles import getSampleStyleSheet
|
| 13 |
from reportlab.lib.units import inch
|
| 14 |
import matplotlib.pyplot as plt
|
| 15 |
from dataclasses import dataclass
|
|
@@ -514,6 +515,27 @@ async def fn_interpreter_node(state: SheamiState):
|
|
| 514 |
story.append(Spacer(1, 0.3 * inch))
|
| 515 |
row = []
|
| 516 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 517 |
doc.build(story,
|
| 518 |
onFirstPage=add_page_decorations,
|
| 519 |
onLaterPages=add_page_decorations)
|
|
|
|
| 1 |
import markdown2
|
| 2 |
+
from reportlab.lib import colors
|
| 3 |
from reportlab.platypus import Table, TableStyle
|
| 4 |
import asyncio
|
| 5 |
from datetime import datetime
|
|
|
|
| 10 |
from langchain_core.prompts import ChatPromptTemplate
|
| 11 |
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Image
|
| 12 |
from reportlab.lib.pagesizes import A4
|
| 13 |
+
from reportlab.lib.styles import ParagraphStyle, getSampleStyleSheet
|
| 14 |
from reportlab.lib.units import inch
|
| 15 |
import matplotlib.pyplot as plt
|
| 16 |
from dataclasses import dataclass
|
|
|
|
| 515 |
story.append(Spacer(1, 0.3 * inch))
|
| 516 |
row = []
|
| 517 |
|
| 518 |
+
disclaimer_style = ParagraphStyle(
|
| 519 |
+
"Disclaimer",
|
| 520 |
+
parent=styles["Normal"],
|
| 521 |
+
fontSize=9,
|
| 522 |
+
textColor=colors.red,
|
| 523 |
+
alignment=1, # center
|
| 524 |
+
spaceBefore=20,
|
| 525 |
+
spaceAfter=20,
|
| 526 |
+
)
|
| 527 |
+
|
| 528 |
+
disclaimer_text = """
|
| 529 |
+
<b>Disclaimer:</b> This application is intended solely for informational and educational purposes.
|
| 530 |
+
It is not a substitute for professional medical advice, diagnosis, or treatment.
|
| 531 |
+
Always seek the guidance of a qualified healthcare provider with any questions you may have
|
| 532 |
+
regarding a medical condition. Do not disregard professional advice or delay seeking it because
|
| 533 |
+
of information provided by this app.
|
| 534 |
+
"""
|
| 535 |
+
|
| 536 |
+
story.append(Spacer(1, 20))
|
| 537 |
+
story.append(Paragraph(disclaimer_text, disclaimer_style))
|
| 538 |
+
|
| 539 |
doc.build(story,
|
| 540 |
onFirstPage=add_page_decorations,
|
| 541 |
onLaterPages=add_page_decorations)
|