Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,15 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import torch
|
| 3 |
import numpy as np
|
| 4 |
-
from transformers import AutoModelForCausalLM
|
| 5 |
from janus.models import VLChatProcessor
|
| 6 |
from PIL import Image
|
| 7 |
import spaces
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
# Medical Imaging Analysis Configuration
|
| 10 |
MEDICAL_CONFIG = {
|
| 11 |
"echo_guidelines": "ASE 2023 Standards",
|
|
@@ -38,6 +42,9 @@ if torch.cuda.is_available():
|
|
| 38 |
|
| 39 |
vl_chat_processor = VLChatProcessor.from_pretrained(model_path)
|
| 40 |
|
|
|
|
|
|
|
|
|
|
| 41 |
# Medical Image Processing Pipelines
|
| 42 |
def preprocess_echo(image):
|
| 43 |
"""Process echocardiography images"""
|
|
@@ -147,11 +154,11 @@ with gr.Blocks(title="Cardiac & Histopathology AI", theme=gr.themes.Soft()) as d
|
|
| 147 |
label="Example Medical Cases"
|
| 148 |
)
|
| 149 |
|
| 150 |
-
@demo.func
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
|
| 157 |
demo.launch(share=True)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import torch
|
| 3 |
import numpy as np
|
| 4 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 5 |
from janus.models import VLChatProcessor
|
| 6 |
from PIL import Image
|
| 7 |
import spaces
|
| 8 |
|
| 9 |
+
# Suppress specific warnings
|
| 10 |
+
import warnings
|
| 11 |
+
warnings.filterwarnings("ignore", category=FutureWarning)
|
| 12 |
+
|
| 13 |
# Medical Imaging Analysis Configuration
|
| 14 |
MEDICAL_CONFIG = {
|
| 15 |
"echo_guidelines": "ASE 2023 Standards",
|
|
|
|
| 42 |
|
| 43 |
vl_chat_processor = VLChatProcessor.from_pretrained(model_path)
|
| 44 |
|
| 45 |
+
# **Fix: Set legacy=False in tokenizer to use the new behavior**
|
| 46 |
+
vl_chat_processor.tokenizer = AutoTokenizer.from_pretrained(model_path, legacy=False)
|
| 47 |
+
|
| 48 |
# Medical Image Processing Pipelines
|
| 49 |
def preprocess_echo(image):
|
| 50 |
"""Process echocardiography images"""
|
|
|
|
| 154 |
label="Example Medical Cases"
|
| 155 |
)
|
| 156 |
|
| 157 |
+
# **Fixed: Removed @demo.func and used .click() correctly**
|
| 158 |
+
analyze_btn.click(
|
| 159 |
+
analyze_medical_case,
|
| 160 |
+
[image_input, clinical_input, modality_select],
|
| 161 |
+
report_output
|
| 162 |
+
)
|
| 163 |
|
| 164 |
demo.launch(share=True)
|