I tried to train a retinanet model with Efficientnet as a backbone. The train script crashes with the following trace:
Traceback (most recent call last):
File "bin/train.py", line 579, in <module>
main()
File "bin/train.py", line 520, in main
weights = backbone.download_imagenet()
File "bin/../../keras_retinanet/models/effnet.py", line 41, in download_imagenet
from efficientnet.model import BASE_WEIGHTS_PATH
ImportError: cannot import name 'BASE_WEIGHTS_PATH'
I have efficientnet in my requirement,txt, I believe the efficientnet code might have been changed so it does not contain BASE_WEIGHTS_PATH anymore,
But if you are using keras_applications, then I can see BASE_WEIGHTS_PATH there, but you probably should fix the imports:
def download_imagenet(self):
""" Downloads ImageNet weights and returns path to weights file.
"""
from efficientnet.model import BASE_WEIGHTS_PATH
from efficientnet.model import WEIGHTS_HASHES
follow. same problem.
you can still train if you parse --no-weight but without pretrained at imagenet.
Or for imagenet you can change the effnet.py ( I am trying it now and it seems to work) like
"if backbone == 'EfficientNetB0':
model = efn.EfficientNetB0(weights='imagenet', input_tensor=inputs, include_top=False)"
I am actually able to train, I just replaced the two imports mentioned above with this:
#from efficientnet.model import BASE_WEIGHTS_PATH
#from efficientnet.model import WEIGHTS_HASHES
BASE_WEIGHTS_PATH = (
'https://github.com/Callidior/keras-applications/'
'releases/download/efficientnet/')
WEIGHTS_HASHES = {
'efficientnet-b0': ('e9e877068bd0af75e0a36691e03c072c',
'345255ed8048c2f22c793070a9c1a130'),
'efficientnet-b1': ('8f83b9aecab222a9a2480219843049a1',
'b20160ab7b79b7a92897fcb33d52cc61'),
'efficientnet-b2': ('b6185fdcd190285d516936c09dceeaa4',
'c6e46333e8cddfa702f4d8b8b6340d70'),
'efficientnet-b3': ('b2db0f8aac7c553657abb2cb46dcbfbb',
'e0cf8654fad9d3625190e30d70d0c17d'),
'efficientnet-b4': ('ab314d28135fe552e2f9312b31da6926',
'b46702e4754d2022d62897e0618edc7b'),
'efficientnet-b5': ('8d60b903aff50b09c6acf8eaba098e09',
'0a839ac36e46552a881f2975aaab442f'),
'efficientnet-b6': ('a967457886eac4f5ab44139bdd827920',
'375a35c17ef70d46f9c664b03b4437f2'),
'efficientnet-b7': ('e964fd6e26e9a4c144bcb811f2a10f20',
'd55674cc46b805f4382d18bc08ed43c1')
}
I mentioned this issue here just to make the developers aware of it and perhaps fix it.
Thank you @ianstath
Yea your solution is better. Great
Most helpful comment
I am actually able to train, I just replaced the two imports mentioned above with this:
I mentioned this issue here just to make the developers aware of it and perhaps fix it.
Thank you @ianstath