Skip to content

Commit

Permalink
remove pytorch lightning
Browse files Browse the repository at this point in the history
  • Loading branch information
brycedrennan committed Jan 2, 2024
1 parent 8824eff commit 819fcb1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
6 changes: 3 additions & 3 deletions imaginairy/img_processors/control_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def create_canny_edges(img: "Tensor") -> "Tensor":
img = torch.clamp((img + 1.0) / 2.0, min=0.0, max=1.0)
img = einops.rearrange(img[0], "c h w -> h w c")
img = (255.0 * img).cpu().numpy().astype(np.uint8).squeeze()
blurred = cv2.GaussianBlur(img, (5, 5), 0).astype(np.uint8)
blurred = cv2.GaussianBlur(img, (5, 5), 0).astype(np.uint8) # type: ignore

if len(blurred.shape) > 2:
blurred = cv2.cvtColor(blurred, cv2.COLOR_BGR2GRAY)
Expand Down Expand Up @@ -143,7 +143,7 @@ def make_noise_disk(H: int, W: int, C: int, F: int) -> "np.ndarray":
import numpy as np

noise = np.random.uniform(low=0, high=1, size=((H // F) + 2, (W // F) + 2, C))
noise = cv2.resize(noise, (W + 2 * F, H + 2 * F), interpolation=cv2.INTER_CUBIC)
noise = cv2.resize(noise, (W + 2 * F, H + 2 * F), interpolation=cv2.INTER_CUBIC) # type: ignore
noise = noise[F : F + H, F : F + W]
noise -= np.min(noise)
noise /= np.max(noise)
Expand All @@ -165,7 +165,7 @@ def shuffle_map_np(img: "np.ndarray", h=None, w=None, f=256) -> "np.ndarray":
x = make_noise_disk(h, w, 1, f) * float(W - 1)
y = make_noise_disk(h, w, 1, f) * float(H - 1)
flow = np.concatenate([x, y], axis=2).astype(np.float32)
return cv2.remap(img, flow, None, cv2.INTER_LINEAR)
return cv2.remap(img, flow, None, cv2.INTER_LINEAR) # type: ignore


def shuffle_map_torch(tensor: "Tensor", h=None, w=None, f=256) -> "Tensor":
Expand Down
2 changes: 1 addition & 1 deletion tests/img_processors/test_control_modes.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import itertools

import pytest
from lightning_fabric import seed_everything

from imaginairy.img_processors.control_modes import CONTROL_MODES, create_depth_map
from imaginairy.modules.midas.api import ISL_PATHS
from imaginairy.schema import LazyLoadingImage
from imaginairy.utils import seed_everything
from imaginairy.utils.img_utils import (
pillow_img_to_torch_image,
torch_img_to_pillow_img,
Expand Down
3 changes: 1 addition & 2 deletions tests/test_enhancers/test_describe_image_blip.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import pytest
from lightning_fabric import seed_everything
from PIL import Image

from imaginairy.enhancers.describe_image_blip import generate_caption
from imaginairy.utils import get_device
from imaginairy.utils import get_device, seed_everything
from tests import TESTS_FOLDER


Expand Down
3 changes: 1 addition & 2 deletions tests/test_enhancers/test_face_restoration_codeformer.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import pytest
from lightning_fabric import seed_everything
from PIL import Image

from imaginairy.enhancers.face_restoration_codeformer import enhance_faces
from imaginairy.utils import get_device
from imaginairy.utils import get_device, seed_everything
from tests import TESTS_FOLDER
from tests.utils import assert_image_similar_to_expectation

Expand Down

0 comments on commit 819fcb1

Please sign in to comment.