Class ImageConverter
java.lang.Object
org.tribuo.interop.tensorflow.ImageConverter
- All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable,com.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>,Serializable,FeatureConverter,ProtoSerializable<org.tribuo.interop.tensorflow.protos.FeatureConverterProto>
Image converter. Assumes the feature id numbers are linearised ids of the form:
[0,0,0] = 0, [0,0,1] = 1, [0,1,0] = k, [1,0,0] = j*k, ..., [i,0,0] = i*j*k,That is, they are in multidimensional row major order (e.g. the order used by
IDXDataSource).- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intProtobuf serialization version.Fields inherited from interface org.tribuo.protos.ProtoSerializable
DESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER -
Constructor Summary
ConstructorsConstructorDescriptionImageConverter(String inputName, int width, int height, int channels) Builds an image converter for images of the supplied size. -
Method Summary
Modifier and TypeMethodDescriptionconvert(List<? extends Example<?>> examples, ImmutableFeatureMap featureIDMap) Transform implicitly pads unseen values with zero.convert(Example<?> example, ImmutableFeatureMap featureIDMap) Transform implicitly pads unseen values with zero.static ImageConverterdeserializeFromProto(int version, String className, com.google.protobuf.Any message) Deserialization factory.booleancom.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenanceinthashCode()Gets a view of the names of the inputs this converter produces.voidUsed by the OLCUT configuration system, and should not be called by external code.org.tribuo.interop.tensorflow.protos.FeatureConverterProtoSerializes this object to a protobuf.toString()
-
Field Details
-
CURRENT_VERSION
public static final int CURRENT_VERSIONProtobuf serialization version.- See Also:
-
-
Constructor Details
-
ImageConverter
Builds an image converter for images of the supplied size.- Parameters:
inputName- The input name.width- The image width.height- The image height.channels- The number of colour channels.
-
-
Method Details
-
postConfig
public void postConfig()Used by the OLCUT configuration system, and should not be called by external code.- Specified by:
postConfigin interfacecom.oracle.labs.mlrg.olcut.config.Configurable
-
deserializeFromProto
public static ImageConverter deserializeFromProto(int version, String className, com.google.protobuf.Any message) throws com.google.protobuf.InvalidProtocolBufferException Deserialization factory.- Parameters:
version- The serialized object version.className- The class name.message- The serialized data.- Returns:
- The deserialized object.
- Throws:
com.google.protobuf.InvalidProtocolBufferException- If the protobuf could not be parsed from themessage.
-
serialize
public org.tribuo.interop.tensorflow.protos.FeatureConverterProto serialize()Description copied from interface:ProtoSerializableSerializes this object to a protobuf.- Specified by:
serializein interfaceProtoSerializable<org.tribuo.interop.tensorflow.protos.FeatureConverterProto>- Returns:
- The protobuf.
-
equals
-
hashCode
-
inputNamesSet
Description copied from interface:FeatureConverterGets a view of the names of the inputs this converter produces.- Specified by:
inputNamesSetin interfaceFeatureConverter- Returns:
- The input names.
-
convert
Transform implicitly pads unseen values with zero.- Specified by:
convertin interfaceFeatureConverter- Parameters:
example- The example to transform.featureIDMap- The feature id mapping to use.- Returns:
- A 4d tensor, (1, width, height, channels) for this example.
-
convert
Transform implicitly pads unseen values with zero.Converts a batch of examples into a Tensor.
- Specified by:
convertin interfaceFeatureConverter- Parameters:
examples- The examples to transform.featureIDMap- The feature id mapping to use.- Returns:
- A 4d tensor, (batch-id, width, height, channels) for this example.
-
convert
Description copied from interface:FeatureConverterConverts aSGDVectorrepresenting the features into aTensorMap.It generates it as a single example minibatch.
- Specified by:
convertin interfaceFeatureConverter- Parameters:
vector- The features to convert.- Returns:
- A TensorMap (similar to a TF Python feed_dict) representing this vector.
-
convert
Description copied from interface:FeatureConverter- Specified by:
convertin interfaceFeatureConverter- Parameters:
vectors- The batch of features to convert.- Returns:
- A TensorMap (similar to a TF Python feed_dict) representing this minibatch.
-
toString
-
getProvenance
public com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance getProvenance()- Specified by:
getProvenancein interfacecom.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>
-