MCPcopy Create free account
hub / github.com/Francis-Rings/StableAnimator / encode_image

Function encode_image

train.py:1213–1232  ·  view source on GitHub ↗
(pixel_values)

Source from the content-addressed store, hash-verified

1211 first_epoch = 0
1212
1213 def encode_image(pixel_values):
1214 pixel_values = _resize_with_antialiasing(pixel_values, (224, 224))
1215 pixel_values = (pixel_values + 1.0) / 2.0
1216
1217 pixel_values = pixel_values.to(torch.float32)
1218 # Normalize the image with for CLIP input
1219 pixel_values = feature_extractor(
1220 images=pixel_values,
1221 do_normalize=True,
1222 do_center_crop=False,
1223 do_resize=False,
1224 do_rescale=False,
1225 return_tensors="pt",
1226 ).pixel_values
1227
1228 pixel_values = pixel_values.to(
1229 device=accelerator.device, dtype=image_encoder.dtype)
1230 image_embeddings = image_encoder(pixel_values).image_embeds
1231 image_embeddings= image_embeddings.unsqueeze(1)
1232 return image_embeddings
1233
1234
1235 def _get_add_time_ids(

Callers 1

mainFunction · 0.70

Calls 1

Tested by

no test coverage detected