* ini

* i

* i

* i

* i

* i

* i

* Update preprocessor_normalbae.py

* i

* i

* i

* i

* Update README.md

* i

* Update preprocessor_depth.py

* Update shared.py

* Update devices.py

* i

* i

* i

* i

* i

* i

* Update README.md

* i

* Update README.md

* i

* Update annotator_path.py

* i

* i

* Update preprocessor_meta.py
This commit is contained in:
lllyasviel
2024-01-28 15:31:49 -08:00
committed by GitHub
parent 99ea8e62f5
commit 946d7ff260
864 changed files with 141791 additions and 28 deletions

View File

@@ -4,6 +4,7 @@ import os
import time
import random
import string
import cv2
def compute_cond_mark(cond_or_uncond, sigmas):
@@ -79,3 +80,28 @@ def write_images_to_mp4(frame_list: list, filename=None, fps=6):
output.close()
return full_path
def pad64(x):
return int(np.ceil(float(x) / 64.0) * 64 - x)
def safer_memory(x):
# Fix many MAC/AMD problems
return np.ascontiguousarray(x.copy()).copy()
def resize_image_with_pad(img, resolution):
H_raw, W_raw, _ = img.shape
k = float(resolution) / float(min(H_raw, W_raw))
interpolation = cv2.INTER_CUBIC if k > 1 else cv2.INTER_AREA
H_target = int(np.round(float(H_raw) * k))
W_target = int(np.round(float(W_raw) * k))
img = cv2.resize(img, (W_target, H_target), interpolation=interpolation)
H_pad, W_pad = pad64(H_target), pad64(W_target)
img_padded = np.pad(img, [[0, H_pad], [0, W_pad], [0, 0]], mode='edge')
def remove_pad(x):
return safer_memory(x[:H_target, :W_target])
return safer_memory(img_padded), remove_pad