formatting
Browse files- handler.py +14 -7
handler.py
CHANGED
@@ -29,9 +29,19 @@ class EndpointHandler:
|
|
29 |
repo_id="SvenN/sdxl-emoji", filename="embeddings.pti", repo_type="model"
|
30 |
)
|
31 |
state_dict = load_file(embedding_path)
|
32 |
-
|
33 |
-
self.pipe.load_textual_inversion(
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
def __call__(self, data: Any) -> List[List[Dict[str, float]]]:
|
37 |
"""
|
@@ -44,10 +54,7 @@ class EndpointHandler:
|
|
44 |
inputs = data.pop("inputs", data)
|
45 |
|
46 |
# Automatically add trigger tokens to the beginning of the prompt
|
47 |
-
images = self.pipe(
|
48 |
-
inputs,
|
49 |
-
**data['parameters']
|
50 |
-
).images
|
51 |
image = images[0]
|
52 |
|
53 |
return image
|
|
|
29 |
repo_id="SvenN/sdxl-emoji", filename="embeddings.pti", repo_type="model"
|
30 |
)
|
31 |
state_dict = load_file(embedding_path)
|
32 |
+
|
33 |
+
self.pipe.load_textual_inversion(
|
34 |
+
state_dict["text_encoders_0"],
|
35 |
+
token=["<s0>", "<s1>"],
|
36 |
+
text_encoder=self.pipe.text_encoder,
|
37 |
+
tokenizer=self.pipe.tokenizer,
|
38 |
+
)
|
39 |
+
self.pipe.load_textual_inversion(
|
40 |
+
state_dict["text_encoders_1"],
|
41 |
+
token=["<s0>", "<s1>"],
|
42 |
+
text_encoder=self.pipe.text_encoder_2,
|
43 |
+
tokenizer=self.pipe.tokenizer_2,
|
44 |
+
)
|
45 |
|
46 |
def __call__(self, data: Any) -> List[List[Dict[str, float]]]:
|
47 |
"""
|
|
|
54 |
inputs = data.pop("inputs", data)
|
55 |
|
56 |
# Automatically add trigger tokens to the beginning of the prompt
|
57 |
+
images = self.pipe(inputs, **data["parameters"]).images
|
|
|
|
|
|
|
58 |
image = images[0]
|
59 |
|
60 |
return image
|