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

(WIP) Improve gradio demo visualization #24

Merged
merged 16 commits into from
Oct 21, 2024
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
demo_monai_vila2d:
cd thirdparty/VILA; \
./environment_setup.sh
pip install -U nibabel python-dotenv deepspeed gradio monai[nibabel,pynrrd,skimage]
pip install -U python-dotenv deepspeed gradio monai[nibabel,pynrrd,skimage]
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ For details, see [here](./monai_vila2d/README.md).
```bash
git clone https://github.com/Project-MONAI/VLM --recursive
cd VLM
python -m venv .venv
python3.10 -m venv .venv
source .venv/bin/activate
make demo_monai_vila2d
```
Expand All @@ -70,9 +70,10 @@ For details, see [here](./monai_vila2d/README.md).

1. Start the Gradio demo:
```bash
python demo/gradio_monai_vila2d.py \
--modelpath /data/checkpoints/<checkpoint-name> \
--convmode <llama_3 or vicuna_1> \
cd monai_vila2d/demo
python gradio_monai_vila2d.py \
--modelpath /data/checkpoints/<8B-checkpoint-name> \
--convmode llama_3 \
--port 7860
```

Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 3 additions & 5 deletions demo/experts/utils.py → monai_vila2d/demo/experts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
import re
from io import BytesIO
from pathlib import Path
from typing import List
from urllib.parse import urlparse

import numpy as np
import requests
Expand Down Expand Up @@ -144,11 +142,11 @@ def get_filename_from_cd(url, cd):
return fname[0].strip('"').strip("'")


def get_slice_filenames(image_file, slice_index):
def get_slice_filenames(image_file: str, slice_index: int, ext: str = "jpg"):
"""Small helper function to get the slice filenames"""
base_name = os.path.basename(image_file)
image_filename = base_name.replace(".nii.gz", f"_slice{slice_index}.jpg")
seg_filename = base_name.replace(".nii.gz", f"_slice{slice_index}_seg.jpg")
image_filename = base_name.replace(".nii.gz", f"_slice{slice_index}_img.{ext}")
seg_filename = base_name.replace(".nii.gz", f"_slice{slice_index}_seg.{ext}")
return image_filename, seg_filename


Expand Down
199 changes: 100 additions & 99 deletions demo/gradio_monai_vila2d.py → monai_vila2d/demo/gradio_monai_vila2d.py

Large diffs are not rendered by default.

Loading