Update handler.py
Browse files- handler.py +16 -14
handler.py
CHANGED
|
@@ -192,6 +192,10 @@ multi_model_list = [
|
|
| 192 |
{"model_id": "jcplus/stable-diffusion-v1-5"},
|
| 193 |
]
|
| 194 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
class EndpointHandler():
|
| 196 |
def __init__(self, path=""):
|
| 197 |
# load the optimized model
|
|
@@ -201,9 +205,7 @@ class EndpointHandler():
|
|
| 201 |
|
| 202 |
lora_style.load(path)
|
| 203 |
|
| 204 |
-
|
| 205 |
-
self.multi_text2image_model={}
|
| 206 |
-
self.multi_image2image_model={}
|
| 207 |
self.path = path
|
| 208 |
|
| 209 |
for model in multi_model_list:
|
|
@@ -215,26 +217,26 @@ class EndpointHandler():
|
|
| 215 |
controlnet = ControlNet()
|
| 216 |
img2img_pipe = Img2Img()
|
| 217 |
text2img_pipe = Text2Img()
|
| 218 |
-
|
| 219 |
controlnet.load(model["model_id"])
|
| 220 |
|
| 221 |
|
| 222 |
-
|
| 223 |
text2img_pipe.load( model["model_id"])
|
| 224 |
|
| 225 |
-
|
| 226 |
img2img_pipe.load( model["model_id"])
|
| 227 |
|
| 228 |
print(" Logs: model[model_id]", model["model_id"])
|
| 229 |
-
print("Logs: multimodel controlnet pipelines are",
|
| 230 |
-
print("Logs: multimodel text2img pipelines are",
|
| 231 |
-
print("Logs: multimodel imgtoimage pipelines are",
|
| 232 |
# controlnet.load(path)
|
| 233 |
# text2img_pipe.load(path)
|
| 234 |
# img2img_pipe.load(path)
|
| 235 |
-
print("Logs: self.multi_image2image_model",
|
| 236 |
-
print("Logs: self.multi_text2image_model",
|
| 237 |
-
print("Logs: self.multi_controlnet_model",
|
| 238 |
print("Logs: model loaded ....")
|
| 239 |
|
| 240 |
|
|
@@ -280,14 +282,14 @@ class EndpointHandler():
|
|
| 280 |
|
| 281 |
try:
|
| 282 |
task_type = task.get_type()
|
| 283 |
-
print("logs post: self.multi_text2image_model[model_id]",
|
| 284 |
if task_type == TaskType.TEXT_TO_IMAGE:
|
| 285 |
# character sheet
|
| 286 |
if "character sheet" in task.get_prompt().lower():
|
| 287 |
print("pose is here")
|
| 288 |
# return pose(task, s3_outkey="", poses=pickPoses())
|
| 289 |
else:
|
| 290 |
-
return text2img(task,
|
| 291 |
# elif task_type == TaskType.IMAGE_TO_IMAGE:
|
| 292 |
# return img2img(task)
|
| 293 |
# elif task_type == TaskType.CANNY:
|
|
|
|
| 192 |
{"model_id": "jcplus/stable-diffusion-v1-5"},
|
| 193 |
]
|
| 194 |
|
| 195 |
+
multi_controlnet_model={}
|
| 196 |
+
multi_text2image_model={}
|
| 197 |
+
multi_image2image_model={}
|
| 198 |
+
|
| 199 |
class EndpointHandler():
|
| 200 |
def __init__(self, path=""):
|
| 201 |
# load the optimized model
|
|
|
|
| 205 |
|
| 206 |
lora_style.load(path)
|
| 207 |
|
| 208 |
+
|
|
|
|
|
|
|
| 209 |
self.path = path
|
| 210 |
|
| 211 |
for model in multi_model_list:
|
|
|
|
| 217 |
controlnet = ControlNet()
|
| 218 |
img2img_pipe = Img2Img()
|
| 219 |
text2img_pipe = Text2Img()
|
| 220 |
+
multi_controlnet_model[model["model_id"]] = controlnet;
|
| 221 |
controlnet.load(model["model_id"])
|
| 222 |
|
| 223 |
|
| 224 |
+
multi_text2image_model[model["model_id"]] = text2img_pipe;
|
| 225 |
text2img_pipe.load( model["model_id"])
|
| 226 |
|
| 227 |
+
multi_image2image_model[model["model_id"]] = img2img_pipe;
|
| 228 |
img2img_pipe.load( model["model_id"])
|
| 229 |
|
| 230 |
print(" Logs: model[model_id]", model["model_id"])
|
| 231 |
+
print("Logs: multimodel controlnet pipelines are", multi_controlnet_model[model["model_id"]])
|
| 232 |
+
print("Logs: multimodel text2img pipelines are", multi_text2image_model[model["model_id"]])
|
| 233 |
+
print("Logs: multimodel imgtoimage pipelines are", multi_image2image_model[model["model_id"]])
|
| 234 |
# controlnet.load(path)
|
| 235 |
# text2img_pipe.load(path)
|
| 236 |
# img2img_pipe.load(path)
|
| 237 |
+
print("Logs: self.multi_image2image_model",multi_image2image_model)
|
| 238 |
+
print("Logs: self.multi_text2image_model",multi_text2image_model)
|
| 239 |
+
print("Logs: self.multi_controlnet_model",multi_controlnet_model)
|
| 240 |
print("Logs: model loaded ....")
|
| 241 |
|
| 242 |
|
|
|
|
| 282 |
|
| 283 |
try:
|
| 284 |
task_type = task.get_type()
|
| 285 |
+
print("logs post: self.multi_text2image_model[model_id]", multi_text2image_model)
|
| 286 |
if task_type == TaskType.TEXT_TO_IMAGE:
|
| 287 |
# character sheet
|
| 288 |
if "character sheet" in task.get_prompt().lower():
|
| 289 |
print("pose is here")
|
| 290 |
# return pose(task, s3_outkey="", poses=pickPoses())
|
| 291 |
else:
|
| 292 |
+
return text2img(task, multi_text2image_model["jayparmr/icbinp"])
|
| 293 |
# elif task_type == TaskType.IMAGE_TO_IMAGE:
|
| 294 |
# return img2img(task)
|
| 295 |
# elif task_type == TaskType.CANNY:
|