Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix model cards from re-appearing in front scene tab #29

Merged
merged 3 commits into from
Oct 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions monai_vila2d/demo/gradio_monai_vila2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
["Segment the visceral structures in the current image."],
["Can you identify any liver masses or tumors?"],
["Segment the entire image."],
["Describe the image in detail"],
]

EXAMPLE_PROMPTS_2D = [
Expand All @@ -90,6 +91,7 @@
["Is there evidence of cardiomegaly in this image?"],
["Is the atelectasis located on the left side or right side?"],
["What level is the cardiomegaly?"],
["Describe the image in detail"],
]

HTML_PLACEHOLDER = "<br>".join([""] * 15)
Expand Down Expand Up @@ -275,6 +277,7 @@ def __init__(self):
self.temp_working_dir = None
self.idx_range = (None, None)
self.interactive = False
self.sys_msgs_to_hide = []


def new_session_variables(**kwargs):
Expand Down Expand Up @@ -422,14 +425,14 @@ def process_prompt(self, prompt, sv, chat_history):
mod_msg = f"This is a {modality} image.\n" if modality != "Unknown" else ""

img_file = CACHED_IMAGES.get(sv.image_url, None)
sys_msgs_to_hide = []

if isinstance(img_file, str):
if "<image>" not in prompt:
_prompt = sv.sys_msg + "<image>" + mod_msg + prompt
sys_msgs_to_hide.append(sv.sys_msg + "<image>" + mod_msg)
sv.sys_msgs_to_hide.append(sv.sys_msg + "<image>" + mod_msg)
else:
_prompt = sv.sys_msg + mod_msg + prompt
sys_msgs_to_hide.append(sv.sys_msg + mod_msg)
sv.sys_msgs_to_hide.append(sv.sys_msg + mod_msg)

if img_file.endswith(".nii.gz"): # Take the specific slice from a volume
chat_history.append(
Expand Down Expand Up @@ -502,12 +505,13 @@ def process_prompt(self, prompt, sv, chat_history):
download_file_path=download_pkg,
temp_working_dir=sv.temp_working_dir,
interactive=True,
sys_msgs_to_hide=sv.sys_msgs_to_hide,
)
return (
None,
new_sv,
chat_history,
chat_history.get_html(show_all=False, sys_msgs_to_hide=sys_msgs_to_hide),
chat_history.get_html(show_all=False, sys_msgs_to_hide=sv.sys_msgs_to_hide),
chat_history.get_html(show_all=True),
)

Expand Down
Loading