@@ -93,14 +93,15 @@ class FluxKleinAPI(ls.LitAPI):
|
|||||||
W = request.get("width", 512)
|
W = request.get("width", 512)
|
||||||
H = request.get("height", 512)
|
H = request.get("height", 512)
|
||||||
images = []
|
images = []
|
||||||
for path in input_image_paths:
|
if input_image_paths:
|
||||||
bucket, *rest = path.split("/", 1) # 拆分为 ["test", "typical_b/uildi/ng_space_station.png"]
|
for path in input_image_paths:
|
||||||
object_name = rest[0] if rest else ""
|
bucket, *rest = path.split("/", 1)
|
||||||
image = oss_get_image(oss_client=minio_client, bucket=bucket, object_name=object_name)
|
object_name = rest[0] if rest else ""
|
||||||
images.append(image)
|
image = oss_get_image(oss_client=minio_client, bucket=bucket, object_name=object_name)
|
||||||
|
images.append(image)
|
||||||
return {
|
return {
|
||||||
"bucket_name": request.get("bucket_name", None),
|
"bucket_name": request.get("bucket_name", "test"),
|
||||||
"object_name": request.get("object_name", None),
|
"object_name": request.get("object_name", f"fida_generate_image/{uuid.uuid4().hex}.png"),
|
||||||
"images": images,
|
"images": images,
|
||||||
"prompt": request.get("prompt", ""),
|
"prompt": request.get("prompt", ""),
|
||||||
"steps": request.get("steps", 4),
|
"steps": request.get("steps", 4),
|
||||||
@@ -115,15 +116,14 @@ class FluxKleinAPI(ls.LitAPI):
|
|||||||
# 3. 执行推理逻辑
|
# 3. 执行推理逻辑
|
||||||
images = payload.get("images", [])
|
images = payload.get("images", [])
|
||||||
prompt = payload.get("prompt", "")
|
prompt = payload.get("prompt", "")
|
||||||
W, H = aspect_to_wh(payload["aspect_ratio"], payload["base_long_edge"])
|
|
||||||
gen = torch.Generator(device=self.device)
|
gen = torch.Generator(device=self.device)
|
||||||
output = {}
|
output = {}
|
||||||
if images:
|
if images:
|
||||||
output['im'] = self.pipe(
|
output['im'] = self.pipe(
|
||||||
image=images,
|
image=images,
|
||||||
prompt=prompt,
|
prompt=prompt,
|
||||||
height=H,
|
height=payload.get("height", 512),
|
||||||
width=W,
|
width=payload.get("width", 512),
|
||||||
guidance_scale=payload["guidance"],
|
guidance_scale=payload["guidance"],
|
||||||
num_inference_steps=payload["steps"],
|
num_inference_steps=payload["steps"],
|
||||||
generator=gen,
|
generator=gen,
|
||||||
@@ -131,8 +131,8 @@ class FluxKleinAPI(ls.LitAPI):
|
|||||||
else:
|
else:
|
||||||
output = self.pipe(
|
output = self.pipe(
|
||||||
prompt=prompt,
|
prompt=prompt,
|
||||||
height=H,
|
height=payload.get("height", 512),
|
||||||
width=W,
|
width=payload.get("width", 512),
|
||||||
guidance_scale=payload["guidance"],
|
guidance_scale=payload["guidance"],
|
||||||
num_inference_steps=payload["steps"],
|
num_inference_steps=payload["steps"],
|
||||||
generator=gen,
|
generator=gen,
|
||||||
|
|||||||
@@ -61,8 +61,7 @@ def oss_upload_image(oss_client, bucket, object_name, image_bytes):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
url = "fida-test/furniture/sketches/4449a66d-6267-43f7-86a2-1e42bd19ec61.png"
|
url = "test/fida_generate_image/692932cfecd9499688899812737a369c.png"
|
||||||
read_type = "2"
|
img = oss_get_image(oss_client=minio_client, bucket=url.split('/')[0], object_name=url[url.find('/') + 1:])
|
||||||
img = oss_get_image(oss_client=minio_client, bucket=url.split('/')[0], object_name=url[url.find('/') + 1:], data_type=read_type)
|
|
||||||
img.show()
|
img.show()
|
||||||
img.save("result.png")
|
img.save("result.png")
|
||||||
|
|||||||
Reference in New Issue
Block a user