Views
No views yet
environment.yml:1conda env create -f environment.yml
2conda activate medversaenvironment.yml has been validated on NVIDIA A100 GPUs. If you have more advanced cards, e.g., NVIDIA H100 GPUs, you may need environment_h100.yml which supports CUDA 11.8:1conda env create -f environment_cu118.yml
2conda activate medversapip install opencv-contrib-pythonincompatible torchvision version, try the following:pip install torchvision==0.15.2+cu118 --index-url https://download.pytorch.org/whl/cu1181from utils import *
2from torch import cuda
3
4# --- Launch Model ---
5device = 'cuda' if cuda.is_available() else 'cpu'
6model_cls = registry.get_model_class('medomni') # medomni is the architecture name :)
7model = model_cls.from_pretrained('hyzhou/MedVersa_Internal').to(device).eval()
8
9# --- Define examples ---
10examples = [
11 [
12 ["./demo_ex/c536f749-2326f755-6a65f28f-469affd2-26392ce9.png"],
13 "Age:30-40.\nGender:F.\nIndication: ___-year-old female with end-stage renal disease not on dialysis presents with dyspnea. PICC line placement.\nComparison: None.",
14 "How would you characterize the findings from <img0>?",
15 "cxr",
16 "report generation",
17 ],
18]
19# --- Define hyperparams ---
20num_beams = 1
21do_sample = True
22min_length = 1
23top_p = 0.9
24repetition_penalty = 1
25length_penalty = 1
26temperature = 0.1
27
28# --- Generate a report for a chest X-ray image ---
29index = 0
30demo_ex = examples[index]
31images, context, prompt, modality, task = demo_ex[0], demo_ex[1], demo_ex[2], demo_ex[3], demo_ex[4]
32seg_mask_2d, seg_mask_3d, output_text = generate_predictions(model, images, context, prompt, modality, task, num_beams, do_sample, min_length, top_p, repetition_penalty, length_penalty, temperature)
33print(output_text)inference.py.CUDA_VISIBLE_DEVICES=0 python demo.py --cfg-path medversa.yamlmedomni/datasets/prompts.json.