Commit
·
7ff8e0e
1
Parent(s):
ac38ecc
- handler.py +11 -8
handler.py
CHANGED
@@ -8,17 +8,20 @@ from diffusers.utils import load_image
|
|
8 |
|
9 |
import torch
|
10 |
import torch.nn.functional as F
|
11 |
-
|
12 |
|
|
|
13 |
from PIL import Image
|
14 |
|
15 |
-
|
16 |
-
|
17 |
|
18 |
from insightface.app import FaceAnalysis
|
19 |
from pipeline_stable_diffusion_xl_instantid_full import StableDiffusionXLInstantIDPipeline, draw_kps
|
20 |
from controlnet_aux import OpenposeDetector
|
21 |
-
|
|
|
|
|
22 |
|
23 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
24 |
if device.type != 'cuda':
|
@@ -31,7 +34,7 @@ class EndpointHandler():
|
|
31 |
print("Loading model from", model_dir)
|
32 |
|
33 |
face_adapter = f"./checkpoints/ip-adapter.bin"
|
34 |
-
controlnet_path = f"
|
35 |
|
36 |
# transform = Compose([
|
37 |
# Resize(
|
@@ -47,9 +50,9 @@ class EndpointHandler():
|
|
47 |
# PrepareForNet(),
|
48 |
# ])
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
|
54 |
pretrained_model_name_or_path = "wangqixun/YamerMIX_v8"
|
55 |
|
|
|
8 |
|
9 |
import torch
|
10 |
import torch.nn.functional as F
|
11 |
+
from torchvision.transforms import Compose
|
12 |
|
13 |
+
import PIL
|
14 |
from PIL import Image
|
15 |
|
16 |
+
from depth_anything.dpt import DepthAnything
|
17 |
+
from depth_anything.util.transform import Resize, NormalizeImage, PrepareForNet
|
18 |
|
19 |
from insightface.app import FaceAnalysis
|
20 |
from pipeline_stable_diffusion_xl_instantid_full import StableDiffusionXLInstantIDPipeline, draw_kps
|
21 |
from controlnet_aux import OpenposeDetector
|
22 |
+
|
23 |
+
|
24 |
+
# end_test
|
25 |
|
26 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
27 |
if device.type != 'cuda':
|
|
|
34 |
print("Loading model from", model_dir)
|
35 |
|
36 |
face_adapter = f"./checkpoints/ip-adapter.bin"
|
37 |
+
controlnet_path = f"./checkpoints/ControlNetModel"
|
38 |
|
39 |
# transform = Compose([
|
40 |
# Resize(
|
|
|
50 |
# PrepareForNet(),
|
51 |
# ])
|
52 |
|
53 |
+
self.controlnet_identitynet = ControlNetModel.from_pretrained(
|
54 |
+
controlnet_path, torch_dtype=dtype
|
55 |
+
)
|
56 |
|
57 |
pretrained_model_name_or_path = "wangqixun/YamerMIX_v8"
|
58 |
|