Spaces:
Sleeping
Sleeping
kgupta21
commited on
Commit
·
3dd738a
1
Parent(s):
41cd3de
local inference page with fixes
Browse files
app.py
CHANGED
@@ -20,7 +20,10 @@ logger = logging.getLogger(__name__)
|
|
20 |
APP_VERSION = "1.0.0"
|
21 |
logger.info(f"Starting Radiology Teaching App v{APP_VERSION}")
|
22 |
|
23 |
-
#
|
|
|
|
|
|
|
24 |
device = 0 if torch.cuda.is_available() else "cpu"
|
25 |
logger.info(f"Using device: {device}")
|
26 |
|
@@ -130,6 +133,8 @@ def analyze_with_llama(
|
|
130 |
temperature: float = 0.6,
|
131 |
) -> Iterator[str]:
|
132 |
"""Analyze transcribed report against ground truth using Llama"""
|
|
|
|
|
133 |
if llm is None or tokenizer is None:
|
134 |
raise gr.Error("Llama model not initialized properly!")
|
135 |
|
@@ -280,11 +285,12 @@ with gr.Blocks() as demo:
|
|
280 |
)
|
281 |
|
282 |
# Load case for local analysis
|
|
|
283 |
load_case_btn.click(
|
284 |
fn=load_random_case,
|
285 |
inputs=[gr.Checkbox(value=False, visible=False)], # Hidden checkbox for hide_ground_truth
|
286 |
outputs=[
|
287 |
-
|
288 |
local_ground_truth_findings,
|
289 |
local_ground_truth_impression,
|
290 |
gr.State(), # Hidden state
|
|
|
20 |
APP_VERSION = "1.0.0"
|
21 |
logger.info(f"Starting Radiology Teaching App v{APP_VERSION}")
|
22 |
|
23 |
+
# Global variables
|
24 |
+
pipe = None
|
25 |
+
llm = None
|
26 |
+
tokenizer = None
|
27 |
device = 0 if torch.cuda.is_available() else "cpu"
|
28 |
logger.info(f"Using device: {device}")
|
29 |
|
|
|
133 |
temperature: float = 0.6,
|
134 |
) -> Iterator[str]:
|
135 |
"""Analyze transcribed report against ground truth using Llama"""
|
136 |
+
global llm, tokenizer # Add global declaration
|
137 |
+
|
138 |
if llm is None or tokenizer is None:
|
139 |
raise gr.Error("Llama model not initialized properly!")
|
140 |
|
|
|
285 |
)
|
286 |
|
287 |
# Load case for local analysis
|
288 |
+
local_image_display = gr.Image(label="Chest X-ray Image", type="pil") # Add this line
|
289 |
load_case_btn.click(
|
290 |
fn=load_random_case,
|
291 |
inputs=[gr.Checkbox(value=False, visible=False)], # Hidden checkbox for hide_ground_truth
|
292 |
outputs=[
|
293 |
+
local_image_display, # Update this line
|
294 |
local_ground_truth_findings,
|
295 |
local_ground_truth_impression,
|
296 |
gr.State(), # Hidden state
|