-
Notifications
You must be signed in to change notification settings - Fork 86
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
Showing
9 changed files
with
175 additions
and
20 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from modules.processing import StableDiffusionProcessingImg2Img | ||
from PIL import Image | ||
|
||
from scripts.entities.face import Face | ||
from scripts.use_cases.face_processor import FaceProcessor | ||
from scripts.use_cases.image_processing_util import rotate_image | ||
|
||
|
||
class RotateFaceProcessor(FaceProcessor): | ||
def name(self) -> str: | ||
return "Rotate" | ||
|
||
def process(self, face: Face, p: StableDiffusionProcessingImg2Img, angle: float = 0, **kwargs) -> Image: | ||
return rotate_image(face.image, angle) |
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 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import cv2 | ||
import numpy as np | ||
from PIL import Image | ||
|
||
|
||
def rotate_image(image: Image, angle: float) -> Image: | ||
if angle == 0: | ||
return image | ||
return Image.fromarray(rotate_array(np.array(image), angle)) | ||
|
||
|
||
def rotate_array(image: np.ndarray, angle: float) -> np.ndarray: | ||
if angle == 0: | ||
return image | ||
|
||
h, w = image.shape[:2] | ||
center = (w // 2, h // 2) | ||
|
||
M = cv2.getRotationMatrix2D(center, angle, 1.0) | ||
return cv2.warpAffine(image, M, (w, h)) |
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 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