BVLC / caffe

Caffe: a fast open framework for deep learning.
http://caffe.berkeleyvision.org/
Other
34.12k stars 18.69k forks source link

AttributeError: 'module' object has no attribute 'io'; a = caffe.io.caffe_pb2.BlobProto.FromString(proto_data) #4897

Closed aquibjaved closed 7 years ago

aquibjaved commented 8 years ago

I am doing a gender recognition program with caffe here's the link of the code I am trying.

While running the code I always stuck at this error

 a = caffe.io.caffe_pb2.BlobProto.FromString(proto_data)
AttributeError: 'module' object has no attribute 'io'

while importing caffe I am not getting any error

>>>import caffe
>>>

Here's the full traceback:

 Traceback (most recent call last):
  File "gender_age.py", line 7, in <module>
    import caffe
  File "/home/aquib/deep-learning/caffe/python/caffe/__init__.py", line 1, in <module>
    from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver
  File "/home/aquib/deep-learning/caffe/python/caffe/pycaffe.py", line 15, in <module>
    import caffe.io
  File "/home/aquib/deep-learning/caffe/python/caffe/io.py", line 4, in <module>
    from skimage.transform import resize
  File "/usr/local/lib/python2.7/dist-packages/skimage/transform/__init__.py", line 1, in <module>
    from .hough_transform import (hough_line, hough_line_peaks,
  File "/usr/local/lib/python2.7/dist-packages/skimage/transform/hough_transform.py", line 3, in <module>
    from .. import measure
  File "/usr/local/lib/python2.7/dist-packages/skimage/measure/__init__.py", line 7, in <module>
    from ._polygon import approximate_polygon, subdivide_polygon
  File "/usr/local/lib/python2.7/dist-packages/skimage/measure/_polygon.py", line 2, in <module>
    from scipy import signal
  File "/usr/local/lib/python2.7/dist-packages/scipy/signal/__init__.py", line 303, in <module>
    from ._peak_finding import *
  File "/usr/local/lib/python2.7/dist-packages/scipy/signal/_peak_finding.py", line 10, in <module>
    from scipy.stats import scoreatpercentile
  File "/usr/local/lib/python2.7/dist-packages/scipy/stats/__init__.py", line 344, in <module>
    from .stats import *
  File "/usr/local/lib/python2.7/dist-packages/scipy/stats/stats.py", line 176, in <module>
    from . import distributions
  File "/usr/local/lib/python2.7/dist-packages/scipy/stats/distributions.py", line 10, in <module>
    from ._distn_infrastructure import (entropy, rv_discrete, rv_continuous,
  File "/usr/local/lib/python2.7/dist-packages/scipy/stats/_distn_infrastructure.py", line 43, in <module>
    from new import instancemethod
  File "/home/aquib/Desktop/cnn_age_gender_models_and_data.0.0.2/new.py", line 16, in <module>
    a = caffe.io.caffe_pb2.BlobProto.FromString(proto_data)
AttributeError: 'module' object has no attribute 'io'

I've also 2 times remove and install the caffe. I also did the runtest...but there's no error at that time.

kevgeo commented 7 years ago

@aquibjaved Were you able to solve this?I'm getting the same error when I'm doing this from caffe.proto import caffe_pb2 Error is- Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named 'caffe.proto'

aquibjaved commented 7 years ago

@kevgeo No I didn't get any solutions.

kevgeo commented 7 years ago

@aquibjaved Which version of OpenCV and python are you using?

aquibjaved commented 7 years ago

@kevgeo I am using opencv 2.4.10 and python 2.7.12

Nomia commented 3 years ago

have u found any solution?

got the same error on google colab @aquibjaved

Nomia commented 3 years ago

And I was trying to go through your AgeGenderDemo.ipynb in the age and gender repo

aquibjaved commented 3 years ago

Hi @Nomia Sorry for the late response, I am not sure how did I fixed the issue and closed it. It's been a long time I am not able to recall it. Is there any reason you want to do this with CAFFE library because I checked there models which you can use via openCV. have a look into this one: (https://learnopencv.com/age-gender-classification-using-opencv-deep-learning-c-python/)

Nomia commented 3 years ago

I was going to convert the caffemodel to coreml model so that I could use it in my ios app, I did that conversion successfully with coremltools, but when I tested it on the xcode, the accuracy was very low, so I wanna try that model out in the repo's demo python notebook, but when I tried to run that notebook, I got the error above.

Here is the result of my converted model, hope that you could give some help link

aquibjaved commented 3 years ago

hey, @Nomia can you check this one, this link

Screenshot 2021-08-04 at 11 08 55 PM