智東西(公眾號:zhidxcom)
作者 | ZeR0
編輯 | 漠影

智東(dong)西8月(yue)6日報道,好消息,智譜AI的(de)視(shi)頻生成模型CogVideoX-2B,昨(zuo)晚正(zheng)式開源了。

模型已上架GitHub、Hugging Face,FP16精度(du)下的推理僅需(xu)18GB顯存,微調則只(zhi)需(xu)要40GB,單張4090顯卡(ka)可推理,單張A6000可微調。

國產版Sora開源了!推理優化到18G,4090單卡可跑

CogVideoX-2B的(de)提示詞上限為(wei)(wei)226個token,視頻(pin)長度(du)為(wei)(wei)6秒,幀率為(wei)(wei)8幀/秒,視頻(pin)分辨率為(wei)(wei)720 * 480。

國產版Sora開源了!推理優化到18G,4090單卡可跑

CogVideoX系列(lie)開源模(mo)型(xing)與智(zhi)譜AI的(de)商業版視頻生成模(mo)型(xing)“清影”同源。2B版本首發后(hou),性(xing)能更強、參數量(liang)更大(da)的(de)開源模(mo)型(xing)將在后(hou)續上架。

代碼倉庫://github.com/THUDM/CogVideo
模型下載://huggingface.co/THUDM/CogVideoX-2b
技術報告://github.com/THUDM/CogVideo/blob/main/resources/CogVideoX.pdf

根據(ju)論(lun)文(wen),CogVideoX在(zai)雷達圖中比其他幾(ji)個視(shi)頻生成(cheng)模型更大,屬性值趨(qu)近六邊(bian)形。

國產版Sora開源了!推理優化到18G,4090單卡可跑

為了(le)(le)評估文生(sheng)視(shi)頻的(de)質量,智(zhi)譜AI使用(yong)了(le)(le)VBench中的(de)多個指(zhi)標,如人(ren)類動(dong)作、場景、動(dong)態(tai)程度等;還使用(yong)了(le)(le)兩(liang)個額外的(de)視(shi)頻評估工具:Devil中的(de)Dynamic Quality和(he)Chrono-Magic中的(de)GPT4o-MT Score,這些(xie)工具專注于視(shi)頻的(de)動(dong)態(tai)特性。從下表可見,CogVideoX在多個指(zhi)標的(de)得分(fen)領先。

國產版Sora開源了!推理優化到18G,4090單卡可跑

在人類盲評中,CogVideoX在五個指標(biao)的得分均超過了快手可靈。

國產版Sora開源了!推理優化到18G,4090單卡可跑

GitHub頁(ye)面展示了幾個由CogVideoX-2B生成(cheng)的(de)視頻作品(pin):

國產版Sora開源了!推理優化到18G,4090單卡可跑

▲提示(shi)詞:A detailed wooden toy ship with intricately carved masts and sails is seen gliding smoothly over a plush, blue carpet that mimics the waves of the sea. The ship’s hull is painted a rich brown, with tiny windows. The carpet, soft and textured, provides a perfect backdrop, resembling an oceanic expanse. Surrounding the ship are various other toys and children’s items, hinting at a playful environment. The scene captures the innocence and imagination of childhood, with the toy ship’s journey symbolizing endless adventures in a whimsical, indoor setting.

國產版Sora開源了!推理優化到18G,4090單卡可跑

▲提示詞(ci):The camera follows behind a white vintage SUV with a black roof rack as it speeds up a steep dirt road surrounded by pine trees on a steep mountain slope, dust kicks up from its tires, the sunlight shines on the SUV as it speeds along the dirt road, casting a warm glow over the scene. The dirt road curves gently into the distance, with no other cars or vehicles in sight. The trees on either side of the road are redwoods, with patches of greenery scattered throughout. The car is seen from the rear following the curve with ease, making it seem as if it is on a rugged drive through the rugged terrain. The dirt road itself is surrounded by steep hills and mountains, with a clear blue sky above with wispy clouds.

國產版Sora開源了!推理優化到18G,4090單卡可跑

▲提示(shi)詞:A street artist, clad in a worn-out denim jacket and a colorful bandana, stands before a vast concrete wall in the heart, holding a can of spray paint, spray-painting a colorful bird on a mottled wall.

國產版Sora開源了!推理優化到18G,4090單卡可跑

▲提示(shi)詞:In the haunting backdrop of a war-torn city, where ruins and crumbled walls tell a story of devastation, a poignant close-up frames a young girl. Her face is smudged with ash, a silent testament to the chaos around her. Her eyes glistening with a mix of sorrow and resilience, capturing the raw emotion of a world that has lost its innocence to the ravages of conflict.

CogVideoX采用3D VAE和專(zhuan)家Transformer架構來(lai)生成連貫長(chang)視(shi)頻,通過自研視(shi)頻理解模型構建了一個具有(you)文本描述的相(xiang)對高質量(liang)的視(shi)頻片段集合。

國產版Sora開源了!推理優化到18G,4090單卡可跑

視頻數據因包含空間和時間信息,其數據量和計算負擔遠超圖像數據。智譜AI提出了基于3D變分自編碼器(3D VAE)的(de)視頻壓(ya)縮方法(fa),通過三維卷積同(tong)時壓(ya)縮視頻的(de)空(kong)間和時間維度,實現(xian)了更高的(de)壓(ya)縮率和更好的(de)重建質量(liang)。

國產版Sora開源了!推理優化到18G,4090單卡可跑▲CogVideoX里的3D VAE架構

模型結構包(bao)括編(bian)碼(ma)器(qi)、解碼(ma)器(qi)、潛在空間(jian)正則化器(qi),通過四個階段的(de)下采(cai)樣和上采(cai)樣實現壓縮。時間(jian)因果卷(juan)積確保了信息的(de)因果性,減(jian)少了通信開銷,上下文(wen)并行技術能更好適應大規模視頻處理。

實驗(yan)中(zhong),智譜AI發現(xian)大(da)分(fen)辨率(lv)編碼易于(yu)泛化,增加幀(zhen)(zhen)數則(ze)挑(tiao)戰較大(da),因此模型訓(xun)練分(fen)兩(liang)個階段:先在較低幀(zhen)(zhen)率(lv)和(he)小批量上訓(xun)練,后通過上下文并(bing)行在更高(gao)幀(zhen)(zhen)率(lv)上微調(diao)。訓(xun)練損(sun)失函數結合了L2損(sun)失、LPIPS感知(zhi)損(sun)失和(he)3D判別器(qi)的(de)GAN損(sun)失。

智譜AI使用VAE的編碼器將視頻壓縮至潛在空間,然后將潛在空間分割成塊并展開成長的序列嵌入z_vision,同時使用T5,將文本輸入編碼為文本嵌入z_text,再將z_text和z_vision沿序列維度拼接,拼接后的嵌入被送入專家Transformer塊(kuai)堆棧中處(chu)理,最后(hou)反向拼(pin)接嵌(qian)入來恢復原始潛在(zai)空間形狀,并使用VAE進行解碼以重(zhong)建視頻。

國產版Sora開源了!推理優化到18G,4090單卡可跑▲CogVideoX架(jia)構

訓練(lian)數(shu)據(ju)(ju)方面(mian),智譜(pu)AI開發了(le)負面(mian)標(biao)簽來(lai)識別和排除低(di)質量(liang)視頻,通過video-llama訓練(lian)的過濾器標(biao)注并篩(shai)選了(le)20000個視頻數(shu)據(ju)(ju)樣(yang)本(ben);同時,計算光(guang)流和美學分數(shu),動(dong)態調整閾值,確保生成視頻的質量(liang)。

針對缺乏視頻字幕數據的問題,智譜AI提出了一種從圖像字幕生成視頻字幕的管道,并微調端(duan)(duan)到端(duan)(duan)的(de)視頻(pin)字(zi)(zi)(zi)(zi)幕模(mo)(mo)型(xing)以獲得更密集(ji)的(de)字(zi)(zi)(zi)(zi)幕。這種方法通過Panda70M模(mo)(mo)型(xing)生(sheng)成(cheng)簡(jian)短字(zi)(zi)(zi)(zi)幕,用CogView3模(mo)(mo)型(xing)生(sheng)成(cheng)密集(ji)圖像字(zi)(zi)(zi)(zi)幕,然后(hou)用GPT-4模(mo)(mo)型(xing)總結(jie)生(sheng)成(cheng)最終的(de)短視頻(pin)。

該團隊還微調了一個基于CogVLM2-Video和Llama 3的CogVLM2-Caption模型,使用(yong)密(mi)集(ji)字(zi)幕(mu)數據進行訓(xun)練,以加速視(shi)頻字(zi)幕(mu)生成過(guo)程。

國產版Sora開源了!推理優化到18G,4090單卡可跑▲密集字幕數據生成流程

智(zhi)譜AI團(tuan)隊仍在努力(li)完善(shan)CogVideoX捕捉復雜動態的能力(li),探究新型模(mo)型架構、更高效地(di)壓縮視(shi)頻(pin)(pin)信息(xi)、更充分地(di)融合文本和視(shi)頻(pin)(pin)內容,以持續(xu)探索視(shi)頻(pin)(pin)生(sheng)成(cheng)模(mo)型的scaling law,旨在訓練(lian)出更大更強(qiang)的模(mo)型,來生(sheng)成(cheng)更長、更高質量的視(shi)頻(pin)(pin)。

如今視(shi)頻生成(cheng)(cheng)模型及應(ying)(ying)用(yong)正變(bian)得(de)越來(lai)越多(duo),技術(shu)也逐漸成(cheng)(cheng)熟,但(dan)此前還沒有一個(ge)開(kai)源的視(shi)頻生成(cheng)(cheng)模型能夠滿足商業(ye)級應(ying)(ying)用(yong)的要求。我們期待(dai)更多(duo)視(shi)頻生成(cheng)(cheng)模型走向(xiang)開(kai)源,推動更多(duo)開(kai)發者及企業(ye)參與開(kai)發視(shi)頻生成(cheng)(cheng)模型及應(ying)(ying)用(yong),并為圍(wei)繞視(shi)頻生成(cheng)(cheng)的各(ge)種技術(shu)優化和(he)功能開(kai)發做貢獻(xian)。