Skip to content

Commit 7846eed

Browse files
committed
[template] Support image list (#5954)
1 parent 1ed2c7c commit 7846eed

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

swift/llm/template/template/kwai.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ def replace_tag(self, media_type: Literal['image', 'video', 'audio'], index: int
3939
return ['<|vision_start|><|image_pad|><|vision_end|>']
4040
else:
4141
video = inputs.videos[index]
42-
if os.path.isdir(video):
43-
video = [os.path.join(video, fname) for fname in os.listdir(video)]
4442
video, video_kwargs = fetch_video({'video': video})
4543
if isinstance(video, torch.Tensor):
4644
video = video.to(torch.uint8)

swift/llm/template/template/qwen.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,6 @@ def replace_tag(self, media_type: Literal['image', 'video', 'audio'], index: int
256256
return ['<|vision_start|><|image_pad|><|vision_end|>']
257257
else:
258258
video = inputs.videos[index]
259-
if os.path.isdir(video):
260-
video = [os.path.join(video, fname) for fname in os.listdir(video)]
261259
video, video_kwargs = fetch_video({'video': video}, return_video_sample_fps=True)
262260
if isinstance(video, torch.Tensor):
263261
video = video.to(torch.uint8)

swift/megatron/utils/convert.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ def convert_hf2mcore(args: ExportArguments) -> None:
235235
del hf_model
236236
logger.info('Successfully transferred HF model weights to MG model.')
237237
args.save_args()
238+
logger.info('Saving the model...')
238239
mg_save_checkpoint(1, [mg_model], None, None, 0)
239240
logger.info(f'Successfully saved Megatron model weights in `{args.output_dir}`.')
240241

@@ -290,6 +291,7 @@ def convert_mcore2hf(args: ExportArguments) -> None:
290291
del mg_model
291292
logger.info('Successfully transferred MG model weights to HF model.')
292293
ckpt_dir = megatron_args.load if megatron_args.adapter_load is None else megatron_args.adapter_load
294+
logger.info('Saving the model...')
293295
save_checkpoint(
294296
hf_model,
295297
processor,
@@ -306,5 +308,6 @@ def convert_mcore2hf(args: ExportArguments) -> None:
306308
patch_torch_dist_shard(args.thread_count)
307309

308310
args.save_args()
311+
logger.info('Saving the model...')
309312
mg_save_checkpoint(1, [mg_model], None, None, 0)
310313
logger.info(f'Successfully saved Megatron model weights in `{args.output_dir}`.')

0 commit comments

Comments
 (0)