'I cannot train tensorflow

I am trying to follow these instructions in order to train tensorflow: https://www.datacamp.com/community/tutorials/tensorflow-tutorial?utm_source=adwords_ppc&utm_campaignid=898687156&utm_adgroupid=48947256715&utm_device=c&utm_keyword=&utm_matchtype=b&utm_network=g&utm_adpostion=1t1&utm_creative=255798340456&utm_targetid=dsa-498578051924&utm_loc_interest_ms=&utm_loc_physical_ms=9061578&gclid=Cj0KCQiA5dPuBRCrARIsAJL7oeh8O1BawcnisHgACgu2gxP1BcofUPxNxsMf2D7cOjC-7QYeuU3ZBZEaAuDnEALw_wcB

I execute this code:

import os
import numpy as np

def load_data(data_directory):
    directories = [d for d in os.listdir(data_directory)
            if os.path.isdir(os.path.join(data_directory, d))]

    labels = []
    images = []
    for d in directories:
        label_directory = os.path.join(data_directory,d)
        file_names = [os.path.join(label_directory, f)
                for f in os.listdir(label_directory)
                if f.endswith(".ppm")]
        for f in file_names:
            images.append(skimage.data.imread(f))
            labels.append(int(d))
    return images, labels

ROOT_PATH = "/home/"
train_data_directory = os.path.join(ROOT_PATH, "BelgiumTSC_Training/Training")
test_data_directory = os.path.join(ROOT_PATH, "BelgiumTSC_Testing/Testing")

images, labels = load_data(train_data_directory)

# print the 'images' dimensions
print(np.array(images).ndim)

# print the number of 'images''s elements
print(np.array(images).size)

# print the first instance of 'images'
images[0]

I get this error:

Traceback (most recent call last):
  File "loading_data.py", line 24, in <module>
    images, labels = load_data(train_data_directory)
  File "loading_data.py", line 16, in load_data
    images.append(skimage.data.imread(f))
NameError: name 'skimage' is not defined

I followed this link without any success: Import error No module named skimage



Solution 1:[1]

instead of

images.append(skimage.data.imread(f))

use

import cv2
images.append(cv2.imread(f))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 kesh