You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I use pipe.build() and pipe.run() to enter the result, the label output is correct, but when I use nvidia.dali.plugin.tf and then use sess.run() to output the result, label is all zero.
my test file format: (image_path, label)
/n01704323/n01704323_1569.JPEG 0
/n01704323/n01704323_5833.JPEG 0
/n01704323/n01704323_2956.JPEG 0
/n01704323/n01704323_4976.JPEG 0
/n01704323/n01704323_8911.JPEG 0
/n01704323/n01704323_9292.JPEG 0
/n01704323/n01704323_1379.JPEG 0
/n01704323/n01704323_8648.JPEG 0
/n01704323/n01704323_8497.JPEG 0
/n01704323/n01704323_2732.JPEG 0
/n02017213/n02017213_3476.JPEG 1
/n02017213/n02017213_6601.JPEG 1
/n02017213/n02017213_3582.JPEG 1
/n02017213/n02017213_765.JPEG 1
/n02017213/n02017213_3461.JPEG 1
/n02017213/n02017213_3894.JPEG 1
/n02017213/n02017213_513.JPEG 1
/n02017213/n02017213_6029.JPEG 1
/n02017213/n02017213_43.JPEG 1
/n02017213/n02017213_5432.JPEG 1
/n02017213/n02017213_7325.JPEG 1
/n02017213/n02017213_7622.JPEG 1
/n02017213/n02017213_7330.JPEG 1
my test code:
`
#First test procedure:
pipe = FileReadPipeline(batch_size=32, num_threads=1, device_id=0, random_shuffle=True,
file_list=save_file_path, initial_fill=4096)
pipe.build()
for _ in range(1):
pipe_out = pipe.run()
images, labels = pipe_out
labels_tensor = labels.asCPU().as_tensor()
images = images.asCPU()
print(np.array(labels_tensor))
# print(images.at(9))
When I use pipe.build() and pipe.run() to enter the result, the label output is correct, but when I use nvidia.dali.plugin.tf and then use sess.run() to output the result, label is all zero.
my test file format: (image_path, label)
/n01704323/n01704323_1569.JPEG 0
/n01704323/n01704323_5833.JPEG 0
/n01704323/n01704323_2956.JPEG 0
/n01704323/n01704323_4976.JPEG 0
/n01704323/n01704323_8911.JPEG 0
/n01704323/n01704323_9292.JPEG 0
/n01704323/n01704323_1379.JPEG 0
/n01704323/n01704323_8648.JPEG 0
/n01704323/n01704323_8497.JPEG 0
/n01704323/n01704323_2732.JPEG 0
/n02017213/n02017213_3476.JPEG 1
/n02017213/n02017213_6601.JPEG 1
/n02017213/n02017213_3582.JPEG 1
/n02017213/n02017213_765.JPEG 1
/n02017213/n02017213_3461.JPEG 1
/n02017213/n02017213_3894.JPEG 1
/n02017213/n02017213_513.JPEG 1
/n02017213/n02017213_6029.JPEG 1
/n02017213/n02017213_43.JPEG 1
/n02017213/n02017213_5432.JPEG 1
/n02017213/n02017213_7325.JPEG 1
/n02017213/n02017213_7622.JPEG 1
/n02017213/n02017213_7330.JPEG 1
my test code:
`
#First test procedure:
pipe = FileReadPipeline(batch_size=32, num_threads=1, device_id=0, random_shuffle=True,
file_list=save_file_path, initial_fill=4096)
pipe.build()
for _ in range(1):
pipe_out = pipe.run()
images, labels = pipe_out
labels_tensor = labels.asCPU().as_tensor()
images = images.asCPU()
print(np.array(labels_tensor))
# print(images.at(9))
output:
[[1]
[0]
[1]
[0]
[1]
[1]
[1]
[0]
[1]
[1]
[0]
[1]
[1]
[0]
[0]
[0]
[1]
[0]
[0]
[0]
[1]
[1]
[0]
[0]
[0]
[1]
[0]
[1]
[0]
[1]
[0]
[0]]
#--------------------------------------#
#Second test procedure:
device_id = 0
pipe = FileReadPipeline(batch_size=32, num_threads=1, device_id=0, random_shuffle=True,
file_list=save_file_path, initial_fill=4096)
seri_pipe = pipe.serialize()
daliop = dali_tf.DALIIterator()
with tf.device('/gpu:%i' % device_id):
image, label = daliop(serialized_pipeline=seri_pipe,
batch_size=32,
height=224,
width=224,
device_id=device_id)
gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.5)
config = tf.ConfigProto(gpu_options=gpu_options)
with tf.Session(config=config) as sess:
ims, labels = sess.run([image, label])
print(labels)
`
output:
[[ 0.00000000e+00]
[ 0.00000000e+00]
[ 1.40129846e-45]
[ 1.40129846e-45]
[ 1.40129846e-45]
[ 1.40129846e-45]
[ 0.00000000e+00]
[ 0.00000000e+00]
[ 1.40129846e-45]
[ 0.00000000e+00]
[ 0.00000000e+00]
[ 1.40129846e-45]
[ 0.00000000e+00]
[ 0.00000000e+00]
[ 1.40129846e-45]
[ 1.40129846e-45]
[ 1.40129846e-45]
[ 1.40129846e-45]
[ 0.00000000e+00]
[ 0.00000000e+00]
[ 1.40129846e-45]
[ 1.40129846e-45]
[ 1.40129846e-45]
[ 0.00000000e+00]
[ 0.00000000e+00]
[ 1.40129846e-45]
[ 0.00000000e+00]
[ 1.40129846e-45]
[ 0.00000000e+00]
[ 0.00000000e+00]
[ 0.00000000e+00]
[ 0.00000000e+00]]
`
class CommonPipeline(Pipeline):
def init(self, batch_size, num_threads, device_id, size=(224, 224), crop_size=(224, 224),
mean=IMAGE_MEAN,
std=IMAGE_STD,
channel_format=types.NHWC,
probability=0.5,
device='gpu',
decode_method='in_gpu'):
super(CommonPipeline, self).init(batch_size, num_threads, device_id)
assert device == 'gpu' and decode_method == 'in_gpu'
if decode_method == 'in_gpu':
self.decode = ops.nvJPEGDecoder(device="mixed", output_type=types.RGB)
else:
self.decode = ops.HostDecoder(output_type=types.RGB)
class FileReadPipeline(CommonPipeline):
def init(self,
batch_size,
num_threads,
device_id,
random_shuffle,
file_root='',
file_list='',
size=(224, 224),
crop_size=(224, 224),
mean=IMAGE_MEAN,
std=IMAGE_STD,
channel_format=types.NHWC,
probability=0.5,
device='gpu',
decode_method='in_gpu',
initial_fill=4096):
super(FileReadPipeline, self).init(batch_size=batch_size,
num_threads=num_threads,
device_id=device_id,
size=size,
crop_size=crop_size,
mean=mean,
std=std,
channel_format=channel_format,
probability=probability,
device=device,
decode_method=decode_method)
self.input = ops.FileReader(file_root=file_root, file_list=file_list,
random_shuffle=random_shuffle, initial_fill=initial_fill)
The text was updated successfully, but these errors were encountered: