MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / process_image

Function process_image

diffusers/examples/amused/train_amused.py:379–399  ·  view source on GitHub ↗
(image, size)

Source from the content-addressed store, hash-verified

377
378
379def process_image(image, size):
380 image = exif_transpose(image)
381
382 if not image.mode == "RGB":
383 image = image.convert("RGB")
384
385 orig_height = image.height
386 orig_width = image.width
387
388 image = transforms.Resize(size, interpolation=transforms.InterpolationMode.BILINEAR)(image)
389
390 c_top, c_left, _, _ = transforms.RandomCrop.get_params(image, output_size=(size, size))
391 image = transforms.functional.crop(image, c_top, c_left, size, size)
392
393 image = transforms.ToTensor()(image)
394
395 micro_conds = torch.tensor(
396 [orig_width, orig_height, c_top, c_left, 6.0],
397 )
398
399 return {"image": image, "micro_conds": micro_conds}
400
401
402def tokenize_prompt(tokenizer, prompt):

Callers 3

__getitem__Method · 0.85
__init__Method · 0.85
__getitem__Method · 0.85

Calls 1

cropMethod · 0.45

Tested by

no test coverage detected