sararoma95 / Re-ReND

Re-ReND: Real-time Rendering of NeRFs across Devices
40 stars 3 forks source link

Loading Pretrained chair model error with missing Keys #7

Closed GIP2000 closed 2 months ago

GIP2000 commented 2 months ago

When I load the pre-trained model and try to export the textures using the python main.py --config configs/chair.txt --expname chair-20240826T142431Z-001 --load_ckpt 000000380000 --export_textures I get an error

        Missing key(s) in state_dict: "hash_enc.levels.0.embedding.weight", "hash_enc.levels.1.embedding.weight", "hash_enc.levels.2.embedding.weight", "hash_enc.levels.3.embedding.weight", "hash_enc.levels.4.embedding.weight", "hash_enc.levels.5.embedding.weight", "hash_enc.levels.6.embedding.weight", "hash_enc.levels.7.embedding.weight", "hash_enc.levels.8.embedding.weight", "hash_enc.levels.9.embedding.weight", "hash_enc.levels.10.embedding.weight", "hash_enc.levels.11.embedding.weight", "hash_enc.levels.12.embedding.weight", "hash_enc.levels.13.embedding.weight", "hash_enc.levels.14.embedding.weight", "hash_enc.levels.15.embedding.weight".
        Unexpected key(s) in state_dict: "pe.levels.0.embedding.weight", "pe.levels.1.embedding.weight", "pe.levels.2.embedding.weight", "pe.levels.3.embedding.weight", "pe.levels.4.embedding.weight", "pe.levels.5.embedding.weight", "pe.levels.6.embedding.weight", "pe.levels.7.embedding.weight", "pe.levels.8.embedding.weight", "pe.levels.9.embedding.weight", "pe.levels.10.embedding.weight", "pe.levels.11.embedding.weight", "pe.levels.12.embedding.weight", "pe.levels.13.embedding.weight", "pe.levels.14.embedding.weight", "pe.levels.15.embedding.weight".

I tried to just rename them and then it does run but it doesn't output textures that make anything look like a chair

internal/model.py

        # Load model
        state = ckpt['network_fn_state_dict']

        # "hash_enc.levels.0.embedding.weight", what it should be
        # 'pe.levels.9.embedding.weight' what it is

        count = 0
        while True:
            old_key = f"pe.levels.{count}.embedding.weight"
            new_key = f"hash_enc.levels.{count}.embedding.weight"
            if old_key not in state:
                break
            val = state[old_key]
            del state[old_key]
            state[new_key] = val
            count += 1

        model.load_state_dict(state)

image

Was I not supposed to do change those names? Was I supposed to load the model in a different way?

sararoma95 commented 2 months ago

Hi, sorry to hear that you're experiencing an issue. I was trying to reproduce the error, but I was unable to do so. However, I did notice that the model's weights might be the cause of the problem. Have you tried training and evaluating the model? If so, what's the PSNR (Peak Signal-to-Noise Ratio) looking like? This might give us a better understanding of what's going on.

This is how I run the code to export the textures:

image
sararoma95 commented 2 months ago

Actually, I was able to reproduce the error. The models in Google Drive are not up-to-date with the latest code version. I'll try loading the weights I have now (35,000), which are not the final iteration. Unfortunately, this means the pre-trained models in the repo may not work as expected. To achieve good results, you'll need to train the models from scratch, which would require approximately 24 hours on an A100. I'll try to resolve the issue with the pre-trained models, but in the meantime, training from scratch might be the best solution.

image
GIP2000 commented 2 months ago

Thank you so much. The pretrained model you uploaded definitely looks like a chair. Thank you so much for your help!

sararoma95 commented 2 months ago

This is so great to hear!

On Thu, Aug 29, 2024 at 3:17 PM Gregory Presser @.***> wrote:

Thank you so much. The pretrained model you uploaded definitely looks like a chair. Thank you so much for your help!

— Reply to this email directly, view it on GitHub https://urldefense.com/v3/__https://github.com/sararoma95/Re-ReND/issues/7*issuecomment-2317820128__;Iw!!Nmw4Hv0!1yQlEPkTZ7-SkgW09GGYXkM5SZAOuw-NcEks_mhrcc4Lswzc6rFn-ls8DftSLNthIpy5Go-h4HTHc6cdPxCd_mS-J117Kuqns4o$, or unsubscribe https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AWZC2PN3D222R46GLEXKPO3ZT4URHAVCNFSM6AAAAABNJDOSM6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMJXHAZDAMJSHA__;!!Nmw4Hv0!1yQlEPkTZ7-SkgW09GGYXkM5SZAOuw-NcEks_mhrcc4Lswzc6rFn-ls8DftSLNthIpy5Go-h4HTHc6cdPxCd_mS-J117f9vHoI8$ . You are receiving this because you commented.Message ID: @.***>

-- Best,

Sara Rojas

--

This message and its contents, including attachments are intended solely for the original recipient. If you are not the intended recipient or have received this message in error, please notify me immediately and delete this message from your computer system. Any unauthorized use or distribution is prohibited. Please consider the environment before printing this email.