OmniGen是一个由北京人工智能研究院的研究人员提出的专为统一图像生成而设计的新型扩散模型。

OmniGen 采用了变分自动编码器(VAE)与预训练的大规模Transformer模型相结合的设计,VAE负责从输入图像中提取连续的视觉特征,而Transformer则根据这些特征及给定条件生成最终的输出图像。

OmniGen可以接受自由形式的多模态交错文本和图像作为输入,使用Phi-3分词器处理文本数据,并通过VAE将图像转化为潜在表示后进一步编码成视觉标记序列。

OmniGen模型具有处理多种图像生成任务的能力,从简单的文本到图像转换到更复杂的图像编辑与视觉条件生成。

通过在统一格式下进行学习,OmniGen能够有效地跨不同任务传递知识,应对未见的任务和领域,并展示出新的能力。

github项目地址:https://github.com/VectorSpaceLab/OmniGen。

一、环境安装

1、python环境

建议安装python版本在3.10以上。

2、pip库安装

pip install git+https://github.com/huggingface/parler-tts.git

3、模型下载

git lfs install

git clone https://www.modelscope.cn/models/OpenBMB/MiniCPM-V-2_6

、功能测试

1、运行测试

(1)python代码调用测试

from OmniGen import OmniGenPipeline

def generate_image(prompt, model_path, output_filename, height=1024, width=1024, guidance_scale=2.5, seed=0):
    # Load the model
    pipe = OmniGenPipeline.from_pretrained(model_path)
    
    # Generate images
    images = pipe(
        prompt=prompt, 
        height=height, 
        width=width, 
        guidance_scale=guidance_scale,
        seed=seed,
    )
     
    # Save the first image
    images[0].save(output_filename)

def main():
    model_path = "Shitao/OmniGen-v1"
    prompt = "A curly-haired man in a red shirt is drinking tea."
    output_filename = "output1.png"

    generate_image(prompt, model_path, output_filename)

if __name__ == "__main__":
    main()

未完......

更多详细的欢迎关注:杰哥新技术

Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐