Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions configs/flux2_klein/flux2_klein_i2i_edit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"model_cls": "flux2_klein",
"task": "i2i",
"task_variant": "edit",
"infer_steps": 40,
"sample_guide_scale": 4.0,
"vae_scale_factor": 16,
"feature_caching": "None",
"enable_cfg": true,
"patch_size": 2,
"tokenizer_max_length": 512,
"rope_type": "flashinfer"
}
16 changes: 16 additions & 0 deletions configs/flux2_klein/flux2_klein_i2i_edit_cfg_parallel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"model_cls": "flux2_klein",
"task": "i2i",
"task_variant": "edit",
"infer_steps": 40,
"sample_guide_scale": 4.0,
"vae_scale_factor": 16,
"feature_caching": "None",
"enable_cfg": true,
"patch_size": 2,
"tokenizer_max_length": 512,
"rope_type": "flashinfer",
"parallel": {
"cfg_p_size": 2
}
}
5 changes: 2 additions & 3 deletions lightx2v/models/schedulers/flux2_klein/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ def prepare_i2i(self, input_info, input_image, vae):

image_latents = []
for img in input_image:
imagge_latent = self._encode_image(img)
image_latents.append(imagge_latent)
image_latent = self._encode_image(img)
image_latents.append(image_latent)

if "task_variant" in self.config:
self.task_variant = self.config["task_variant"]
Expand All @@ -180,7 +180,6 @@ def prepare_i2i(self, input_info, input_image, vae):

ref_img_latent = self._pack_latents(ref_img_latent).squeeze(0)
ref_img_latent = ref_img_latent.unsqueeze(0).to(AI_DEVICE, dtype=self.dtype)

self.latents = (1 - self.sigmas[0]) * ref_img_latent + self.sigmas[0] * self.latents

image_latent_ids = self._prepare_image_ids(image_latents, scale=10)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
lightx2v_path=
lightx2v_path=/mnt/miaohua/wangshankun/LightX2V
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

脚本中硬编码了绝对路径 /mnt/miaohua/wangshankun/LightX2V。这会导致脚本在其他开发者的环境下无法直接运行。建议将其设置为相对路径或保留为空,以提高脚本的可移植性。

Suggested change
lightx2v_path=/mnt/miaohua/wangshankun/LightX2V
lightx2v_path=

model_path="/data/temp/black-forest-labs/FLUX.2-klein-9B"
export CUDA_VISIBLE_DEVICES=0

Expand Down
15 changes: 15 additions & 0 deletions scripts/flux2_klein/infer_flux2_klein_i2i_maskedit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
lightx2v_path=
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

lightx2v_path 被设置为空字符串,这会导致后续的路径拼接(如第 6 行的 source 命令和第 15 行的 --config_json)指向系统根目录(如 /scripts/...),这通常会因为路径不存在而导致脚本运行失败。建议将其默认值设置为 . 或在使用前进行有效性检查。

Suggested change
lightx2v_path=
lightx2v_path=.

model_path="/data/temp/black-forest-labs/FLUX.2-klein-9B"
export CUDA_VISIBLE_DEVICES=0

source ${lightx2v_path}/scripts/base/base.sh

python -m lightx2v.infer \
--model_cls flux2_klein \
--task i2i \
--model_path $model_path \
--prompt "A clean ppt background, without text" \
--image_path "${lightx2v_path}/assets/inputs/imgs/mask_edit" \
--save_result_path "${lightx2v_path}/save_results/flux2_klein_i2i_mask_edit.png" \
--config_json "${lightx2v_path}/configs/flux2_klein/flux2_klein_i2i_edit.json"
15 changes: 15 additions & 0 deletions scripts/flux2_klein/infer_flux2_klein_i2i_maskedit_cfg_parallel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
lightx2v_path=
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

lightx2v_path 为空会导致脚本尝试访问根目录下的文件(如 /scripts/base/base.sh),建议设置合理的默认值(如 .)以确保脚本在仓库根目录下运行时能够正确找到相关文件。

Suggested change
lightx2v_path=
lightx2v_path=.

model_path="/data/temp/black-forest-labs/FLUX.2-klein-9B"
export CUDA_VISIBLE_DEVICES=0,1

source ${lightx2v_path}/scripts/base/base.sh

torchrun --nproc_per_node=2 -m lightx2v.infer \
--model_cls flux2_klein \
--task i2i \
--model_path $model_path \
--prompt "A clean ppt background, without text" \
--image_path "${lightx2v_path}/assets/inputs/imgs/mask_edit" \
--save_result_path "${lightx2v_path}/save_results/flux2_klein_i2i_mask_edit.png" \
--config_json "${lightx2v_path}/configs/flux2_klein/flux2_klein_i2i_edit_cfg_parallel.json"
Loading