Python Forum

Full Version: NameError: name 'd' is not defined
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Here steps of my code

from skimage import io
import mxnet as mx

test='C:/Users/Admin/Desktop/test.lst'# folder where must be my test.lst
DataSet='C:/Users/Admin/Downloads/mypic/'

data_iter = mx.image.ImageIter(
batch_size=4,
data_shape=(3,816, 1232),
label_width=4,
path_imglist='C:/Users/Admin/Desktop/test.lst',
path_root='DataSet')


for data in data_iter:
    d = data.data[0]
    if some_condition_is_True:
        break



import numpy as nd
img =nd.transpose(d,(0,2,3,1))
after it, i get error
Error:
Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'd' is not defined
What's wrong?
this error is not produced by this code.
Check the actual code that you are running.

Also if some_condition_is_True: - some_condition_is_True is just a placeholder, you need to replace it with actual condition that will break you out of the loop