Upload folder using huggingface_hub
Browse files
README.md
CHANGED
|
@@ -6,6 +6,7 @@ python_version: 3.13.6
|
|
| 6 |
emoji: 🩺
|
| 7 |
colorFrom: blue
|
| 8 |
colorTo: green
|
|
|
|
| 9 |
---
|
| 10 |
|
| 11 |
# Sheami App
|
|
@@ -13,4 +14,6 @@ colorTo: green
|
|
| 13 |
Smart Healthcare Excellence through Artificial Medical Intelligence.
|
| 14 |
|
| 15 |
This Space runs on a custom **Dockerfile** because we need Poppler + Tesseract
|
| 16 |
-
for OCR. The app runs on port **7860** (Gradio default).
|
|
|
|
|
|
|
|
|
| 6 |
emoji: 🩺
|
| 7 |
colorFrom: blue
|
| 8 |
colorTo: green
|
| 9 |
+
hf_oauth: true
|
| 10 |
---
|
| 11 |
|
| 12 |
# Sheami App
|
|
|
|
| 14 |
Smart Healthcare Excellence through Artificial Medical Intelligence.
|
| 15 |
|
| 16 |
This Space runs on a custom **Dockerfile** because we need Poppler + Tesseract
|
| 17 |
+
for OCR. The app runs on port **7860** (Gradio default).
|
| 18 |
+
|
| 19 |
+
It uses HuggingFace OAuth.
|
home.py
CHANGED
|
@@ -403,60 +403,6 @@ async def get_selected_patient_details_ui(selected_patient):
|
|
| 403 |
|
| 404 |
|
| 405 |
# ----- Gradio UI (Sidebar Layout) -----
|
| 406 |
-
def get_user_from_request(request: gr.Request):
|
| 407 |
-
print("request.username = ", request.username)
|
| 408 |
-
return request.username or "Unknown"
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
async def build_securely():
|
| 412 |
-
with gr.Blocks(
|
| 413 |
-
title=get_app_title(), theme=get_app_theme(), css=get_css(), fill_height=True
|
| 414 |
-
) as ui:
|
| 415 |
-
logged_in_user = gr.State(None)
|
| 416 |
-
|
| 417 |
-
@gr.render(inputs=logged_in_user)
|
| 418 |
-
def render_if_logged_in(user):
|
| 419 |
-
if not user:
|
| 420 |
-
render_logo()
|
| 421 |
-
with gr.Row():
|
| 422 |
-
gr.Column()
|
| 423 |
-
login_btn = gr.Button(
|
| 424 |
-
"Login",
|
| 425 |
-
link="/login",
|
| 426 |
-
variant="huggingface",
|
| 427 |
-
size="lg",
|
| 428 |
-
visible=True,
|
| 429 |
-
scale=0,
|
| 430 |
-
)
|
| 431 |
-
gr.Column()
|
| 432 |
-
else:
|
| 433 |
-
if isinstance(user, str):
|
| 434 |
-
print("user = ", user)
|
| 435 |
-
try:
|
| 436 |
-
user_dict = json.loads(user)
|
| 437 |
-
user = SheamiUser(**user_dict)
|
| 438 |
-
print("user= ", user)
|
| 439 |
-
# Check if the user is registered. if not route to registration flow. add the user and then route to secure content.
|
| 440 |
-
asyncio.run(register_user(logged_in_user=user))
|
| 441 |
-
build_home_page(logged_in_user=user)
|
| 442 |
-
except json.decoder.JSONDecodeError as e:
|
| 443 |
-
gr.Markdown("User not logged-in perhaps?" + e)
|
| 444 |
-
print("User not logged-in perhaps? ", e)
|
| 445 |
-
elif isinstance(user, SheamiUser):
|
| 446 |
-
asyncio.run(register_user(logged_in_user=user))
|
| 447 |
-
build_home_page(logged_in_user=user)
|
| 448 |
-
|
| 449 |
-
ui.load(get_user_from_request, None, logged_in_user)
|
| 450 |
-
return ui
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
async def register_user(logged_in_user: SheamiUser):
|
| 454 |
-
user = await get_db().get_user_by_email(email=logged_in_user.email)
|
| 455 |
-
if not user:
|
| 456 |
-
# register the user
|
| 457 |
-
await get_db().add_user(email=logged_in_user.email, name=logged_in_user.name)
|
| 458 |
-
|
| 459 |
-
|
| 460 |
def build_home_page(logged_in_user: SheamiUser):
|
| 461 |
with gr.Column() as sheami_secure_container:
|
| 462 |
(
|
|
@@ -972,6 +918,7 @@ def build_home_page(logged_in_user: SheamiUser):
|
|
| 972 |
)
|
| 973 |
sheami_sidebar.expand(fn=hide_component, outputs=[sheami_logo_container])
|
| 974 |
sheami_sidebar.collapse(fn=show_component, outputs=[sheami_logo_container])
|
|
|
|
| 975 |
def enable_add_patient_if_logged_in(email):
|
| 976 |
if email:
|
| 977 |
return enable_component()
|
|
|
|
| 403 |
|
| 404 |
|
| 405 |
# ----- Gradio UI (Sidebar Layout) -----
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 406 |
def build_home_page(logged_in_user: SheamiUser):
|
| 407 |
with gr.Column() as sheami_secure_container:
|
| 408 |
(
|
|
|
|
| 918 |
)
|
| 919 |
sheami_sidebar.expand(fn=hide_component, outputs=[sheami_logo_container])
|
| 920 |
sheami_sidebar.collapse(fn=show_component, outputs=[sheami_logo_container])
|
| 921 |
+
|
| 922 |
def enable_add_patient_if_logged_in(email):
|
| 923 |
if email:
|
| 924 |
return enable_component()
|
ui.py
CHANGED
|
@@ -622,39 +622,42 @@ def render_top_menu_bar(logged_in_user: SheamiUser = None):
|
|
| 622 |
)
|
| 623 |
gr.Column() # spacer
|
| 624 |
with gr.Row(scale=2):
|
| 625 |
-
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
show_download_button=False,
|
| 630 |
-
show_fullscreen_button=False,
|
| 631 |
-
show_share_button=False,
|
| 632 |
-
height=30,
|
| 633 |
-
visible=False,
|
| 634 |
-
)
|
| 635 |
-
with gr.Column(
|
| 636 |
-
scale=4,
|
| 637 |
-
):
|
| 638 |
-
gr.Markdown(value=logged_in_user.name,elem_classes="text-center")
|
| 639 |
-
email_in = gr.Text(
|
| 640 |
-
label="👤 You are logged in as",
|
| 641 |
-
placeholder="doctor1@sheami.com",
|
| 642 |
-
value=logged_in_user.email,
|
| 643 |
-
interactive=False,
|
| 644 |
-
elem_id="logged_in_user",
|
| 645 |
-
text_align="left",
|
| 646 |
-
show_label=False,
|
| 647 |
container=False,
|
| 648 |
-
|
| 649 |
-
|
| 650 |
-
|
| 651 |
-
|
| 652 |
-
|
| 653 |
-
link="/logout",
|
| 654 |
-
variant="huggingface",
|
| 655 |
-
size="sm",
|
| 656 |
-
visible=True,
|
| 657 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 658 |
return (
|
| 659 |
sheami_logo_container,
|
| 660 |
email_in,
|
|
|
|
| 622 |
)
|
| 623 |
gr.Column() # spacer
|
| 624 |
with gr.Row(scale=2):
|
| 625 |
+
if(logged_in_user):
|
| 626 |
+
gr.Image(
|
| 627 |
+
value=logged_in_user.picture_url,
|
| 628 |
+
scale=0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 629 |
container=False,
|
| 630 |
+
show_download_button=False,
|
| 631 |
+
show_fullscreen_button=False,
|
| 632 |
+
show_share_button=False,
|
| 633 |
+
height=30,
|
| 634 |
+
visible=False,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 635 |
)
|
| 636 |
+
with gr.Column(
|
| 637 |
+
scale=4,
|
| 638 |
+
):
|
| 639 |
+
gr.Markdown(value=logged_in_user.name,elem_classes="text-center", visible=False)
|
| 640 |
+
email_in = gr.Text(
|
| 641 |
+
label="👤 You are logged in as",
|
| 642 |
+
placeholder="doctor1@sheami.com",
|
| 643 |
+
value=logged_in_user.email,
|
| 644 |
+
interactive=False,
|
| 645 |
+
elem_id="logged_in_user",
|
| 646 |
+
text_align="left",
|
| 647 |
+
show_label=False,
|
| 648 |
+
container=False,
|
| 649 |
+
elem_classes="text-center",
|
| 650 |
+
visible=False
|
| 651 |
+
)
|
| 652 |
+
# gr.Button(
|
| 653 |
+
# "Logout",
|
| 654 |
+
# link="/logout",
|
| 655 |
+
# variant="huggingface",
|
| 656 |
+
# size="sm",
|
| 657 |
+
# visible=True,
|
| 658 |
+
# )
|
| 659 |
+
else:
|
| 660 |
+
email_in = gr.Text()
|
| 661 |
return (
|
| 662 |
sheami_logo_container,
|
| 663 |
email_in,
|