Clara AI
The Clara AI (pre-alpha version) currently provides a sample AI application server using TRTIS.
The AI Service provides multi-organ segmentation on abdominal CT with dense v-networks and supports RESTful APIs to allow customization of abdominal CT image processing.
Before running the container, use docker pull to ensure an up-to-date image is installed. Once the pull is complete, you can run the container image.
Procedure
Container images for Clara AI are available at NGC Registry.
In the
Tags
section, locate the container image release that you want to run.In the
PULL TAG
column in the table, click the icon to copy thedocker pull
command.Open a command prompt and paste the pull command. The pulling of the container image begins. Ensure the pull completes successfully before proceeding to the next step.
Create
input
andoutput
folders that will be mounted to the container in the next steps.mkdir -p input output
Create network for AI.
docker network create claranet
Download vnet model files (to
models/v_net
folder) from the data container.mkdir -p models docker run -it --rm -u $UID:$UID -v $(pwd):/data --entrypoint "" nvcr.io/nvidian/nvidia-clara-ai:0.1.2 bash -c 'rsync -a --info=progress2 /models /data'
Download a sample test input (
input/test
folder).# Download 'input/test' folder from the internet. mkdir -p input/test wget -q https://www.dropbox.com/s/5fk0m9v12if5da9/dense_vnet_abdominal_ct_model_zoo_data.tar.gz?dl=1 -O - | tar xvz -C input/test rm input/test/100_Label.nii # Remove unnecessary label image.
Run TRTIS server with v-net model.
nvidia-docker run -it --rm -d \ --shm-size=1g \ --ulimit memlock=-1 \ --ulimit stack=67108864 \ --name trtis \ --network claranet \ -p 8000:8000 \ -v `pwd`/models/v_net:/models/v_net \ nvcr.io/nvidia/tensorrtserver:18.11-py3 \ trtserver --model-store=/models Note that above command assumes that model files for dense v-network are located in ``models/v_net`` folder.
Run the AI server within the container. Open a command prompt and issue:
nvidia-docker run -it --rm -d \ --name ai \ --network claranet \ -p 5002:5002 \ -e CIM_APP_FOLDER_NAME=custom_application_vnet \ -e CIM_APP_SKIP_INSTALL=true \ -v $(pwd)/input:/ai/in \ -v $(pwd)/output:/ai/out \ nvcr.io/nvidian/nvidia-clara-ai:<x.x.x> \ serve --input_folder=/ --output_folder=/ \ --trtis_url=trtis:8000 --port=5002
Where:
-it means keeping STDIN open even if not attached, and allocating a pseudo-TTY
–rm will delete the container when finished
-d is for Detached mode: Run containers in the background
–name is for assigning a name to the container
–network is for connecting a container to a network
-p is for publishing container’s port to host (here, we use
5002
)-e is for providing environment variable
-v is for mounting host folder to container folder
<x.x.x>
is the container version. For example,0.1.2
.–trtis_url is for setting URL of TRTIS (it assumes
localhost:8000
for TRTIS url)–port indicates port number for server access (should be same port number used in
-p
option)
Submit requests with a sample test input (Run a workflow No.5 which is AI module-only workflow).
``input/test`` folder
# .nii file is interpreted as image with LPS axis code so transpose it to ARS to match with vnet model curl -H "Content-Type: application/json" \ -d '{"name":"test","workflow":5,"pre_axcodes":"ARS"}' \ http://localhost:5002/ai
After several seconds,
100_CT.seg.mhd
and100_CT.seg.raw
files would be available with original input files atoutput/test
folder. Please executedocker logs ai
to see AI log messages.Stop containers and remove network.
If you want to stop the AI and TRTIS containers and remove the network, execute the following commands:
docker stop ai trtis docker network rm claranet
GET /ai (Return Code: 200)
Return a list of AI tasks. Each entry will include source, destination, and status. If status is ‘completed’, then a return code will also be included.
POST /ai (Return Code: 201)
Create a new AI task. Returns a JSON result containing the recon-id for the newly added task.
Parameters:
workflow: workflow ID
name: name for the job
roi: (optional) a comma separated list of coordinates for Region Of Interest (ROI), e.g. “x1,x2,y1,y2,z1,z2”
pre_axcodes: (optional) 3-character axis codes (e.g., LPS or RAS) for transposing 3d matrix after loading the image. Default value is ‘PRS’. For more information: Coordinate Systems
post_axcodes: (optional) 3-character axis codes (e.g., LPS or RAS) for transposing 3d matrix before writing output. Default value is original axis codes from the input image. For more information: Coordinate Systems
Note that workflow option should be 5
(AI workflow) to run the AI app server as a standalone.
Example 1)
JSON object:
{
"name": "test",
"workflow": 5,
"roi": "88,440,53,465,61,142"
}
Command:
curl -H "Content-Type: application/json" \
-d '{"name":"test","workflow":5,"roi":"88,440,53,465,61,142"}' \
http://localhost:5002/ai
Note that parameters for roi
, pre_axcodes
, and post_axcodes
are optional, and it assumes input files (XX.mhd
and XX.raw
, or XX.nii
/XX.nii.gz
file) are available at /ai/in/test
folder which is input/test
folder in host system.
For the latest Release Notes, see XXX (TBD).
For more information about Clara AI, see:
TBD