Open MartinPlantinga opened 6 years ago
This is a numpy version problem. I guess you're using version > 1.11.2, which doesn't support float index.
A quick fix is just to install numpy 1.11.2: sudo pip install numpy==1.11.2
, then you don't have to change anything in the code.
I have had this problem before. Because I have no root user rights, so I directly change the code in rpn/proposal_target_layer.py", line 305
roi_mask = -1 * np.ones((int(h), int(w)), dtype=np.float32)
There are another places need to be change in the rpn/proposal_target_layer.py
You can fix the float index problem by converting the indexes to integer.
Or without root, you can try pip install numpy==1.11.2 --user
. It will be installed on your local system, and there is no need to change the code :)
@nqanh Thanks a lot! It's a good means to solve this problem. You always can give us good advice!
Thanks guys! I did as @lsj910128 proposed and changed the lib/rpn/proposal_target_layer.py
to force the values to be integers. After modifying this, the training script worked! This is the summary of the changes I made:
for ind in inds:
cls = clss[ind]
start = 4 * cls
end = start + 4
start = int(start)
end = int(end)
bbox_targets[ind, start:end] = bbox_target_data[ind, 1:]
bbox_inside_weights[ind, start:end] = cfg.TRAIN.BBOX_INSIDE_WEIGHTS
if fg_inds.size > 0:
fg_inds = npr.choice(fg_inds, size=int(fg_rois_per_this_image), replace=False)
if bg_inds.size > 0:
bg_inds = npr.choice(bg_inds, size=int(bg_rois_per_this_image), replace=False)
labels[int(fg_rois_per_this_image):] = 0
roi_mask = -1 * np.ones((int(h), int(w)), dtype=np.float32)
mask_overlap = np.zeros((int(y2o-y1o), int(x2o-x1o)), dtype=np.float32)
mask_overlap_draw = color_img[int(y1o):int(y2o), int(x1o):int(x2o), :]
mask_overlap[:, :] = gt_mask[int(y1o):int(y2o), int(x1o):int(x2o)]
roi_mask[int(y1o-y1):int(y2o-y1), int(x1o-x1):int(x2o-x1)] = mask_overlap
@nqanh I did 'pip install numpy==1.11.2
' but it doesn't work
if i did 'pip install numpy==1.11.2'
then error message is
ImportError: numpy.core.multiarray failed to import
so, I reinstall >1.11 numpy then error message is
TypeError: slice indices must be integers or None or have an index method
so I fixed the code, then it worked Could I solve this problem?
My environment is
anaconda2 python2.7.12 ubuntu14 cuda8.0 cudnn5.1
You can manually convert the float indexes to integers. If it works, then it's ok.
When training the network with your script I get the following error:
These errors are probably caused by the version of Numpy I am using (v 13.3). I managed to solve these errors by modifying the `$AffordanceNet/lib/rpn/proposal_target_layer.py file as follows:
vim $AffordanceNet/lib/rpn/proposal_target_layer.py
I get a new error, however, which I am not able to solve: