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