SEGMENTATION Not Allowed

I would like to test the segmentation from this msegmentation model : clara_mri_seg_brain_tumors_br16_t1c2tc_amp.

I use one nifty and I try to use this command:

curl -X POST "http://0.0.0.0:5000/v1/segmentation?model=segmentation_brain&output=image"  -H "accept: multipart/form-data"  -H "Content-Type: multipart/form-data"   -F "params={}" \ -F "image=@5e36bdf685b7930de4555ea219a7f2509c2801f2b77146e9aa544d96.nii.gz;type=application/x-gzip" \ -o aaaaaaaaaaaaa.nii.gz

I have this errors:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>
curl: (3) Host name ' -F' contains bad letter
curl: (6) Could not resolve host: 5e36bdf685b7930de4555ea219a7f2509c2801f2b77146e9aa544d96.nii.gz;type=application
curl: (3) Host name ' -o' contains bad letter
curl: (6) Could not resolve host: aaaaaaaaaaaaa.nii.gz

this is the log

[2020-01-08 13:24:54.938][ INFO](werkzeug:_log) - 127.0.0.1 - - [08/Jan/2020 13:24:54] "e[1me[35mPOST /v1/segmentation?model=segmentation_brain&output=image HTTP/1.1e[0m" 500 -
[2020-01-08 13:25:37.639][ INFO](werkzeug:_log) - 127.0.0.1 - - [08/Jan/2020 13:25:37] "e[37mGET / HTTP/1.1e[0m" 200 -
[2020-01-08 13:25:42.150][ INFO](werkzeug:_log) - 127.0.0.1 - - [08/Jan/2020 13:25:42] "e[37mGET /logs HTTP/1.1e[0m" 200 -
[2020-01-08 13:26:28.181][ INFO](werkzeug:_log) - 127.0.0.1 - - [08/Jan/2020 13:26:28] "e[37mGET /logs?lines=-1 HTTP/1.1e[0m" 200 -
[2020-01-08 13:27:32.081][ INFO](schedule:run) - Running job Every 5 minutes do cleanup_docs() (last run: 2020-01-08 13:22:32, next run: 2020-01-08 13:27:32)
[2020-01-08 13:32:32.084][ INFO](schedule:run) - Running job Every 5 minutes do cleanup_docs() (last run: 2020-01-08 13:27:32, next run: 2020-01-08 13:32:32)
[2020-01-08 13:35:27.497][ INFO](nvmidl.apps.aas.server:api_v1_segmentation) - Running Segmentation for: segmentation_brain
[2020-01-08 13:35:27.498][ERROR](nvmidl.apps.aas.server:run_inference) - SEGMENTATION Not Allowed
[2020-01-08 13:35:27.499][ERROR](AIAAServer:log_exception) - Exception on /v1/segmentation [POST]
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1951, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.6/dist-packages/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1820, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.6/dist-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python3.6/dist-packages/flask_monitoringdashboard/core/measurement.py", line 61, in wrapper
    result = fun(*args, **kwargs)
  File "apps/aas/server.py", line 301, in api_v1_segmentation
TypeError: 'Response' object is not iterable

I guess you have uploaded annotation model as “segmentation_brain”…
the best way to check if model type is segmentation for “segmentation_brain” by querying /v1/models and go through the details…

Yes of course:

[{"name": "segmentation_brain", "internal name": "segmentation_brain", "labels": ["brain tumor core"], "description": "A pre-trained model for volumetric (3D) annotation of brain tumors from T1c MRIs", "roi": [128, 128, 128], "sigma": 3, "padding": 20.0, "version": "2", "type": "annotation"}]

“name”: “segmentation_brain”
“description”: “A pre-trained model for volumetric (3D) annotation of brain tumors from T1c MRIs”
“type”: “annotation”

As I guessed, you are using an annotation model in /v1/segmentation API…

FYI::
There are 2 types of models in NGC (which are trained accordingly)

  1. segmentation (/v1/segmentation) - user will provide full image as input and get the label mask for an organ
  2. annotation (/v1/dextr3d) - Nvidia specific annotation API (faster) - where user will provide min 6 extreme points + cropped image as input to get the label mask

so I hope you understood

  1. what went wrong in your request (picking annotation model for /v1/segmentation api or vice-versa not correct)
  2. pick appropriate name while importing a model for annotation model vs segmentation model (better readability)

Could you please suggest me how to upload the segmentation model. I follow the command describe in the tutorial page.
Thanks so much

https://ngc.nvidia.com/catalog/models/nvidia:med:clara_ct_seg_spleen_amp

curl -X PUT “http://127.0.0.1:5000/admin/model/clara_ct_seg_spleen_amp
-H “accept: application/json”
-H “Content-Type: application/json”
-d ‘{“path”:“nvidia/med/clara_ct_seg_spleen_amp”,“version”:“1”}’

This is for spleen… (If AIAA is running on port 5000)

[2020-01-16 15:24:44.087][ INFO](nvmidl.apps.aas.server:admin_model_load) - Model: clara_ct_seg_spleen_amp
[2020-01-16 15:24:44.088][ INFO](nvmidl.apps.aas.server:check_for_access) - Request Host: 127.0.0.1:5000
[2020-01-16 15:24:44.088][ INFO](nvmidl.apps.aas.server:check_for_access) - Remote  Addr: 127.0.0.1
[2020-01-16 15:24:44.088][ INFO](nvmidl.apps.aas.actions.model_import:model_import_ngc) - Model: clara_ct_seg_spleen_amp; Path: nvidia/med/clara_ct_seg_spleen_amp; Version: 1
[2020-01-16 15:24:44.088][ INFO](nvmidl.apps.aas.actions.model_import:_ngc_download) - Trying to download model from NGC...
[2020-01-16 15:24:44.088][ INFO](nvmidl.apps.aas.actions.model_import:_ngc_download) - Running command: 
ngc registry model download-version nvidia/med/clara_ct_seg_spleen_amp:1 --dest /workspace/data/Evamidaizebedei//downloads/host-5000/clara_ct_seg_spleen_amp
[2020-01-16 15:24:44.094][ INFO](GenericUtils:run_command) - Running Command: ngc registry model download-version nvidia/med/clara_ct_seg_spleen_amp:1 --dest /workspace/data/Evamidaizebedei//downloads/host-5000/clara_ct_seg_spleen_amp
[2020-01-16 15:24:47.873][ INFO](GenericUtils:run_command) - NGC:: 
[2020-01-16 15:28:33.594][ INFO](schedule:run) - Running job Every 5 minutes do cleanup_docs() (last run: 2020-01-16 15:23:33, next run: 2020-01-16 15:28:33)
[2020-01-16 15:33:33.596][ INFO](schedule:run) - Running job Every 5 minutes do cleanup_docs() (last run: 2020-01-16 15:28:33, next run: 2020-01-16 15:33:33)
[2020-01-16 15:38:33.599][ INFO](schedule:run) - Running job Every 5 minutes do cleanup_docs() (last run: 2020-01-16 15:33:33, next run: 2020-01-16 15:38:33)
[2020-01-16 15:43:33.602][ INFO](schedule:run) - Running job Every 5 minutes do cleanup_docs() (last run: 2020-01-16 15:38:33, next run: 2020-01-16 15:43:33)
[2020-01-16 15:48:33.605][ INFO](schedule:run) - Running job Every 5 minutes do cleanup_docs() (last run: 2020-01-16 15:43:33, next run: 2020-01-16 15:48:33)
[2020-01-16 15:53:24.494][ INFO](nvmidl.apps.aas.server:admin_model_load) - Model: clara_ct_seg_spleen_amp
[2020-01-16 15:53:24.495][ INFO](nvmidl.apps.aas.server:check_for_access) - Request Host: 127.0.0.1:5000
[2020-01-16 15:53:24.495][ INFO](nvmidl.apps.aas.server:check_for_access) - Remote  Addr: 127.0.0.1
[2020-01-16 15:53:24.495][ INFO](werkzeug:_log) - 127.0.0.1 - - [16/Jan/2020 15:53:24] "e[1me[31mPUT /admin/model/clara_ct_seg_spleen_amp HTTP/1.1e[0m" 400 -
[2020-01-16 15:53:33.608][ INFO](schedule:run) - Running job Every 5 minutes do cleanup_docs() (last run: 2020-01-16 15:48:33, next run: 2020-01-16 15:53:33)
[2020-01-16 15:55:02.295][ INFO](nvmidl.apps.aas.server:admin_model_load) - Model: clara_ct_seg_spleen_amp
[2020-01-16 15:55:02.295][ INFO](nvmidl.apps.aas.server:check_for_access) - Request Host: 127.0.0.1:5000
[2020-01-16 15:55:02.295][ INFO](nvmidl.apps.aas.server:check_for_access) - Remote  Addr: 127.0.0.1
[2020-01-16 15:55:02.295][ INFO](werkzeug:_log) - 127.0.0.1 - - [16/Jan/2020 15:55:02] "e[1me[31mPUT /admin/model/clara_ct_seg_spleen_amp HTTP/1.1e[0m" 400 -
[2020-01-16 15:55:54.028][ INFO](werkzeug:_log) - 127.0.0.1 - - [16/Jan/2020 15:55:54] "e[37mGET /logs?lines=-1 HTTP/1.1e[0m" 200 -
[2020-01-16 15:55:54.074][ INFO](werkzeug:_log) - 127.0.0.1 - - [16/Jan/2020 15:55:54] "e[37mGET /favicon.ico HTTP/1.1e[0m" 200 -
[2020-01-16 15:56:31.530][ INFO](nvmidl.apps.aas.server:admin_model_load) - Model: clara_ct_seg_spleen_amp
[2020-01-16 15:56:31.531][ INFO](nvmidl.apps.aas.server:check_for_access) - Request Host: 0.0.0.0:5000
[2020-01-16 15:56:31.531][ INFO](nvmidl.apps.aas.server:check_for_access) - Remote  Addr: 127.0.0.1
[2020-01-16 15:56:31.533][ INFO](werkzeug:_log) - 127.0.0.1 - - [16/Jan/2020 15:56:31] "e[1me[31mPUT /admin/model/clara_ct_seg_spleen_amp HTTP/1.1e[0m" 400 -

Is your docker running on some private n/w and can’t access to ngc?

You can try to run (inside docker):
ngc registry model download-version nvidia/med/clara_ct_seg_spleen_amp:1 --dest /tmp

because you should see something like follows:

=====================================
Running Command: ngc registry model download-version nvidia/med/clara_ct_seg_spleen_amp:1 --dest /workspace/Data/AIAATest/downloads/host-80/test_spleen_amp

NGC::
NGC:: Downloaded 2.04 MB in 1s, Download speed: 2.04 MB/s
NGC:: Downloaded 14.57 MB in 2s, Download speed: 7.29 MB/s

how you loaded a model previously… I am just asking you to use a different model “clara_ct_seg_spleen_amp” instead…

I’m able to download the model using ngc.

The previous model was able to upload using this commands:

ngc registry model download-version nvidia/med/clara_mri_annotation_brain_tumors_t1ce_tc_no_amp:1 --dest /var/tmp
cd /var/tmp/clara_mri_annotation_brain_tumors_t1ce_tc_no_amp/

curl -X PUT "http://127.0.0.1:5000/admin/model/segmentation_brain" -F "config=@config/config_aiaa.json;type=application/json" -F "data=@models/model.trt.pb"

Got it,

Then you can do the exact same thing for a seg spleen model

that is do

ngc registry model download-version nvidia/med/clara_ct_seg_spleen_amp:1 --dest /var/tmp
cd /var/tmp/clara_ct_seg_spleen_amp/

curl -X PUT "http://127.0.0.1:5000/admin/model/segmentation_spleen" -F "config=@config/config_aiaa.json;type=application/json" -F "data=@models/model.trt.pb"

Then you can test that model.
For spleen you can use data from here: http://medicaldecathlon.com/