Krishwall commited on
Commit
9bf18c6
·
1 Parent(s): 8ef5ac5

Deploy Multimodal Clinical AI app

Browse files
app.py CHANGED
@@ -3,18 +3,42 @@ Hugging Face Spaces Deployment App
3
  Multimodal Clinical AI - Chest X-ray Analysis
4
  """
5
  import os
 
6
  import torch
7
  import torch.nn.functional as F
8
  from PIL import Image
9
  import streamlit as st
10
- from demo.utils.load_model import load_fusion_model
11
- from demo.utils.grad_cam import GradCAM, overlay_cam
12
- from demo.utils.saliency import (
13
- compute_text_saliency,
14
- merge_wordpieces,
15
- filter_tokens,
16
- highlight_text,
17
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  # --------------------------------------------------
20
  # Page configuration
 
3
  Multimodal Clinical AI - Chest X-ray Analysis
4
  """
5
  import os
6
+ import sys
7
  import torch
8
  import torch.nn.functional as F
9
  from PIL import Image
10
  import streamlit as st
11
+
12
+ # Add current directory to path for imports
13
+ sys.path.insert(0, os.path.dirname(__file__))
14
+
15
+ # Try importing from demo.utils, with fallback handling
16
+ try:
17
+ from demo.utils.load_model import load_fusion_model
18
+ from demo.utils.grad_cam import GradCAM, overlay_cam
19
+ from demo.utils.saliency import (
20
+ compute_text_saliency,
21
+ merge_wordpieces,
22
+ filter_tokens,
23
+ highlight_text,
24
+ )
25
+ except ImportError as e:
26
+ # If demo folder structure doesn't exist, show helpful error
27
+ import traceback
28
+ st.error(f"❌ Import error: {e}")
29
+ st.info("💡 Please ensure the following files are in your Space:")
30
+ st.code("""
31
+ demo/
32
+ __init__.py
33
+ utils/
34
+ __init__.py
35
+ load_model.py
36
+ grad_cam.py
37
+ saliency.py
38
+ """)
39
+ with st.expander("🔍 Full error details"):
40
+ st.code(traceback.format_exc())
41
+ st.stop()
42
 
43
  # --------------------------------------------------
44
  # Page configuration
checkpoints/fusion_model/fusion_layer4_tuned.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:89dcb3f9e5fba4eb0746851c2e2326c6368c9aabc231b60b12b2b639bfe97cd7
3
+ size 480755648
demo/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ # Demo package
demo/utils/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ # Demo utils package
demo/utils/saliency.py CHANGED
@@ -56,6 +56,7 @@ def merge_wordpieces(tokens, scores):
56
  merged_scores.append(current_score)
57
 
58
  return merged_tokens, merged_scores
 
59
  def filter_tokens(tokens, scores, attention_mask):
60
  clean_tokens = []
61
  clean_scores = []
 
56
  merged_scores.append(current_score)
57
 
58
  return merged_tokens, merged_scores
59
+
60
  def filter_tokens(tokens, scores, attention_mask):
61
  clean_tokens = []
62
  clean_scores = []