Convert pytorch pkl file to ptl file - machine-learning

I've trained a classification model using pytorch and got the model in pkl format. I need to convert this file to ptl format to deploy in React Native platform. Is there any way to convert the pkl file to ptl or I need to train the classification model again in another way?

Related

Is there any way to read .pth(dataset) and turn them into csv?

I have a repo that provided a model architecture, but not pretrained model. it actually provides a .pth file but it's dataset inside the file, is there any way to make the dataset to csv?
.pth files saved with toch.save() are supposed to be binaries. using torch.load() you can get the dataset, and then save it again as a .csv with pandas for example

Convert tf.keras vgg16 classifier from .pb to pbtxt for use in opencv dnn module

I fine tuned a simple vgg16 model using tf.keras and converted it to .pb using
new_model = tf.keras.experimental.load_from_saved_model('path_to_saved_model')
Now I wanted to use that model in opencv dnn module so I needed a pbtxt file , I tried converting using some scripts but failed, so i also read you can at times get aways without specifying the .pbtxt file like in east text detector, so i tried that using cv2.readfromnet(frozen.pb) approach but still it showed error and said it faced error while parsing pbtxt file
So I tried converting to onnx format since its just a single file , but also faced error.
Now my question is if you have successfully trained custom models and have converted the frozen graph to pbtxt then what approach do you use (Note: I'm not training a object detector but a simple vgg16 classifier ) so the scripts in tensorflow model zoo are useless to me.
Already spent a couple of hours in this so if you have any suggestion then would love to hear it

How to convert (samesize, categoriezed) images into dataset for TensorFlow

I am learning to create a learning model using TensorFlow.
I have successfully run the MNIST tutorial, now would like to test the model with my own images. They are same-size image (224x224) and classified into folders.
Now I would like to use those images as input for my model as in the MNIST example. I tried to open the MNIST data-set but it's unreadable. I guess it has been converted into some binary types. Through the example, I think the MNIST dataset somehow has a structure like this:
mnist
test
images
labels
train
images
labels
How can I make a dataset look like the MNIST data from my own images files?
Thank you very much!
MNIST is not stored in image format. From the mnist web-site (http://yann.lecun.com/exdb/mnist/) you could see that it has specific format which is already close to the tensor or numpy array, which could be used in tensorflow with minimal adjustments. It is a kind of a matrix with numbers.
What you need to work with usual images (.jpg for instance) is to use any python lib for image processing to convert into the np.array. For example PIL will work, like here:
PIL and numpy
Another option is to use a built-in functions from tensorflow to convert your images straight to tensors supported by tensofrlow, check this out:
https://www.tensorflow.org/versions/r0.9/api_docs/python/image.html

why the model file size trained by libsvm much bigger than the model file trained by opencv

I used the same data to train a svm model,the xml model file trained by opencv is only 802 kb,but the model file trained by libsvm is bigger than 17MB; I don't know the difference between those two model file;

Classifying instances of a set with a Classification Model on WEKA GUI

I am new to data mining and I would like to ask you a classification question.
I have trained a classification algorithm on WEKA (GUI), using a training set in ARFF format. Consequently I saved it in Model format for future use.
Now I want to use this classification Model on WEKA (GUI) to get the predicted class of instances of a set that is also in ARFF format. Could you please give me instructions on how to do this on WEKA? Unlike the Weka Java API, the GUI version has really poor documentation in the Web and I couldn't find anything relevant.
Is it possible to store the classified set back to ARFF format with '?''s replaced with the class label in the class attribute? I need such outputs files for some computations.
Thank you beforehand.

Resources