simple-faster-rcnn-pytorch icon indicating copy to clipboard operation
simple-faster-rcnn-pytorch copied to clipboard

ImportError: cannot import name array_tool ??

Open JACKYLUO1991 opened this issue 7 years ago • 8 comments
trafficstars

How to solve this problem?

JACKYLUO1991 avatar Jan 23 '18 11:01 JACKYLUO1991

Are you using Python2? try add from __future__ import absolute_import arrary_tool is in utils/array_tool.py

chenyuntc avatar Jan 23 '18 11:01 chenyuntc

ImportError Traceback (most recent call last) in () 4 import torch as t 5 from utils.config import opt ----> 6 from model import FasterRCNNVGG16 7 from trainer import FasterRCNNTrainer 8 from data.util import read_image

/home/luoling/faster-rcnn/model/init.py in () ----> 1 from .faster_rcnn_vgg16 import FasterRCNNVGG16

/home/luoling/faster-rcnn/model/faster_rcnn_vgg16.py in () 3 from torchvision.models import vgg16 4 from model.region_proposal_network import RegionProposalNetwork ----> 5 from model.faster_rcnn import FasterRCNN 6 from model.roi_module import RoIPooling2D 7 from utils import array_tool as at

/home/luoling/faster-rcnn/model/faster_rcnn.py in () 3 import numpy as np 4 import cupy as cp ----> 5 from utils import array_tool as at 6 from model.utils.bbox_tools import loc2bbox 7 from model.utils.nms import non_maximum_suppression

ImportError: cannot import name array_tool I use python3!

JACKYLUO1991 avatar Jan 23 '18 11:01 JACKYLUO1991

I've just tried, it worked fine in my server with python 3.5.2...

python3 train.py train --env='fasterrcnn-caffe' --plot-every=100 --caffe-pretrain

Temporary fix: copy utils/array_tool.py to model/utils/ would fix for you. I will work on it to figure out why. see #12

or change it to from ..utils import array_tool as at

chenyuntc avatar Jan 23 '18 12:01 chenyuntc

I think you are using Python2, when I excute:

python2 train.py train --env='fasterrcnn-caffe' --plot-every=100 --caffe-pretrain

get the same error as you do:

Traceback (most recent call last):
  File "train.py", line 9, in <module>
    from model import FasterRCNNVGG16
  File "model/__init__.py", line 1, in <module>
    from .faster_rcnn_vgg16 import FasterRCNNVGG16
  File "model/faster_rcnn_vgg16.py", line 5, in <module>
    from model.faster_rcnn import FasterRCNN
  File "model/faster_rcnn.py", line 5, in <module>
    from utils import array_tool as at
ImportError: cannot import name array_tool

chenyuntc avatar Jan 23 '18 12:01 chenyuntc

sorry, I can't reproduce it. I've just tried demo.ipynb, It still works fine for me :sob:

Instead, when I changed it to pyhon2 kernel I get


---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-4a4fda8ce59f> in <module>()
      4 import torch as t
      5 from utils.config import opt
----> 6 from model import FasterRCNNVGG16
      7 from trainer import FasterRCNNTrainer
      8 from data.util import  read_image

/home/cy/del/simple-faster-rcnn-pytorch/model/__init__.py in <module>()
----> 1 from .faster_rcnn_vgg16 import FasterRCNNVGG16

/home/cy/del/simple-faster-rcnn-pytorch/model/faster_rcnn_vgg16.py in <module>()
      3 from torchvision.models import vgg16
      4 from model.region_proposal_network import RegionProposalNetwork
----> 5 from model.faster_rcnn import FasterRCNN
      6 from model.roi_module import RoIPooling2D
      7 from utils import array_tool as at

/home/cy/del/simple-faster-rcnn-pytorch/model/faster_rcnn.py in <module>()
      4 import cupy as cp
      5 print('hhhh')
----> 6 from utils import array_tool as at
      7 from model.utils.bbox_tools import loc2bbox
      8 from model.utils.nms import non_maximum_suppression

ImportError: cannot import name array_tool

maybe there is a break in python, I'll try to figure why.

chenyuntc avatar Jan 23 '18 13:01 chenyuntc

@chenyuntc is 4gb gpu enough?

brisker avatar Jan 25 '18 08:01 brisker

Yes, usually it's around 3GB. But some times it will raise to 4 GB --- wired behaviour of CUPY.

chenyuntc avatar Jan 25 '18 08:01 chenyuntc

hello,Have you solved this problem?I have same problem with python3.6..

Xxxxxxxi avatar Nov 11 '19 06:11 Xxxxxxxi