Comments (8)
When I ran 'detect_test_images.py' with Windows10, keras(2.2.4) and tensorflow(1.15.0), error occurred 'load_model' operation. The error was 'ValueError: Cannot create group in read only mode.'. In my case, I made 'checkpoints' directory and put your 'traffic-light-detection.h5' file in 'checkpoints' folder. How can I solve this problem?
I also modified json file like below.
{
"model" :
{
"image_h": 416,
"image_w": 416,
"anchors": [0.24,0.79, 0.80,2.12],
"max_obj": 5,
"grid_h": 13,
"grid_w": 13,
"num_classes": 2,
"classes": ["go", "stop"],
"obj_thresh": 0.20,
"nms_thresh": 0.01,
"saved_model_name": "traffic-light-detection.h5",
"obj_scale": 85,
"no_obj_scale": 75,
"coord_scale": 70,
"class_scale": 70
},
"plot_model": true,
"train": {
"enabled": false,
"annot_file_name": "carla_all.csv",
"batch_size": 8,
"learning_rate": 1e-4,
"nb_epochs": 500,
"warmup_batches": 0,
"debug": true
}
}
from traffic-light-detection-module.
Ok I could fix this issue. You need to access the model attribute of the YOLO class, e.g.
model = YOLO(config)
and then you can call
yolo.model.load_weights("checkpoints\\traffic-light-detection.h5")
That is how you load the pretrained model. But you have to make several changes to the code.
In yolo.py in the TinyYoloFeature class, i removed the following lines:
pretrained = load_model('checkpoints\\' + config['model']['saved_model_name'], custom_objects={'custom_loss': dummy_loss, 'tf': tf})
pretrained = pretrained.get_layer('model_1')
idx = 0
for layer in self.feature_extractor.layers:
print(layer.name)
layer.set_weights(pretrained.get_layer(index=idx).get_weights())
idx += 1
as well as in the YOLO class the following lines:
pretrained = load_model('checkpoints\\' + config['model']['saved_model_name'], custom_objects={'custom_loss': self.custom_loss, 'tf': tf})
self.model.get_layer('DetectionLayer').set_weights(pretrained.get_layer('DetectionLayer').get_weights())
Now none of these classes loads the model and you can load the pretrained model as I described above. Hope this helps.
from traffic-light-detection-module.
Hi,
Can you please specify which Tensorflow and Keras versions you are using?
from traffic-light-detection-module.
Keras 2.3.1
Tensorflow 1.14.0
from traffic-light-detection-module.
Can you try using Keras 2.2.4 and Tensorflow 1.12.0? I tested it out with those versions and it seemed to be working fine.
from traffic-light-detection-module.
this error happened to me because there is no pretrained model.
"pretrained = load_model('checkpoints\' + config['model']['saved_model_name'], custom_objects={'custom_loss': dummy_loss, 'tf': tf})"
you can find from description.
from traffic-light-detection-module.
I have the same problem as @Kangsan-Jeon .
from traffic-light-detection-module.
hello, I get the following error, could you please help me about it?
This function in the predict.py file;
1- def get_model_from_file(config):
2- path = os.path.join(BASE_DIR, 'checkpoints', config['model']['saved_model_name'])
3- model = load_model(path, custom_objects={'custom_loss': dummy_loss})
4- return model
I get the error:
SavedModel file does not exist at: C:\Users\90531\Source\Repos\traffic-light-detection-module\checkpoints\model.09-2.01.h5/{saved_model.pbtxt|saved_model.pb}
from traffic-light-detection-module.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from traffic-light-detection-module.