forked from lllyasviel/ControlNet-v1-1-nightly
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7525266
commit 9c16a2a
Showing
7 changed files
with
47 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,28 @@ | ||
import cv2 | ||
import numpy as np | ||
from annotator.util import make_noise_disk | ||
from annotator.util import make_noise_disk, min_max_norm | ||
|
||
|
||
class ShuffleDetector: | ||
class ContentShuffleDetector: | ||
def __call__(self, img): | ||
H, W, C = img.shape | ||
F = 256 | ||
x = make_noise_disk(H, W, 1, F) * float(W - 1) | ||
y = make_noise_disk(H, W, 1, F) * float(H - 1) | ||
flow = np.stack([x, y], axis=2).astype(np.float32) | ||
return cv2.remap(img, flow, None, cv2.INTER_LINEAR) | ||
|
||
|
||
class ColorShuffleDetector: | ||
def __call__(self, img): | ||
H, W, C = img.shape | ||
F = 256 | ||
A = make_noise_disk(H, W, 3, F) | ||
B = make_noise_disk(H, W, 3, F) | ||
C = (A + B) / 2.0 | ||
A = (C + (A - C) * 2.0).clip(0, 1) | ||
B = (C + (B - C) * 2.0).clip(0, 1) | ||
L = img.astype(np.float32) / 255.0 | ||
Y = A * L + B * (1 - L) | ||
Y = min_max_norm(Y) * 255.0 | ||
return Y.clip(0, 255).astype(np.uint8) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters