魔搭ModelScope社区 2024年12月09日
魔搭社区每周速递(12.01-12.07)
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

魔搭ModelScope社区近期更新了1338个模型,包括HunyuanVideo、InternVL2.5系列等,新增82个数据集,如OpenO1-SFT、LLaVA-CoT-o1-Instruct等,以及26个创新应用,如OminiControl、Hallo等.此外,社区还发布了8篇技术文章,内容涵盖NexaAI、魔搭AIGC12月赛题、免费模型推理API、2024“AI+硬件创新大赛”获奖名单、腾讯开源混元视频生成模型、金融行业大模型挑战赛、智源研究院中文高质量数据集CCI3.0-HQ技术报告以及用OpenVINO™部署GLM-Edge全家桶.

🎞️HunyuanVideo是腾讯开源的一个具有超过130亿参数的先进开源视频生成模型,它通过集成数据管理、图像-视频联合训练和高效基础设施的综合框架,以及有效的模型架构和数据集扩展策略,实现了高视觉质量、运动多样性、文本-视频对齐和生成稳定性。

🖼️InternVL 2.5是上海人工智能实验室开源的一个先进的多模态大型语言模型(MLLM)系列,基于InternVL 2.0的核心模型架构,在训练、测试策略以及数据质量方面作显著增强,通过对包括多学科推理、文档理解、多图像/视频理解、现实世界理解、多模态幻觉检测、视觉锚定、多语言能力和纯语言处理等广泛基准的深入评估,是第一个在MMMU基准上超过70%的开源MLLM。

💻社区发布了8篇技术文章,内容涵盖了NexaAI、魔搭AIGC12月赛题、免费模型推理API、2024“AI+硬件创新大赛”获奖名单、腾讯开源混元视频生成模型、金融行业大模型挑战赛、智源研究院中文高质量数据集CCI3.0-HQ技术报告以及用OpenVINO™部署GLM-Edge全家桶。

👨‍💻魔搭ModelScope社区近期更新了1338个模型,新增82个数据集以及26个创新应用,为开发者提供了丰富的资源和工具。

🏆2024“AI+硬件创新大赛”获奖名单出炉,浙大、上交与复旦联队等夺冠,展示了高校在AI领域的创新实力。

2024-12-08 22:34 浙江

1338模型、82数据集、26创新应用、8篇文章

?魔搭ModelScope本期社区进展:

?1338个模型:HunyuanVideo、InternVL2.5系列TeleChat2系列、AWPortraitCNfish-speech-1.5、Mistral-Nemo-Instruct-2407-FP等;

?82个数据集:OpenO1-SFT、LLaVA-CoT-o1-Instruct、LLaVA-CoT-100k等;

?26个创新应用OminiControl、Hallo、HunyuanVideo等

? 8内容:


01


精选模型


HunyuanVideo

HunyuanVideo是腾讯开源的一个具有超过130亿参数的先进开源视频生成模型,它通过集成数据管理、图像-视频联合训练和高效基础设施的综合框架,以及有效的模型架构和数据集扩展策略,实现了高视觉质量、运动多样性、文本-视频对齐和生成稳定性


模型链接:

https://modelscope.cn/models/AI-ModelScope/HunyuanVideo


代码示例:

详见 腾讯开源混元视频生成模型,这效果!太稳了吧!


InternVL2.5系列

InternVL 2.5是上海人工智能实验室开源的一个先进的多模态大型语言模型(MLLM)系列,基于InternVL 2.0的核心模型架构,在训练、测试策略以及数据质量方面作显著增强,通过对包括多学科推理、文档理解、多图像/视频理解、现实世界理解、多模态幻觉检测、视觉锚定、多语言能力和纯语言处理等广泛基准的深入评估,是第一个在MMMU基准上超过70%的开源MLLM。


模型链接:

https://www.modelscope.cn/models/OpenGVLab/InternVL2_5-1B/summary


https://www.modelscope.cn/models/OpenGVLab/InternVL2_5-2B


https://www.modelscope.cn/models/OpenGVLab/InternVL2_5-4B


https://www.modelscope.cn/models/OpenGVLab/InternVL2_5-8B


https://www.modelscope.cn/models/OpenGVLab/InternVL2_5-26B


https://www.modelscope.cn/models/OpenGVLab/InternVL2_5-38B


https://www.modelscope.cn/models/OpenGVLab/InternVL2_5-78B


代码示例:

transformers推理代码(以InternVL2_5-4B推理为例):

import numpy as npimport torchimport torchvision.transforms as Tfrom decord import VideoReader, cpufrom PIL import Imagefrom torchvision.transforms.functional import InterpolationModefrom modelscope import AutoModel, AutoTokenizer
IMAGENET_MEAN = (0.485, 0.456, 0.406)IMAGENET_STD = (0.229, 0.224, 0.225)
def build_transform(input_size): MEAN, STD = IMAGENET_MEAN, IMAGENET_STD transform = T.Compose([ T.Lambda(lambda img: img.convert('RGB') if img.mode != 'RGB' else img), T.Resize((input_size, input_size), interpolation=InterpolationMode.BICUBIC), T.ToTensor(), T.Normalize(mean=MEAN, std=STD) ]) return transform
def find_closest_aspect_ratio(aspect_ratio, target_ratios, width, height, image_size): best_ratio_diff = float('inf') best_ratio = (1, 1) area = width * height for ratio in target_ratios: target_aspect_ratio = ratio[0] / ratio[1] ratio_diff = abs(aspect_ratio - target_aspect_ratio) if ratio_diff < best_ratio_diff: best_ratio_diff = ratio_diff best_ratio = ratio elif ratio_diff == best_ratio_diff: if area > 0.5 * image_size * image_size * ratio[0] * ratio[1]: best_ratio = ratio return best_ratio
def dynamic_preprocess(image, min_num=1, max_num=12, image_size=448, use_thumbnail=False): orig_width, orig_height = image.size aspect_ratio = orig_width / orig_height
# calculate the existing image aspect ratio target_ratios = set( (i, j) for n in range(min_num, max_num + 1) for i in range(1, n + 1) for j in range(1, n + 1) if i * j <= max_num and i * j >= min_num) target_ratios = sorted(target_ratios, key=lambda x: x[0] * x[1])
# find the closest aspect ratio to the target target_aspect_ratio = find_closest_aspect_ratio( aspect_ratio, target_ratios, orig_width, orig_height, image_size)
# calculate the target width and height target_width = image_size * target_aspect_ratio[0] target_height = image_size * target_aspect_ratio[1] blocks = target_aspect_ratio[0] * target_aspect_ratio[1]
# resize the image resized_img = image.resize((target_width, target_height)) processed_images = [] for i in range(blocks): box = ( (i % (target_width // image_size)) * image_size, (i // (target_width // image_size)) * image_size, ((i % (target_width // image_size)) + 1) * image_size, ((i // (target_width // image_size)) + 1) * image_size ) # split the image split_img = resized_img.crop(box) processed_images.append(split_img) assert len(processed_images) == blocks if use_thumbnail and len(processed_images) != 1: thumbnail_img = image.resize((image_size, image_size)) processed_images.append(thumbnail_img) return processed_images
def load_image(image_file, input_size=448, max_num=12): image = Image.open(image_file).convert('RGB') transform = build_transform(input_size=input_size) images = dynamic_preprocess(image, image_size=input_size, use_thumbnail=True, max_num=max_num) pixel_values = [transform(image) for image in images] pixel_values = torch.stack(pixel_values) return pixel_values
# If you want to load a model using multiple GPUs, please refer to the `Multiple GPUs` section.path = 'OpenGVLab/InternVL2_5-4B'model = AutoModel.from_pretrained( path, torch_dtype=torch.bfloat16, low_cpu_mem_usage=True, use_flash_attn=True, trust_remote_code=True).eval().cuda()tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True, use_fast=False)
# set the max number of tiles in `max_num`pixel_values = load_image('./awesome.png', max_num=12).to(torch.bfloat16).cuda()generation_config = dict(max_new_tokens=1024, do_sample=True)
# pure-text conversation (纯文本对话)question = 'Hello, who are you?'response, history = model.chat(tokenizer, None, question, generation_config, history=None, return_history=True)print(f'User: {question}\nAssistant: {response}')
question = 'Can you tell me a story?'response, history = model.chat(tokenizer, None, question, generation_config, history=history, return_history=True)print(f'User: {question}\nAssistant: {response}')
# single-image single-round conversation (单图单轮对话)question = '<image>\nPlease describe the image shortly.'response = model.chat(tokenizer, pixel_values, question, generation_config)print(f'User: {question}\nAssistant: {response}')
# single-image multi-round conversation (单图多轮对话)question = '<image>\nPlease describe the image in detail.'response, history = model.chat(tokenizer, pixel_values, question, generation_config, history=None, return_history=True)print(f'User: {question}\nAssistant: {response}')
question = 'Please write a poem according to the image.'response, history = model.chat(tokenizer, pixel_values, question, generation_config, history=history, return_history=True)print(f'User: {question}\nAssistant: {response}')
# multi-image multi-round conversation, combined images (多图多轮对话,拼接图像)pixel_values1 = load_image('./awesome.png', max_num=12).to(torch.bfloat16).cuda()pixel_values2 = load_image('./noword.jpg', max_num=12).to(torch.bfloat16).cuda()pixel_values = torch.cat((pixel_values1, pixel_values2), dim=0)
question = '<image>\nDescribe the two images in detail.'response, history = model.chat(tokenizer, pixel_values, question, generation_config, history=None, return_history=True)print(f'User: {question}\nAssistant: {response}')
question = 'What are the similarities and differences between these two images.'response, history = model.chat(tokenizer, pixel_values, question, generation_config, history=history, return_history=True)print(f'User: {question}\nAssistant: {response}')
# multi-image multi-round conversation, separate images (多图多轮对话,独立图像)pixel_values1 = load_image('./awesome.png', max_num=12).to(torch.bfloat16).cuda()pixel_values2 = load_image('./noword.jpg', max_num=12).to(torch.bfloat16).cuda()pixel_values = torch.cat((pixel_values1, pixel_values2), dim=0)num_patches_list = [pixel_values1.size(0), pixel_values2.size(0)]
question = 'Image-1: <image>\nImage-2: <image>\nDescribe the two images in detail.'response, history = model.chat(tokenizer, pixel_values, question, generation_config, num_patches_list=num_patches_list, history=None, return_history=True)print(f'User: {question}\nAssistant: {response}')
question = 'What are the similarities and differences between these two images.'response, history = model.chat(tokenizer, pixel_values, question, generation_config, num_patches_list=num_patches_list, history=history, return_history=True)print(f'User: {question}\nAssistant: {response}')
# batch inference, single image per sample (单图批处理)pixel_values1 = load_image('./awesome.png', max_num=12).to(torch.bfloat16).cuda()pixel_values2 = load_image('./noword.jpg', max_num=12).to(torch.bfloat16).cuda()num_patches_list = [pixel_values1.size(0), pixel_values2.size(0)]pixel_values = torch.cat((pixel_values1, pixel_values2), dim=0)
questions = ['<image>\nDescribe the image in detail.'] * len(num_patches_list)responses = model.batch_chat(tokenizer, pixel_values, num_patches_list=num_patches_list, questions=questions, generation_config=generation_config)for question, response in zip(questions, responses): print(f'User: {question}\nAssistant: {response}')
# video multi-round conversation (视频多轮对话)def get_index(bound, fps, max_frame, first_idx=0, num_segments=32): if bound: start, end = bound[0], bound[1] else: start, end = -100000, 100000 start_idx = max(first_idx, round(start * fps)) end_idx = min(round(end * fps), max_frame) seg_size = float(end_idx - start_idx) / num_segments frame_indices = np.array([ int(start_idx + (seg_size / 2) + np.round(seg_size * idx)) for idx in range(num_segments) ]) return frame_indices
def load_video(video_path, bound=None, input_size=448, max_num=1, num_segments=32): vr = VideoReader(video_path, ctx=cpu(0), num_threads=1) max_frame = len(vr) - 1 fps = float(vr.get_avg_fps())
pixel_values_list, num_patches_list = [], [] transform = build_transform(input_size=input_size) frame_indices = get_index(bound, fps, max_frame, first_idx=0, num_segments=num_segments) for frame_index in frame_indices: img = Image.fromarray(vr[frame_index].asnumpy()).convert('RGB') img = dynamic_preprocess(img, image_size=input_size, use_thumbnail=True, max_num=max_num) pixel_values = [transform(tile) for tile in img] pixel_values = torch.stack(pixel_values) num_patches_list.append(pixel_values.shape[0]) pixel_values_list.append(pixel_values) pixel_values = torch.cat(pixel_values_list) return pixel_values, num_patches_list
video_path = './showcase.mp4'pixel_values, num_patches_list = load_video(video_path, num_segments=8, max_num=1)pixel_values = pixel_values.to(torch.bfloat16).cuda()video_prefix = ''.join([f'Frame{i+1}: <image>\n' for i in range(len(num_patches_list))])question = video_prefix + 'What is the red panda doing?'# Frame1: <image>\nFrame2: <image>\n...\nFrame8: <image>\n{question}response, history = model.chat(tokenizer, pixel_values, question, generation_config, num_patches_list=num_patches_list, history=None, return_history=True)print(f'User: {question}\nAssistant: {response}')
question = 'Describe this video in detail. Don\'t repeat.'response, history = model.chat(tokenizer, pixel_values, question, generation_config, num_patches_list=num_patches_list, history=history, return_history=True)print(f'User: {question}\nAssistant: {response}')


 TeleChat2

星辰语义大模型TeleChat2是由中国电信人工智能研究院研发训练的大语言模型。


TeleChat2系列模型包括TeleChat2-3B、TeleChat2-7B、TeleChat2-35B和TeleChat2-115B,具备显著的工具调用功能和优化的Function Call表现,相较同尺寸模型在多个榜单中表现优异。


该系列在训练数据和方法方面进行了全面改进,通用问答及逻辑推理等能力较前代提升超过29%。所有模型均在国产算力和深度学习框架上训练,保障了自主可控性。通过优化MP、PP、SP实现和长文训练技术,提升了模型性能和训练速度。

模型链接:

https://modelscope.cn/models/TeleAI/TeleChat2-3B


https://modelscope.cn/models/TeleAI/TeleChat2-7B


https://modelscope.cn/models/TeleAI/TeleChat2-35B-Nov


https://modelscope.cn/models/TeleAI/TeleChat2-115B


代码示例:

当前模型推理兼容了单卡和多卡推理,以及针对长文推理做了部分优化工作,模型推理方法示范:

import osimport torchfrom modelscope import AutoModelForCausalLM, AutoTokenizer, GenerationConfigtokenizer = AutoTokenizer.from_pretrained('TeleAI/TeleChat2-3B', trust_remote_code=True)model = AutoModelForCausalLM.from_pretrained('TeleAI/TeleChat2-3B', trust_remote_code=True, device_map="auto",                                                  torch_dtype=torch.float16)prompt = "生抽与老抽的区别?"messages = [{"role": "user", "content": prompt}]text = tokenizer.apply_chat_template(messages,  tokenize=False,       add_generation_prompt=True)model_inputs = tokenizer([text], return_tensors="pt").to(model.device)generated_ids = model.generate(    **model_inputs,    max_new_tokens=512)generated_ids = [    output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)]



AWPortraitCN

AWPortraitCN 是基于FLUX.1-dev开发。它在训练时使用了更符合中国人外貌和审美特征的图像。它包含了多种类型的肖像,如室内和室外肖像、时尚和影棚照片。它具有很强的泛化能力。与原始版本相比,AWPortraitCN在皮肤质感上更加细腻真实。为了追求更真实的原始图像效果,它可以与AWPortraitSR工作流程一起使用。


模型链接:

https://modelscope.cn/models/LiblibAI/AWPortraitCN


效果展示:



02


数据集推荐



DAVIS-Edit

数据集专为通过SFT微调语言模型以激活思维链而设计,目的是提升模型在复杂推理任务上生成连贯、逻辑性强的推理序列的能力。


数据集链接:

https://modelscope.cn/datasets/AI-ModelScope/OpenO1-SFT


LLaVA-CoT-o1-Instruct

LLaVA-CoT-o1-Instruct是用于支持和提升语言模型在复杂任务中的逻辑推理和连贯性表现。


数据集链接:

https://modelscope.cn/datasets/AI-ModelScope/LLaVA-CoT-o1-Instruct


LLaVA-CoT-100k

LLaVA-CoT-100k是一个专注于复杂推理任务的数据集,包含100,000个样本。这个数据集被设计用来训练和测试语言模型,以提高它们在逻辑推理和问题解决方面的能力。


数据集链接:

https://modelscope.cn/datasets/AI-ModelScope/LLaVA-CoT-100k


03


精选应用



OminiControl

是一款内容生成工具,支持上传一张有主体的图片+一段文本关键词进行合成。具有广泛的应用前景。


体验直达:

https://modelscope.cn/studios/AI-ModelScope/OminiControl



Hallo

TTS x Hallo Talking Portrait Generator是一个集成多个开源项目的演示工具,允许用户生成会说话的肖像视频,但视频长度限制为4秒音频以内。


体验直达:

https://modelscope.cn/studios/AI-ModelScope/Hallo



HunyuanVideo

HunyuanVideo是一个创新的视频生成工具,它通过引入Transformer架构和Full Attention机制,实现了图像和视频的统一生成。该工具采用“Dual-stream to Single-stream”混合模型设计,首先独立处理视频和文本token,确保每个模态都能学习到适合自己的调制机制,然后在Single-stream阶段将视频和文本token融合,实现多模态信息的有效整合,捕捉视觉和语义信息之间的复杂交互,从而显著提升模型的整体性能。


体验直达:

https://modelscope.cn/studios/chuanSir/HunyuanVideo


04


社区精选文章





?点击关注ModelScope公众号获取

更多技术信息~






跳转微信打开

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

魔搭ModelScope 人工智能 开源模型 视频生成 多模态
相关文章