MCPcopy Create free account
hub / github.com/tensorflow/models / call

Method call

official/projects/pixel/modeling/pixel.py:99–125  ·  view source on GitHub ↗
(self, inputs)

Source from the content-addressed store, hash-verified

97 return self.token_cls(patch_embeds)
98
99 def call(self, inputs): # pylint:disable=signature-mismatch
100 if isinstance(inputs, dict):
101 images = inputs.get('pixel_values', None)
102 attention_mask = inputs.get('attention_mask', None)
103 attention_mask = tf.transpose(
104 tf.concat(
105 values=[
106 tf.ones((1, tf.shape(attention_mask)[0]), tf.float32),
107 tf.transpose(attention_mask),
108 ],
109 axis=0,
110 )
111 )
112 attention_mask = tf.einsum('ij,ik->ijk', attention_mask, attention_mask)
113 attention_mask = tf.cast(attention_mask, tf.int32)
114 else:
115 raise ValueError('Unexpected inputs type to %s.' % self.__class__)
116
117 images = tf.transpose(images, perm=[0, 2, 3, 1])
118 patch_embeds = self.to_embed(images)
119 patch_shape = tf.shape(patch_embeds)
120 patch_embeds = tf.reshape(
121 patch_embeds, (patch_shape[0], -1, patch_shape[-1])
122 )
123 patch_embeds = self.insert_cls(patch_embeds)
124
125 return self.encoder((patch_embeds, attention_mask))
126
127
128class PixelClassifier(tf_keras.layers.Layer):

Callers

nothing calls this directly

Calls 5

to_embedMethod · 0.95
insert_clsMethod · 0.95
concatMethod · 0.80
encoderMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected