Processing Image To Feed data in to Convolutional Neural Network - python

I am new to Machine Learning and recently took a courser by Andrew Ng on Coursera.
After that I shifted to Python and used Pandas, Numpy, Sklearn to implement ML algorithms.
Now while surfing I came across tensorFLow and found it pretty amazing, and implemented this example which takes MNIST data as input.
Now I want to read my own custom images and use them for training. I am confused as to how should I convert the images to MNIST sort of data. Or some other way to train my Network.
I took this tutorial to create my network.

Information on the MNIST dataset can be found on Yann LeCun's website.
The TensorFlow module tensorflow.examples.tutorials.mnist.mnist_softmax.py looks to be acquiring/preparing the dataset for the train/test steps.
The MNIST dataset contains an image of a handwritten digit and a corresponding label. If you would like to create labels for a new image, you could use scipy.misc.imread.

Related

Implementing CNN from scratch with numpy only and save model

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.

How to create pre-trained model for LSTM with non-image data in python?

I have Data A from accelerometer and gyroscope sensors like this
I want to create a pre-trained model to be used to classify with the LSTM method using Data A in python. Is that possible? Because from what I read, pre-trained is used for image data and uses methods such as CNN for classification. In addition, I tried to find data that has gone through the pre-trained process but have not found it so I doubt whether it is possible.
And if I do the classification using LSTM, can I use the A data that has gone through the pre-trained?
Is there a tutorial I can study? Any help would be very much appreciated.
I advise you to look at some HAR datasets you can find plenty of examples in Kaggle that are using a LSTM, the first one that comes to my mind is the excellent tutorial of Jason Brownlee https://machinelearningmastery.com/how-to-develop-rnn-models-for-human-activity-recognition-time-series-classification/

How to load custom dataset to capsule network?

I am a newbie to deep learning and its frameworks. I have collected some jpg images of bicycle and bike object. Now, I wanted to train this images using capsule network.
Capsule network is implemented on mnist dataset. The code is here.
What are the required changes to apply my custom dataset. Image should be changed to numpy format or tfrecord format? And how to load them on network?
To load custom dataset, I refered this. It helps. The dataset is converted to numpy array and keras background is used.
I load custom dataset and for capsule network model, use this.

Using my own data in tensorflow for neuralnetwork implementation

I'm very new to TensorFlow and Python. I have a dataset, very similar to the MNIST dataset (28 * 28 image). I have been following a lot of the online tutorials on how to implement a basic neural network with tensorflow and found that most of them just use:
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("/tmp/data/", one_hot = True)
Is there a way for me to use my own MNIST-like data instead of importing it from tensorflow? Furthermore, will I still be able to use mnist.train.next_batch with the MNIST-like data? Thank you.
The MNIST dataset used in tensorflow tutorial includes 4 files:
train-images-idx3-ubyte
train-labels-idx1-ubyte
t10k-images-idx3-ubyte
t10k-labels-idx1-ubyte
The first two are training data and training labels; The next two are test data and testing labels. The pixel values/label are stored as byte streams in the file. If your dataset has the exact format as MNIST dataset above, definitely you can use the same approach. The image and label part are read using extract_image and extract_labels method defined here.
Actually it is up to you to store your data in any other format (maybe tf.Example TFRecord file is actually easier). Take a look at the new API too.

Machine Learning - Features design for Images

I just started learning about machine learning recently and have a project where I have to develop a program for QR code localization so that a QR code can be detected and read at any angle of rotation. Development will be done in Python.
The plan is to gather various images of the QR codes at different angles with different backgrounds. From this I would like to create a dataset for training with neural networks and then testing.
The issue that I'm having is that I can't seem to figure out a correct feature design for the dataset and how to identify the QR code from the images for feature processing. Would I use ground-truth images to isolate the QR code or edge magnitude maps? Feature design for images seems to confuse me.
Any help with this would be amazing? Thanks for your time.
You mention that you want to train neural networks. Instead of starting with your problem, start with a beginner example.
Start with MNIST example for deep learning.
Train your Neural Network on notMNIST dataset that is used in Udacity Deep Learning Course.
In these two examples, you will see that you do not design features but NN somehow founds correct features. Easiest solution would be to use same technique for QR codes in your dataset.

Categories

Resources