Skip to content

TypeError: slice indices must be integers or None or have an __index__ method` #34

@tobimichigan

Description

@tobimichigan

Firstly, let me commend you on your effort for this paper and the repo that accompanies it. As a programmer myself, I know how difficult it is to write code especially for machine learning models.

I successfully, reproduced the results through a GPU hardware and the code code ran up until:

# Visualize results imshow(img_p, lbl_p, pred>0.5, title=['Slice','Ground truth', 'Prediction'])

Besides, I also had to downgrade SCIPY to 1:00 because of the depreciated imgresize issue.

/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:108: DeprecationWarning: imresizeis deprecated!imresizeis deprecated in SciPy 1.0.0, and will be removed in 1.2.0. Use ``skimage.transform.resize`` instead. /usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:104: DeprecationWarning:imresizeis deprecated!imresize is deprecated in SciPy 1.0.0, and will be removed in 1.2.0. Use ``skimage.transform.resize`` instead.

perhaps you could look into these issues.

Additionally, running:
`# Prepare liver patch for step2

net1 output is used to determine the predicted liver bounding box

img_p2, bbox = step2_preprocess_img_slice(img_p, pred)
imshow(img_p2)`

gave the following error:
`---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in ()
----> 1 img_p2, bbox = step2_preprocess_img_slice(img_p, pred)
2 imshow(img_p2)

in step2_preprocess_img_slice(img_p, step1_pred)
79 y2 = min(img.shape[0], y2+y_pad)
80
---> 81 img = img[y1:y2+1, x1:x2+1]
82 pred = pred[y1:y2+1, x1:x2+1]
83

TypeError: slice indices must be integers or None or have an index method`

these affected the rest of the executions such as:

  1. `# Visualize result

extract liver portion as predicted by net1

x1,x2,y1,y2 = bbox
lbl_p_liver = lbl_p[y1:y2,x1:x2]

Set labels to 0 and 1

lbl_p_liver[lbl_p_liver==1]=0
lbl_p_liver[lbl_p_liver==2]=1
imshow(img_p2[92:-92,92:-92],lbl_p_liver, pred2>0.5)`

  1. # Load step2 network net2 = caffe.Net(STEP2_DEPLOY_PROTOTXT, STEP2_MODEL_WEIGHTS, caffe.TEST)

and finally

  1. net2.blobs['data'].data[0,0,...] = img_p2 pred2 = net2.forward()['prob'][0,1] print (pred2.shape)

Please could you kindly proffer solutions to these issues?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions