How to import a dataset consisting of images and annotations - python

I'm new to working with deep learning and I'm trying to import the affectNet dataset with images and annotations separated. Currently, each image has 4 annotations (for eg: 0_aro.npy, 0_exp.npy, 0_ind.npy, 0_val.npy). How can I import the dataset into python?
I've loaded the images and searched online about using the annotations but couldn't find much about how to use them.

Related

Loading Images from Multiple Folders along with their labels into an array

I am working on a multiclass image classification problem and there are 12 folders inside my training folder and I am trying to load all the images from these 12 folders along with their label in the numpy arrays both X and Y.
This is the code that I am using. I am able to get the images as an array, however I want to know how to get the corresponding labels as well. I'd appreciate the help.
This is the code that I am using.

How to convert ndjson data into numpy to extract image data?

Following the Google's doodle dataset I would like to know how to get the numpy 28x28 image data out of a .ndjson file (just the image data).
I am aware that they also provide the dataset in a numpy version but I am facing a similar issue with another dataset similar to Google´s one which only has the simplified .ndjson files.

Is there a way to resize non-image files for CNN similarly to image-based examples?

I am working on a research project involving brain wave data. The goal is to classify (1,0) each "image." The problem is essentially an image classification problem, where I could use a CNN, but it's not clean at all like most CNN examples online. The files that I have are tsv's (each file is an individual trial from a patient), and I have stacked them all into one pickle file with each having the participant ID and trial ID as an additional column.
I want to feed them through a CNN, but almost examples online deal with equal-sized images. My data aren't of equal size, and they aren't images. I'm wanting to use PIL to make each file the same size, but is PIL even the correct way of doing so since I don't have image files?

Artificially incorporate non-rigid motions in Images for generating data using Python/Matlab

The main challenges in Medical Imaging is Data acquisition. There are different types of motions (Rigid & Non Rigid) possible during acquitions(Body movement,breathing etc).
Suppose I want to generate different types of motion artificially in an Image(eg. 3D NIFTI MRI image).
Motions can be global rigid motions or elastic deformation or bspline based local deformations. Input will be an 3D image and output will be a newly generated data incorporated the desired motion.
I was wondering if there is any package or software available to do this, but didn't find any. Using this type of feature we can validate our registration methods or simulate different deformation models.
I want some help in generating such artificial data using python or matlab for NIFTI/DICOM 3D images.
Within Python, there are a couple options. The first is using the pydicom module for I/O along with numpy to represent/process the layers. In order to use this, you may additionally have to use matplotlib, scipy/scikit-image, or Pillow to visualize the input and generated output.
However there is also VTK, which comes with both a Python interface and a DICOM reader/writer. Using vtkpython will allow you to create a fairly simple application for viewing and interacting with the data. For generating the motion layers, I think numpy may still be the best option with this route.
This page has a good introduction to using both of these methods: https://pyscience.wordpress.com/2014/09/08/dicom-in-python-importing-medical-image-data-into-numpy-with-pydicom-and-vtk/

Recognize images in Python

I'm kinda new both to OCR recognition and Python.
What I'm trying to achieve is to run Tesseract from a Python script to 'recognize' some particular figures in a .tif.
I thought I could do some training for Tesseract but I didn't find any similar topic on Google and here at SO.
Basically I have some .tif that contains several images (like an 'arrow', a 'flower' and other icons), and I want the script to print as output the name of that icon. If it finds an arrow then print 'arrow'.
Is it feasible?
This is by no means a complete answer, but if there are multiple images in the tif and if you know the size in advance, you can standardize the image samples prior to classifying them. You would cut up the image into all the possible rectangles in the tif.
So when you create a classifier (I don't mention the methods here), the end result would take a synthesis of classifying all of the smaller rectangles.
So if given a tif , the 'arrow' or 'flower' images are 16px by 16px , say, you can use
Python PIL to create the samples.
from PIL import Image
image_samples = []
im = Image.open("input.tif")
sample_dimensions = (16,16)
for box in get_all_corner_combinations(im, sample_dimensions):
image_samples.append(im.crop(box))
classifier = YourClassifier()
classifications = []
for sample in image_samples:
classifications.append (classifier (sample))
label = fuse_classifications (classifications)
Again, I didn't talk about the learning step of actually writing YourClassifier. But hopefully this helps with laying out part of the problem.
There is a lot of research on the subject of learning to classify images as well as work in cleaning up noise in images before classifying them.
Consider browsing through this nice collection of existing Python machine learning libraries.
http://scipy-lectures.github.com/advanced/scikit-learn/index.html
There are many techniques that relate to images as well.

Categories

Resources