leondgarse / keras_cv_attention_models

Keras beit,caformer,CMT,CoAtNet,convnext,davit,dino,efficientdet,edgenext,efficientformer,efficientnet,eva,fasternet,fastervit,fastvit,flexivit,gcvit,ghostnet,gpvit,hornet,hiera,iformer,inceptionnext,lcnet,levit,maxvit,mobilevit,moganet,nat,nfnets,pvt,swin,tinynet,tinyvit,uniformer,volo,vanillanet,yolor,yolov7,yolov8,yolox,gpt2,llama2, alias kecam
MIT License
596 stars 95 forks source link

Can you provide the code for converting pytorch weights to tf? #106

Closed 131404060321 closed 1 year ago

131404060321 commented 1 year ago

Hi. Can you provide the code for converting pytorch weights to tf, such as beit. Because I wanted to try the effect of beitv2's pre-training weights. Thanks!

leondgarse commented 1 year ago

The conversion is actually using my keras_reload_from_torch_model. You can find some model conversion code here including beit 08-20_pytorch_to_keras.md#beit. Generally, it's define model architecture -> covert and load model weights. If you just wanna a fast try, may consider tools like onnx-tensorflow or onnx2tflite.

131404060321 commented 1 year ago

Thanks!

leondgarse commented 1 year ago

Uh, sorry, I didn't expect beitv2 is exactly same with beit, and got lazy when thinking may need to read their code... beit_v2_base_patch16_224.h5 is uploaded in beit_pretrained. Others are also in the way, including eva ones. May soon be available just depending on my network speed...