TensorFlow - Feeding models with own images

Contents:


Examples how to feed TensorFlow with own images

Here is a list of links where people provide example TensorFlow code to feed TF models with own images:


Preparing OpenCV2 for use in Python3

One way to read own images and feed them into TensorFlow is using OpenCV. But for this, you first have to install OpenCV on your system. I followed this excellent explanation, which worked perfectly in my case (Python 3.4.3).

After building OpenCV (which took roughly 20 minutes on my PC), I tested it within the python3 shell:

juebrauer@ubuntu:~/OpenCV-tmp/build$ python3
Python 3.4.3 (default, Oct 14 2015, 20:28:29) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'3.1.0-dev'
        
            # test_opencv.py
            #
            # small test program to see, whether we can use OpenCV in Python3
            #
            # by Prof. Dr. Juergen Brauer, www.juergenbrauer.org


            import cv2

            # 1. read in image (free image from pixabay)
            img = cv2.imread('space-shuttle.jpg')

            # 2. resize image
            img = cv2.resize(img, (0,0), fx=1.5, fy=1.5)

            # 3. prepare window
            cv2.namedWindow('my window 1')

            # 4. show window with image
            cv2.imshow('my window 1', img)

            # 5. wait for key press by user ...
            cv2.waitKey(0)

            # 6. ... then close the window
            cv2.destroyAllWindows()