The book provides code snippets for the computer vision problem set but it seems to be not working for the transform. I mean specifcally the following code:
The TFRecordDataset is a two-feature dataset one containing the raw (JPEG) image and other one contains the label as string (stored also as bytes). It was generated using pretty much the same code shown earlier in the book under the Data Ingestion chapter.
---------------------------------------------------------------------------
InvalidArgumentError Traceback (most recent call last)
~/projects/datadrivers/venv/lib/python3.6/site-packages/tensorflow/python/framework/ops.py in _create_c_op(graph, node_def, inputs, control_inputs, op_def)
1811 try:
-> 1812 c_op = pywrap_tf_session.TF_FinishOperation(op_desc)
1813 except errors.InvalidArgumentError as e:
InvalidArgumentError: Shape must be rank 0 but is rank 1 for '{{node DecodeJpeg}} = DecodeJpeg[acceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false](Reshape)' with input shapes: [?].
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
<ipython-input-38-795928f0e78f> in <module>
5 )
6
----> 7 context.run(transform)
~/projects/datadrivers/venv/lib/python3.6/site-packages/tfx/orchestration/experimental/interactive/interactive_context.py in run_if_ipython(*args, **kwargs)
65 # __IPYTHON__ variable is set by IPython, see
66 # https://ipython.org/ipython-doc/rel-0.10.2/html/interactive/reference.html#embedding-ipython.
---> 67 return fn(*args, **kwargs)
68 else:
69 absl.logging.warning(
~/projects/datadrivers/venv/lib/python3.6/site-packages/tfx/orchestration/experimental/interactive/interactive_context.py in run(self, component, enable_cache, beam_pipeline_args)
175 telemetry_utils.LABEL_TFX_RUNNER: runner_label,
176 }):
--> 177 execution_id = launcher.launch().execution_id
178
179 return execution_result.ExecutionResult(
~/projects/datadrivers/venv/lib/python3.6/site-packages/tfx/orchestration/launcher/base_component_launcher.py in launch(self)
203 execution_decision.input_dict,
204 execution_decision.output_dict,
--> 205 execution_decision.exec_properties)
206
207 absl.logging.info('Running publisher for %s',
~/projects/datadrivers/venv/lib/python3.6/site-packages/tfx/orchestration/launcher/in_process_component_launcher.py in _run_executor(self, execution_id, input_dict, output_dict, exec_properties)
65 executor_context) # type: ignore
66
---> 67 executor.Do(input_dict, output_dict, exec_properties)
~/projects/datadrivers/venv/lib/python3.6/site-packages/tfx/components/transform/executor.py in Do(self, input_dict, output_dict, exec_properties)
388 label_outputs[labels.CACHE_OUTPUT_PATH_LABEL] = cache_output
389 status_file = 'status_file' # Unused
--> 390 self.Transform(label_inputs, label_outputs, status_file)
391 absl.logging.debug('Cleaning up temp path %s on executor success',
392 temp_path)
~/projects/datadrivers/venv/lib/python3.6/site-packages/tfx/components/transform/executor.py in Transform(***failed resolving arguments***)
886 # order to fail faster if it fails.
887 analyze_input_columns = tft.get_analyze_input_columns(
--> 888 preprocessing_fn, typespecs)
889
890 if not compute_statistics and not materialize_output_paths:
~/projects/datadrivers/venv/lib/python3.6/site-packages/tensorflow_transform/inspect_preprocessing_fn.py in get_analyze_input_columns(preprocessing_fn, specs)
56 input_signature = impl_helper.batched_placeholders_from_specs(
57 specs)
---> 58 _ = preprocessing_fn(input_signature.copy())
59
60 tensor_sinks = graph.get_collection(analyzer_nodes.TENSOR_REPLACEMENTS)
~/projects/datadrivers/module.py in preprocessing_fn(inputs)
21 label = inputs['label']
22 label_integerized = tft.compute_and_apply_vocabulary(label)
---> 23 img_preprocessed = process_image(image_raw)
24 return {
25 'img_preprocessed': img_preprocessed,
~/projects/datadrivers/module.py in process_image(raw_image)
5 def process_image(raw_image):
6 raw_image = tf.reshape(raw_image, [-1])
----> 7 img_rgb = tf.io.decode_jpeg(raw_image, channels=3)
8 img_gray = tf.image.rgb_to_grayscale(img_rgb)
9 img = tf.image.convert_image_dtype(img_gray, tf.float32)
~/projects/datadrivers/venv/lib/python3.6/site-packages/tensorflow/python/ops/gen_image_ops.py in decode_jpeg(contents, channels, ratio, fancy_upscaling, try_recover_truncated, acceptable_fraction, dct_method, name)
1101 try_recover_truncated=try_recover_truncated,
1102 acceptable_fraction=acceptable_fraction,
-> 1103 dct_method=dct_method, name=name)
1104 _result = _outputs[:]
1105 if _execute.must_record_gradient():
~/projects/datadrivers/venv/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py in _apply_op_helper(op_type_name, name, **keywords)
742 op = g._create_op_internal(op_type_name, inputs, dtypes=None,
743 name=scope, input_types=input_types,
--> 744 attrs=attr_protos, op_def=op_def)
745
746 # `outputs` is returned as a separate return value so that the output
~/projects/datadrivers/venv/lib/python3.6/site-packages/tensorflow/python/framework/ops.py in _create_op_internal(self, op_type, inputs, dtypes, input_types, name, attrs, op_def, compute_device)
3483 input_types=input_types,
3484 original_op=self._default_original_op,
-> 3485 op_def=op_def)
3486 self._create_op_helper(ret, compute_device=compute_device)
3487 return ret
~/projects/datadrivers/venv/lib/python3.6/site-packages/tensorflow/python/framework/ops.py in __init__(self, node_def, g, inputs, output_types, control_inputs, input_types, original_op, op_def)
1973 op_def = self._graph._get_op_def(node_def.op)
1974 self._c_op = _create_c_op(self._graph, node_def, inputs,
-> 1975 control_input_ops, op_def)
1976 name = compat.as_str(node_def.name)
1977 # pylint: enable=protected-access
~/projects/datadrivers/venv/lib/python3.6/site-packages/tensorflow/python/framework/ops.py in _create_c_op(graph, node_def, inputs, control_inputs, op_def)
1813 except errors.InvalidArgumentError as e:
1814 # Convert to ValueError for backwards compatibility.
-> 1815 raise ValueError(str(e))
1816
1817 return c_op
ValueError: Shape must be rank 0 but is rank 1 for '{{node DecodeJpeg}} = DecodeJpeg[acceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false](Reshape)' with input shapes: [?].