I'm working with a Deep Learning model which has a ResNet-50 as backbone pretrained on ImageNet. The dataset that I'm using is the CUB-200, which is a set of 200 species of birds. For this reason I think that could be good to have a pretrained model on a dataset that has a similar domain and I found that the iNaturalist one could be the one that I'm looking for.
The problem is that I didn't find any pretrained model for Pytorch, but only a Tensorflow one here.
I tried to convert it using the MDNN library, but it needs also the '.ckpt.meta' file extend and I have only the '.ckpt'.
This is an example of how to use the MDNN library to convert a tf model to torch:
mmconvert -sf tensorflow -in imagenet_resnet_v2_152.ckpt.meta -iw imagenet_resnet_v2_152.ckpt --dstNode MMdnn_Output -df pytorch -om tf_to_pytorch_resnet_152.pth
Could anyone help me with it?
Related
Currently, I am learning CNN by myself. I find lots of sources on the Internet. But most of them use Pytorch and Tensorflow. I want to find some examples for image classification that uses NumPy only and have some way to train my dataset, save and load the trained model. Does anyone know where is the example?
I wrote a library if you are interested: https://github.com/samrere/pytortto
basically it's a pytorch written in numpy&cupy. It completely follows pytorch interface, and can be trained in GPU.
I've included several basic examples, such as training Resnet, UNet, vision transformer and DCGAN, all trained/finetuned entirely using simple numpy functions.
I had a pre-trained model(tensorflow model) which was trained using data from publicly available data set. I had meta file and ckpt file. I’d like to train my tensorflow model using new data from privately obtained data set. I have small dataset, so I’d like to fine-tune my model according to ‘Strategy 2’ or ‘Strategy 3’.
Strategy 2: Train some layers and leave the others frozen.
Strategy 3: Freeze the convolutional base.
Reference site: https://towardsdatascience.com/transfer-learning-from-pre-trained-models-f2393f124751
However, I couldn’t find sample code which is implemented in a transfer learning and fine-tuning for tensorflow model. There are many examples with keras model. How can I implement in a transfer learning and fine-tuning for my tensorflow model?
If you don't have to use Tensorflow's functions, You can use example code with tf.keras module of Tensorflow 2.0 also..
I have BERT-base model checkpoints which I trained from scratch in Tensorflow. How can I use those checkpoints to predict masked word in a given sentence?
Like, let say sentence is,
"[CLS] abc pqr [MASK] xyz [SEP]"
And I want to predict word at [MASK] position.
How can I do it?
I searched a lot online but everyone is using BERT for their task specific classification tasks.
Not using BERT to predict masked word.
Please help me in solving this prediction problem.
I created data using create_pretraining_data.py & trained model from scratch using run_pretraining.py from official BERT repo (https://github.com/google-research/bert)
I have searched in issues in official bert repo. But didn't found any solution.
Also looked at code in that repo. They're using Estimator which they are training not using from checkpoints weights.
Didn't found any way to use way to use Tensorflow checkpoints of BERT-base model (trained from scratch) to predict word masked token (i.e. [MASK]).
Do you definitely need to start from a TF checkpoint? If you can use one of the pretrained models used in the pytorch-transformers library, I wrote a library for doing exactly this: FitBERT.
If you have to start with a TF checkpoint, there are scripts for converting from a TF checkpoint to something pytorch-transformers can use, link, and after converting you should be able to use FitBERT, or you can just see what we're doing in the code.
I have an old model defined and trained using tensorflow, and now I would like to work on it but I'm currently using Keras for everything.
So the question is: is it possible to load a tf cehckpoint (with *.index, *.meta etc..) into a Keras model?
I am aware of old questions like: How can I convert a trained Tensorflow model to Keras?.
I am hoping that after 2 years, and with keras being included into tf, there would be a easier way to do it now.
Unfortunately I don't have the original model definition in tf; I may be able to find it, but it would be nicer if it wasn't necessary.
Thanks!
In the below link, which is the official TensorFlow tutorial, the trained model is saved and it has .ckpt extension. After, it is loaded and is used with Keras model.
I think it might help you.
https://www.tensorflow.org/tutorials/keras/save_and_restore_models
I'm training tensorflow slim based models for image classification on a custom dataset. Before I invest a lot of time training such huge a dataset, I wanted to know whether or not can I convert all the models available in the slim model zoo to tflite format.
Also, I know that I can convert my custom slim-model to a frozen graph. It is the step after this which I'm worried about i.e, conversion to .tflite from my custom trained .pb model.
Is this supported ? or is there anyone who is facing conversion problems that has not yet been resolved ?
Thanks.
Many Slim models can be converted to TFLite, but it isn't a guarantee since some models might have ops not supported by TFLite.
What you could do, is try and convert your model to TensorFlow Lite using TFLiteConverter in Python before training. If the conversion succeeds, then you can train your TF model and convert it once again.