愛在花開的季節 发表于 2024-9-7 21:42:05

Datawhale X 魔搭 AI夏令营第四期AIGC方向的实践学习

学习简介

从零入门AI生图原理&实践 是 Datawhale 2024 年 AI 夏令营第四期的学习活动(“AIGC”方向),基于魔搭社区“可图Kolors-LoRA风格故事挑战赛”开展的实践学习——


[*] 适合想 入门并实践 AIGC文生图、工作流搭建、LoRA微调 的学习者参与
学习内容提要:从通过代码实现AI文生图逐渐进阶,教程侧重图像工作流、微调、图像优化等思路,最后会简朴介绍AIGC应用方向、数字人技能。
接下来我将对于怎样生成一个AI图片和怎样参加实践学习进行一个简要的表明和说明。
第一步,参加可图Kolors-LoRA风格故事挑战赛

赛事链接

https://tianchi.aliyun.com/s/ce4dc8bf800db1e58d51263ff357d28f
赛事任务


[*] 参赛者需在可图Kolors 模子的基础上训练LoRA 模子,生成无限风格,如水墨画风格、水彩风格、赛博朋克风格、日漫风格......
[*] 基于LoRA模子生成 8 张图片组成连贯故事,故事内容可自界说;基于8图故事,评估LoRA风格的美感度及连贯性。
评分规则介绍

1. 主观评分
由评委对参赛作品进行投票,评审标准可以从技能运用(40%)、组图风格连贯性(30%)、团体视觉结果(30%)几方面进行评判投票。
2. 客观评分
美学分数仅作评价提交是否有用的标准,此中美学分数小于6(阈值可能根据比赛的实际情况调整,表明权归主办方所有)的提交被视为无效提交,无法参与主观评分。
任务提交格式说明

1.将训练好的LoRA 模子上传到魔搭模子库


[*] LoRA模子命名为:队伍名称-可图Kolors训练-xxxxxx
[*] LoRA 上传地点:魔搭社区
2.作品发布在比赛品牌馆讨论区,魔搭社区


[*] 发布标题格式为:天池平台报名队伍名称+LoRA模子链接地点+作品图(8图故事)
第二步,正式开始训练LoRA模子,生成图片



step 1:开通阿里云PAI-DSW试用

链接:​​​​​​阿里云免费试用 - 阿里云


[*] 新用户必要注册&绑定阿里云账号
[*] 新用户还必要完成阿里云账号的实名认证,直接完成即可
https://i-blog.csdnimg.cn/direct/445b4f2543b3497687d4957ed061a8d3.png
https://i-blog.csdnimg.cn/direct/4ea59d949bb94fe284ffe0deb7e8e0a8.png
https://i-blog.csdnimg.cn/direct/70578baa50df4d40a1b46d8026b3c157.png
https://i-blog.csdnimg.cn/direct/9d0084630cf545519e2e19215ef32aff.png
https://i-blog.csdnimg.cn/direct/c42eed8292d640d9b9cfcd90b370412e.png
https://i-blog.csdnimg.cn/direct/042446b6b386484a897fa5b857611f98.png


[*] 开通免费试用
开通PAI-DSW 试用 ,可获得 5000算力时!有用期3个月!
如果已经开通试用或试用已过期,可以跳过此步骤,利用魔搭免费GPU额度或探求其他的算力方案。
https://i-blog.csdnimg.cn/direct/efcae4fab9cd4f21bc25277053510c2f.png
https://i-blog.csdnimg.cn/direct/171c5f50ffd741b9ac20b28fcd611ea0.png
https://i-blog.csdnimg.cn/direct/6b2263834c8d462c9c588a207724d5b8.png


[*] 在魔搭社区进行授权
链接:https://www.modelscope.cn/my/mynotebook/authorization
如果这一步授权失败,可跳过此步骤,继承往下进行
https://i-blog.csdnimg.cn/direct/787497cfb12c46f8b322bd2c1624c02f.png
https://i-blog.csdnimg.cn/direct/2c0a8596df6a45809a718ff717523077.png
https://i-blog.csdnimg.cn/direct/5f04e1e5d27446099c78b5d30719a207.png
https://i-blog.csdnimg.cn/direct/22951cf8493f42e48ab9f4bed783875c.pngstep 2 :报名赛事

赛事链接:https://tianchi.aliyun.com/competition/entrance/532254
点击报名比赛,即可报名乐成
https://i-blog.csdnimg.cn/direct/17fef3f2729140a3a2d2739586ef85e6.png
https://i-blog.csdnimg.cn/direct/19a834af8d3b4e2280d7738bc4ead8e4.png
step 3 :在魔搭社区创建PAI实例

链接:https://www.modelscope.cn/my/mynotebook/authorization
创建实例,启动!
如果在上一步授权失败,可到阿里云控制台创建 & 打开实例,具体步骤详见下方子步骤
https://i-blog.csdnimg.cn/direct/9e9bdb29a64146c8991a6bda606df807.png
https://i-blog.csdnimg.cn/direct/49600851f2db44419957cfdcd3ec82f4.png
https://i-blog.csdnimg.cn/direct/459813e6c9eb4f4195396c7d85212199.png
https://i-blog.csdnimg.cn/direct/5fe7e3d28e594ec898f735324364dc7a.png
https://i-blog.csdnimg.cn/direct/7d43d21ba65a4da2aed625ec41a9a7f8.png
https://i-blog.csdnimg.cn/direct/1fceb1fa55704cc5a6f14ddf1da955ee.png
step 4 :打开实例

https://i-blog.csdnimg.cn/direct/ac3d3fd467404b03902f717d65b1f5fd.png
留意(其他情况)

如果在魔塔无法授权大概点击【打开】无法打开,可到阿里云控制台创建&打开实例
起首,打开管理控制台

https://i-blog.csdnimg.cn/direct/c9ce7a0a7e25466bbfe553c2edcef80b.png
https://i-blog.csdnimg.cn/direct/7c2be9fa224f4f36bd4d76b46e18c9b4.png
其次,创建实例

https://i-blog.csdnimg.cn/direct/1a4734b852854d2099f75cc082dd9cfb.png
https://i-blog.csdnimg.cn/direct/d0ee3053b2304a4693270a9d7de13f55.png
https://i-blog.csdnimg.cn/direct/b383e5a973f24ad6ae817da4bc643143.png
https://i-blog.csdnimg.cn/direct/1b895e4dd30d4160987e2d967deebe14.png
最后,打开实例

https://i-blog.csdnimg.cn/direct/4e188f402c6e4539bd8367f9c0467906.png
https://i-blog.csdnimg.cn/direct/a68ebe0bbecd494497db6e67e8f9b6cf.png


[*] 如果之前试用的额度已颠末期,可利用魔搭的免费Notebook实例

https://i-blog.csdnimg.cn/direct/c3db6ec11f744fd8ad5e00548bb9f8bc.png
https://i-blog.csdnimg.cn/direct/0cc3f4692c5948bc8ce207f13750b183.png
step 5 :下载baseline文件

1 git lfs install
2 git clone https://www.modelscope.cn/datasets/maochase/kolors.git https://i-blog.csdnimg.cn/direct/d08356db1ad44d0bab84a2ce02c3c82c.png
https://i-blog.csdnimg.cn/direct/93a5e9eef66d43b9bc3aed5f04ea3133.png
step 6 :打开baseline文件

https://i-blog.csdnimg.cn/direct/14045bf077464a6ba61c5c06097cf478.png
https://i-blog.csdnimg.cn/direct/247d1c36f81445d6b88ec968ba7ca716.png
step 7 :安装情况,并重启kernel

安装 Data-Juicer 和 DiffSynth-Studio

Data-Juicer:数据处理和转换工具,旨在简化数据的提取、转换和加载过程
DiffSynth-Studio:高效微调训练大模子工具
https://i-blog.csdnimg.cn/direct/6137a94b32c0480bbcb92635f8cddc2a.png
重启kernel

https://i-blog.csdnimg.cn/direct/6a6f64b86b854130ae5b069c8f5c3001.png
在实例中的接下来的代码块内容

1. 数据集的下载和数据集中的图片及元数据的保存
2. 利用Data-Juicer处理数据,整理训练数据文件
3. 利用DiffSynth-Studio在基础模子上,利用前面整理好的数据文件进行训练微调
4. 加载训练微调后的模子
5. 利用微调后的模子,生成用户指定的prompt提示词的图片

step 8 : 根据实例中的代码,依次顺序运行剩余的代码块

https://i-blog.csdnimg.cn/direct/920d095cf8944588b3284ed809e51bcd.png
https://i-blog.csdnimg.cn/direct/376b170564d54446b975191bbdc5c60d.png
https://i-blog.csdnimg.cn/direct/8866a7063b4e47bd90d8c9e475dd66e5.png
https://i-blog.csdnimg.cn/direct/d869526d348440388f9917dc21ddc713.png
https://i-blog.csdnimg.cn/direct/4770314752ca41b78bf9032fd19dd99d.png
https://i-blog.csdnimg.cn/direct/36b8a0448e9e4902b961947687c7ebdc.png
https://i-blog.csdnimg.cn/direct/45fe4bc4689149c8bc2578df873bdef0.png
https://i-blog.csdnimg.cn/direct/09483e2ec7cc4cb2a51f76625461ef70.png
step 9 :调整prompt,生成图像

正向形貌词:你想要生成的图片应该包含的内容
反向提示词:你不希望生成的图片的内容
https://i-blog.csdnimg.cn/direct/d6b66008db8a4c7b9c13f9fbe3fc978d.pngstep 10 : 运行最后的代码块,最终获得图片

https://i-blog.csdnimg.cn/direct/35136956a16243d49ade1c39b05f37e9.png
step 11:微调结果上传魔搭

链接:https://www.modelscope.cn/models/create

1. 移动结果文件

创建terminal,粘贴如下命令,回车执行
1 mkdir /mnt/workspace/kolors/output & cd
2 cp /mnt/workspace/kolors/models/lightning_logs/version_0/checkpoints/epoch\=0-step\=500.ckpt /mnt/workspace/kolors/output/
3 cp /mnt/workspace/kolors/1.jpg /mnt/workspace/kolors/output/
 https://i-blog.csdnimg.cn/direct/0545cec8dab24457b950d1795bcf9eac.png
2. 下载结果文件

双击进入output文件夹,分别下载两个文件到本地
https://i-blog.csdnimg.cn/direct/c9e986eada804bccb45178bfbef6a805.png
https://i-blog.csdnimg.cn/direct/de91f0996fb64d6ba53bd541ebf97237.png
3. 创建并上传模子所必要的内容

  点击魔搭链接,创建模子,中文名称发起格式:队伍名称-可图Kolors训练-xxxxxx
https://i-blog.csdnimg.cn/direct/119111ee3bc54fdd9df1e472936ba602.png
https://i-blog.csdnimg.cn/direct/769379e433d04c8991f002ba34479d6c.png
如许就算创建完成并发布在创空间讨论区了。
4. 来到创空间,检察本身的模子是否发布

https://i-blog.csdnimg.cn/direct/5a07b176072a43bcaef146222b388f77.png
https://i-blog.csdnimg.cn/direct/521c46768b10486fa211950a43b421da.png
step 12 :关闭PAI实例

链接:https://www.modelscope.cn/my/mynotebook/authorization
运行完成后,别忘了回到魔搭,【关闭】实例,否则会不停消耗你的试用额度!
每小时消耗大概7个试用额度!(统共5000个,有用期三个月)
https://i-blog.csdnimg.cn/direct/8145e547f769424ba649b34ba10d8367.png
做完这些步骤以后,如许就完成了一个AI图片,并进行了发表和参赛。
附录

从零入门AI生图原理&实践:Datawhale

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: Datawhale X 魔搭 AI夏令营第四期AIGC方向的实践学习