基于MindSpore 2.7.0和MindSpore NLP 0.5.1实现真人照片到特定风格图像生成的可交互DEMO开发#50
Open
tt5416 wants to merge 2 commits intomindspore-lab:devfrom
Open
基于MindSpore 2.7.0和MindSpore NLP 0.5.1实现真人照片到特定风格图像生成的可交互DEMO开发#50tt5416 wants to merge 2 commits intomindspore-lab:devfrom
tt5416 wants to merge 2 commits intomindspore-lab:devfrom
Conversation
Contributor
|
好的,辛苦 @moyu026 做下代码验证,@DuangZ-GR 来检查下代码规范 |
Author
老师,修改完毕,请查收 |
Author
|
MindSpore 2.7.0和MindSpore NLP 0.5.1版本可以运行 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




任务描述:真人照片风格化生成可交互 DEMO
一、任务概述
基于 MindSpore 2.7.0 + MindNLP 0.5.1,参考照片风格化生成方案,在 华为 Ascend NPU 910B 上实现 真人照片到指定风格图像生成 的可交互 DEMO。支持上传真人照片后一键生成风格化结果,在保持人物主要面部特征相似的前提下,实现更稳定的吉卜力风格与卡通插画风格生成。
二、实现内容
真人照片风格化可交互 DEMO(app.py)
基于 Gradio 构建 Web 交互界面,支持以下功能:
风格选择:吉卜力、卡通插画
图片上传与生成:用户上传真人照片后,一键生成对应风格图像
参数调节:支持 strength、steps、guidance_scale、seed、size
人物特征保留增强:尽量保持原人物脸型、五官和整体身份特征
多尺寸输出:支持 512 / 640 / 768
风格化生成与局部优化
围绕真人照片到风格图像生成,核心实现包括:
基于 StableDiffusionImg2ImgPipeline 实现全图风格化生成
通过 STYLE_PRESETS 配置不同风格的模型与提示词
加入面部区域局部优化,采用 原脸结构保留 + 风格颜色迁移 + 软融合回贴 的方式增强人物相似性
针对面部发糊问题,增加细节恢复、遮罩优化和轻量锐化处理