def _benchmark_adjust_saturation_in_yiq(self, device, cpu_count): image_shape = [299, 299, 3] warmup_rounds = 100 benchmark_rounds = 1000 config = config_pb2.ConfigProto() if cpu_count is not None: config.inter_op_parallelism_threads = 1 config.intra_op_parallelism_threads = cpu_count with session.Session('', graph=ops.Graph(), config=config) as sess: with ops.device(device): inputs = variables.Variable( random_ops.random_uniform(image_shape, dtype=dtypes.float32) * 255, trainable=False, dtype=dtypes.float32) scale = constant_op.constant(0.1, dtype=dtypes.float32) outputs = distort_image_ops.adjust_hsv_in_yiq(inputs, 0, scale, 1) run_op = control_flow_ops.group(outputs) sess.run(variables.global_variables_initializer()) for _ in xrange(warmup_rounds): sess.run(run_op) start = time.time() for _ in xrange(benchmark_rounds): sess.run(run_op) end = time.time() step_time = (end - start) / benchmark_rounds tag = '%s' % (cpu_count) if cpu_count is not None else '_all' print('benchmarkAdjustSaturationInYiq_299_299_3_cpu%s step_time: %.2f us' % (tag, step_time * 1e6)) self.report_benchmark( name='benchmarkAdjustSaturationInYiq_299_299_3_cpu%s' % (tag), iters=benchmark_rounds, wall_time=step_time)
def _benchmark_adjust_saturation_in_yiq(self, device, cpu_count): image_shape = [299, 299, 3] warmup_rounds = 100 benchmark_rounds = 1000 config = config_pb2.ConfigProto() if cpu_count is not None: config.inter_op_parallelism_threads = 1 config.intra_op_parallelism_threads = cpu_count with session.Session('', graph=ops.Graph(), config=config) as sess: with ops.device(device): inputs = variables.Variable(random_ops.random_uniform( image_shape, dtype=dtypes.float32) * 255, trainable=False, dtype=dtypes.float32) scale = constant_op.constant(0.1, dtype=dtypes.float32) outputs = distort_image_ops.adjust_hsv_in_yiq( inputs, 0, scale, 1) run_op = control_flow_ops.group(outputs) sess.run(variables.global_variables_initializer()) for _ in xrange(warmup_rounds): sess.run(run_op) start = time.time() for _ in xrange(benchmark_rounds): sess.run(run_op) end = time.time() step_time = (end - start) / benchmark_rounds tag = '%s' % (cpu_count) if cpu_count is not None else '_all' print( 'benchmarkAdjustSaturationInYiq_299_299_3_cpu%s step_time: %.2f us' % (tag, step_time * 1e6)) self.report_benchmark( name='benchmarkAdjustSaturationInYiq_299_299_3_cpu%s' % (tag), iters=benchmark_rounds, wall_time=step_time)
def _adjust_hue_in_yiq_tf(self, x_np, delta_h): with self.test_session(use_gpu=True): x = constant_op.constant(x_np) y = distort_image_ops.adjust_hsv_in_yiq(x, delta_h, 1, 1) y_tf = y.eval() return y_tf
def _adjust_saturation_in_yiq_tf(self, x_np, scale): with self.test_session(use_gpu=True): x = constant_op.constant(x_np) y = distort_image_ops.adjust_hsv_in_yiq(x, 0, scale, 1) y_tf = y.eval() return y_tf
def _adjust_hue_in_yiq_tf(self, x_np, delta_h): with self.test_session(use_gpu=True): x = constant_op.constant(x_np) y = distort_image_ops.adjust_hsv_in_yiq(x, delta_h, 1, 1) y_tf = y.eval() return y_tf
def _adjust_saturation_in_yiq_tf(self, x_np, scale): with self.test_session(use_gpu=True): x = constant_op.constant(x_np) y = distort_image_ops.adjust_hsv_in_yiq(x, 0, scale, 1) y_tf = y.eval() return y_tf