MCPcopy Create free account
hub / github.com/VisionXLab/OF-Diff / random_crop

Function random_crop

ldm/modules/image_degradation/bsrgan.py:427–435  ·  view source on GitHub ↗
(lq, hq, sf=4, lq_patchsize=64)

Source from the content-addressed store, hash-verified

425
426
427def random_crop(lq, hq, sf=4, lq_patchsize=64):
428 h, w = lq.shape[:2]
429 rnd_h = random.randint(0, h - lq_patchsize)
430 rnd_w = random.randint(0, w - lq_patchsize)
431 lq = lq[rnd_h:rnd_h + lq_patchsize, rnd_w:rnd_w + lq_patchsize, :]
432
433 rnd_h_H, rnd_w_H = int(rnd_h * sf), int(rnd_w * sf)
434 hq = hq[rnd_h_H:rnd_h_H + lq_patchsize * sf, rnd_w_H:rnd_w_H + lq_patchsize * sf, :]
435 return lq, hq
436
437
438def degradation_bsrgan(img, sf=4, lq_patchsize=72, isp_model=None):

Callers 2

degradation_bsrganFunction · 0.70
degradation_bsrgan_plusFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected