feat(新功能):
fix(修复bug): docs(文档变更): refactor(重构): test(增加测试): 旧版product 测试
This commit is contained in:
@@ -247,6 +247,9 @@ class GenerateProductImage:
|
||||
self.redis_client.set(self.tasks_id, json.dumps(self.gen_product_data))
|
||||
else:
|
||||
# pil图像转成numpy数组
|
||||
if self.product_type == "single":
|
||||
image = result.as_numpy("generated_cnet_image")
|
||||
else:
|
||||
image = result.as_numpy("generated_inpaint_image")
|
||||
image_result = Image.fromarray(np.squeeze(image.astype(np.uint8)))
|
||||
# cropped_image = post_processing_image(image_result, self.left, self.top)
|
||||
@@ -269,9 +272,9 @@ class GenerateProductImage:
|
||||
images = [self.image.astype(np.uint8)] * self.batch_size
|
||||
|
||||
if self.product_type == "single":
|
||||
text_obj = np.array(prompts, dtype="object").reshape(-1, 1)
|
||||
image_obj = np.array(images, dtype=np.uint8).reshape((-1, 1024, 1024, 3))
|
||||
image_strength_obj = np.array(self.image_strength, dtype=np.float32).reshape(-1, 1)
|
||||
text_obj = np.array(prompts, dtype="object").reshape((-1, 1))
|
||||
image_obj = np.array(images, dtype=np.uint8).reshape((-1, 768, 512, 3))
|
||||
image_strength_obj = np.array(self.image_strength, dtype=np.float32).reshape((-1, 1))
|
||||
else:
|
||||
text_obj = np.array(prompts, dtype="object").reshape((1))
|
||||
image_obj = np.array(images, dtype=np.uint8).reshape((768, 512, 3))
|
||||
@@ -290,7 +293,7 @@ class GenerateProductImage:
|
||||
inputs = [input_text, input_image, input_image_strength]
|
||||
|
||||
if self.product_type == "single":
|
||||
ctx = self.grpc_client.async_infer(model_name="stable_diffusion_xl_cnet_inpaint", inputs=inputs, callback=self.callback)
|
||||
ctx = self.grpc_client.async_infer(model_name="stable_diffusion_1_5_cnet", inputs=inputs, callback=self.callback)
|
||||
else:
|
||||
ctx = self.grpc_client.async_infer(model_name="diffusion_ensemble_all", inputs=inputs, callback=self.callback)
|
||||
|
||||
@@ -369,8 +372,8 @@ if __name__ == '__main__':
|
||||
# prompt="",
|
||||
image_strength=0.7,
|
||||
prompt="The best quality, masterpiece, real image.,high quality clothing details,8K realistic,HDR",
|
||||
image_url="aida-users/11633/toProductImageElement/46166c36-c584-4e0f-b9fe-50615ec03ef3.png",
|
||||
product_type="overall"
|
||||
image_url="aida-results/result_40c7924e-e220-11ef-8ea2-0242ac150003.png",
|
||||
product_type="single"
|
||||
)
|
||||
server = GenerateProductImage(rd)
|
||||
print(server.get_result())
|
||||
|
||||
Reference in New Issue
Block a user