Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -14,7 +14,6 @@ from huggingface_hub import hf_hub_download
|
|
14 |
### We use the ckpt of 79999_iter.pth: https://drive.google.com/open?id=154JgKpzCPW82qINcVieuPH3fZ2e0P812
|
15 |
### Thanks for the open source of face-parsing model.
|
16 |
from models.BiSeNet.model import BiSeNet
|
17 |
-
from multiprocessing import Process, Queue, Manager
|
18 |
|
19 |
# zero = torch.Tensor([0]).cuda()
|
20 |
# print(zero.device) # <-- 'cpu' 🤔
|
@@ -37,27 +36,10 @@ pipe = ConsistentIDStableDiffusionPipeline.from_pretrained(
|
|
37 |
).to(device)
|
38 |
|
39 |
### Load other pretrained models
|
40 |
-
@spaces.GPU
|
41 |
-
def load_model(queue, bise_net_cp_path):
|
42 |
-
bise_net = BiSeNet(n_classes = 19)
|
43 |
-
bise_net.to(device)
|
44 |
-
bise_net.load_state_dict(torch.load(bise_net_cp_path))
|
45 |
-
bise_net.eval()
|
46 |
-
queue.put(bise_net)
|
47 |
## BiSenet
|
48 |
-
bise_net_cp_path = hf_hub_download(repo_id="JackAILab/ConsistentID", filename="face_parsing.pth",
|
49 |
-
|
50 |
-
|
51 |
-
# Create a queue to share data between processes
|
52 |
-
queue = manager.Queue()
|
53 |
-
|
54 |
-
# Create a new process and start it
|
55 |
-
p = Process(target=load_model, args=(queue, bise_net_cp_path))
|
56 |
-
p.start()
|
57 |
-
|
58 |
-
# Wait for the process to finish and get the result
|
59 |
-
p.join()
|
60 |
-
bise_net = queue.get()
|
61 |
|
62 |
### Load consistentID_model checkpoint
|
63 |
pipe.load_ConsistentID_model(
|
@@ -66,7 +48,7 @@ pipe.load_ConsistentID_model(
|
|
66 |
subfolder="",
|
67 |
weight_name=os.path.basename(consistentID_path),
|
68 |
trigger_word="img",
|
69 |
-
)
|
70 |
pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config)
|
71 |
|
72 |
|
|
|
14 |
### We use the ckpt of 79999_iter.pth: https://drive.google.com/open?id=154JgKpzCPW82qINcVieuPH3fZ2e0P812
|
15 |
### Thanks for the open source of face-parsing model.
|
16 |
from models.BiSeNet.model import BiSeNet
|
|
|
17 |
|
18 |
# zero = torch.Tensor([0]).cuda()
|
19 |
# print(zero.device) # <-- 'cpu' 🤔
|
|
|
36 |
).to(device)
|
37 |
|
38 |
### Load other pretrained models
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
## BiSenet
|
40 |
+
bise_net_cp_path = hf_hub_download(repo_id="JackAILab/ConsistentID", filename="face_parsing.pth", local_dir="./checkpoints")
|
41 |
+
bise_net = BiSeNet(n_classes = 19)
|
42 |
+
bise_net.load_state_dict(torch.load(self.bise_net_cp, map_location="cpu"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
### Load consistentID_model checkpoint
|
45 |
pipe.load_ConsistentID_model(
|
|
|
48 |
subfolder="",
|
49 |
weight_name=os.path.basename(consistentID_path),
|
50 |
trigger_word="img",
|
51 |
+
).to(device)
|
52 |
pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config)
|
53 |
|
54 |
|