Load a pre-trained Pytorch model in Julia

Hi all,
What are the best practices to load a pre-trained pytorch model in Julia (e.g. Flux.jl)?
Thank you!

Depends on the model, for CNN you should check Metalhead, Home · Metalhead.jl. Also, for an easier interface, you could see FastAPI, FastAI.jl - FastAI.jl.

Thank you!
In my current case, it is only MLP.
I am going to check the FastAI.jl

Hi, I have the same question.
Have you made a success of trying FastAI.jl to load a pre-trained pytorch model?

Hi, in my project, I kept using Pytorch finally, so I did not try it out in Julia.
You may try to find some tutorials in FastAI.

The problem is that the PyTorch saved model format does not contain enough information to reconstruct the model without knowing what the model structure is ahead of time. You’d have the same problem trying to load PyTorch weights into a TF or JAX model. How libraries like Metalhead.jl and Transformers.jl handle this is by keeping a known list of models for which we can specify direct mappings between PyTorch → Julia. This is somewhat manual, but you could try reusing the utility functionality from either library for your own code to save some work.