open-discussion > How to Convert .h5 Trained Weights to PyTorch or Access Model Architecture?
Apr 16, 2025  02:04 PM | engineer junaid
How to Convert .h5 Trained Weights to PyTorch or Access Model Architecture?

Hi everyone šŸ‘‹


First off, thank you for sharing this amazing project! šŸ™
I'm currently exploring this repository /Acute-stroke_Detection_Segmentation and would like to use the trained models in a PyTorch environment.


I noticed that the trained weights are saved in .h5 format (which I assume were trained using Keras/TensorFlow). I have two main questions:




  1. Is there a way to convert the existing .h5 weights to PyTorch format?




    • If yes, could you please guide me or point to any scripts that might help with the conversion?






  2. Alternatively, can you share the full architecture (e.g., in PyTorch or a model summary)?




    • This would help in recreating the same architecture in PyTorch so I can manually port over weights (if needed).






I’d be happy to contribute a PyTorch implementation back to the repo if that's helpful. 😊


Thanks in advance!