nvidia/vista-3d

RUN ANYWHERE

VISTA-3D is a specialized interactive foundation model for segmenting and anotating human anatomies.

By running the below commands, you accept the NVIDIA AI Enterprise Terms of Use and the NVIDIA Community Models License.

Pull and run nvidia/vista-3d using Docker (this will download the full model and run it in your local environment)

$ docker login nvcr.io Username: $oauthtoken Password: <PASTE_API_KEY_HERE>

Start NIM

  1. Export NGC_API_KEY variable.
export NGC_API_KEY=<your personal NGC key>
  1. The NIM container automatically downloads any required models. To save time and bandwidth it is recommended to provide a local cache directory. This way the NIM will be able to reuse any already downloaded models. Execute the following command to setup the cache directory:
export LOCAL_NIM_CACHE=~/.cache/nim mkdir -p $LOCAL_NIM_CACHE

Note that you may need to run (sudo) chmod -R 777 $LOCAL_NIM_CACHE after the VISTA-3D model is downloaded to avoid permission issues.

  1. Run the NIM container with the following commands:
docker run --rm -it --name vista3d \ --runtime=nvidia -e CUDA_VISIBLE_DEVICES=0 \ --shm-size=8G \ -p 8000:8000 \ -e NGC_API_KEY=$NGC_API_KEY \ nvcr.io/nim/nvidia/vista3d:latest

This command will start the NIM container and expose port 8000 for the user to interact with the NIM.

  1. Open a new terminal, leaving the terminal open with the just launched service. In the new terminal, wait until the health check end point returns {"status":"ready"} before proceeding. This may take a couple of minutes. You can use the following command to query the health check.
curl -X 'GET' \ 'http://localhost:8000/v1/health/ready' \ -H 'accept: application/json'

Python Client Example: Segment Everything

  1. Save following Python example to a file named nim_client.py.
import requests import zipfile base_url = "http://localhost:8000" data = { "image": "https://assets.ngc.nvidia.com/products/api-catalog/vista3d/example-1.nii.gz", } def unzip_file(zip_filepath, dest_dir): with zipfile.ZipFile(zip_filepath, 'r') as zip_ref: zip_ref.extractall(dest_dir) response = requests.post(f"{base_url}/v1/vista3d/inference", json=data) if response.status_code == 200: output_folder = "output" output_zip_name = "output.zip" with open(output_zip_name, "wb") as f: f.write(response.content) unzip_file(output_zip_name, output_folder)
  1. Execute the example.
python nim_client.py
  1. The resulting segmentation file will be returned and written to output.zip.
cat output.zip

Shell Client Example

  1. Save the following Shell example to a file named nim_client.sh.
LOCAL_URL='http://localhost:8000/v1/vista3d/inference' DATA=$(cat <<EOF { "image": "https://assets.ngc.nvidia.com/products/api-catalog/vista3d/example-1.nii.gz" } EOF ) response=$(curl -s -o output.zip -w "%{http_code}" -X POST -H "Content-Type: application/json" -d "$DATA" $LOCAL_URL) if [ "$response" -eq 200 ]; then echo "Response Success, save inference results into folder: output" unzip -o "output.zip" -d "output" else echo "Request failed with status $response" fi
  1. Execute the example.
chmod +x nim_client.sh ./nim_client.sh
  1. Results will be returned in ZIP format. You will be able to see the label formatted output; you can also use curl to save the output directly to file.