mw9385 / Collision-avoidance

Towards Monocular Vision Based Collision Avoidance Using Deep Reinforcement Learning
35 stars 8 forks source link

Wrong weight file #5

Closed KhuongDiep911 closed 1 year ago

KhuongDiep911 commented 1 year ago

Hi,

I am trying to run the testing file of your code, But I have the problem "ValueError: You are trying to load a weight file containing 1 layers into a model with 7 layers".

Do you uploaded the right weight file for the D3QN model. Can you help me to recheck again?

Thank you in advance for your help. Khuong

mw9385 commented 1 year ago

Sorry for the late response. I was on a business trip for three weeks. I will check the error.

mw9385 commented 1 year ago

@KhuongDiep911 Could you try with the model real_world_test/Saved_models/D3QN_V_17_single.h5. Maybe the error has appeared due to multi-GPU training. The model in real_world_test is a converted model that fits to single GPU.

KhuongDiep911 commented 1 year ago

First of all, thank you so much for sharing this code, it helps me a lot to understand how to implement DRL to drone.

Yeah, I tried the "D3QN_V_17_single.h5" file and it can be run. But the result is not good. May I ask is this just a demo or the final trained model?

And you mentioned about "a converted model that fits to single GPU". So if I train on multi-gpu, does that means I need to do the converted step? I haven't tried training on multi-gpu, so can you tell me how to do it?

Thank you very much for your help, Khuong

mw9385 commented 1 year ago

@KhuongDiep911 Thanks for your interest in my research. When I trained my model, I trained it with multiple GPUs. This model cannot be ran in a model with single GPU. So, you need to convert them that fits to single GPU implementation. Refer this (https://github.com/keras-team/keras/issues/11253#issuecomment-482467792) solution. It may help you a lot.

The performance of my model is highly affected by many factors such as estimated depth image resolution, illumination. If you try to implement my model in an indoor environments, it would be fine. However, if your environment is an outdoor, then you need to change the depth estimation model with another one. As far as I know, a model trained with NYU2Dataset would work. I will check the model and try to upload it.

mw9385 commented 1 year ago

@KhuongDiep911 I have uploaded D3QN_V_3_single.h5. This will remove issues. Also, i uploaded est_model_V1.json together. This is depth estimation model trained with NYU dataset. Load the model before you run collision avoidance model. The code that loads depth estimation model in Test_D3QN.py is written to load original depth estimation model. Change it with my new depth estimation model. Then it would work. Let me know any further issues.

Many Thanks.

KhuongDiep911 commented 1 year ago

Hi @mw9385, I changed the code to load your new depth estimation model, but I have this error "TypeError: ('Keyword argument not understood:', 'implementation')". I'm new in tensorflow and keras, so maybe I made some mistakes.

Here is the code after changing:

with tf.name_scope("predict"):    
        height = 228
        width = 304
        channels = 3
        batch_size = 1
        input_node = tf.placeholder(tf.float32, shape=(None, height, width, channels))
        model_weight_path = './NYU_FCRN-checkpoint/est_model_V1.h5'
        model_json_path = './NYU_FCRN-checkpoint/est_model_V1.json'

        print('start create the session and model')
        json_file = open(model_json_path, 'r')
        loaded_model_json = json_file.read()
        json_file.close()
        net = model_from_json(loaded_model_json)
        net.load_weights(model_weights_path)

        config = tf.ConfigProto()
        cnn_sess = tf.Session(config=config)
        cnn_saver = tf.train.Saver()     
        cnn_saver.restore(cnn_sess)
        print('Finishied')

Do you know what is the problem in my code?

Thank you so much, Khuong

mw9385 commented 1 year ago

TypeError: ('Keyword argument not understood:', 'implementation') usually occurs when tensorflow version is not matched. Try with tensorflow version 1.12.0. What is your tensorflow version?

KhuongDiep911 commented 1 year ago

Hi @mw9385,

I'm using tensorflow 1.14.0 because tensorflow 1.12.0 causes some package conflicts. Maybe I installed the wrong dependencies for tensorflow 1.10.0. Could you please send the yaml file with all of the utilized packages and their versions? I'll try again to install Tensorflow 1.12.0.

Thank you very much for your help, Khuong

mw9385 commented 1 year ago

Sorry, I changed my computer settings recently. Maybe try with conda installation.

KhuongDiep911 commented 1 year ago

Okay, I will try to install Tensorflow 1.12.0 again. You are very kind, thank you so much for your help!