Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ImageGenerate_paddle
Commits
3b78e547
"docs/vscode:/vscode.git/clone" did not exist on "66956356968b4849a98c2a86d58a5dd588d638c8"
Commit
3b78e547
authored
Nov 17, 2023
by
dengjb
Browse files
fixed readme and add inference api
parent
fb2f958e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
148 additions
and
16 deletions
+148
-16
.idea/workspace.xml
.idea/workspace.xml
+57
-5
README.md
README.md
+10
-10
inference.py
inference.py
+80
-0
requirement.txt
requirement.txt
+1
-1
No files found.
.idea/workspace.xml
View file @
3b78e547
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"AutoImportSettings"
>
<option
name=
"autoReloadType"
value=
"SELECTIVE"
/>
</component>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"01d3e030-fd3e-4982-8660-10d478b2149f"
name=
"Default Changelist"
comment=
""
/>
<list
default=
"true"
id=
"01d3e030-fd3e-4982-8660-10d478b2149f"
name=
"Default Changelist"
comment=
"fixed readme"
>
<change
afterPath=
"$PROJECT_DIR$/inference.py"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/README.md"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/README.md"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/requirement.txt"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/requirement.txt"
afterDir=
"false"
/>
</list>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"HIGHLIGHT_CONFLICTS"
value=
"true"
/>
<option
name=
"HIGHLIGHT_NON_ACTIVE_CHANGELIST"
value=
"false"
/>
<option
name=
"LAST_RESOLUTION"
value=
"IGNORE"
/>
</component>
<component
name=
"FileTemplateManagerImpl"
>
<option
name=
"RECENT_TEMPLATES"
>
<list>
<option
value=
"Python Script"
/>
</list>
</option>
</component>
<component
name=
"Git.Settings"
>
<option
name=
"RECENT_GIT_ROOT_PATH"
value=
"$PROJECT_DIR$"
/>
</component>
<component
name=
"MarkdownSettingsMigration"
>
<option
name=
"stateVersion"
value=
"1"
/>
</component>
<component
name=
"ProjectColorInfo"
>
{
"
associatedIndex
"
: 3
}
</component>
<component
name=
"ProjectId"
id=
"2VHIjrdE8hMnatRuBCcXo98aok5"
/>
<component
name=
"ProjectLevelVcsManager"
settingsEditedManually=
"true"
/>
<component
name=
"ProjectViewState"
>
<option
name=
"hideEmptyMiddlePackages"
value=
"true"
/>
<option
name=
"showLibraryContents"
value=
"true"
/>
</component>
<component
name=
"PropertiesComponent"
>
<property
name=
"RunOnceActivity.OpenProjectViewOnStart"
value=
"true"
/>
<property
name=
"RunOnceActivity.ShowReadmeOnStart"
value=
"true"
/>
</component>
<component
name=
"PropertiesComponent"
>
{
"
keyToString
"
: {
"
WebServerToolWindowFactoryState
"
:
"
false
"
,
"
git-widget-placeholder
"
:
"
Rebasing main
"
,
"
last_opened_file_path
"
:
"
D:/sugon/work_space/git/model_zoo
"
,
"
node.js.detected.package.eslint
"
:
"
true
"
,
"
node.js.detected.package.tslint
"
:
"
true
"
,
"
node.js.selected.package.eslint
"
:
"
(autodetect)
"
,
"
node.js.selected.package.tslint
"
:
"
(autodetect)
"
,
"
nodejs_package_manager_path
"
:
"
npm
"
,
"
vue.rearranger.settings.migration
"
:
"
true
"
}
}
</component>
<component
name=
"SpellCheckerSettings"
RuntimeDictionaries=
"0"
Folders=
"0"
CustomDictionaries=
"0"
DefaultDictionary=
"application-level"
UseSingleDictionary=
"true"
transferred=
"true"
/>
<component
name=
"TaskManager"
>
<task
active=
"true"
id=
"Default"
summary=
"Default task"
>
<changelist
id=
"01d3e030-fd3e-4982-8660-10d478b2149f"
name=
"Default Changelist"
comment=
""
/>
...
...
@@ -27,7 +58,28 @@
<option
name=
"number"
value=
"Default"
/>
<option
name=
"presentableId"
value=
"Default"
/>
<updated>
1694486720086
</updated>
<workItem
from=
"1698909897462"
duration=
"1290000"
/>
<workItem
from=
"1699238067729"
duration=
"75000"
/>
<workItem
from=
"1700186034106"
duration=
"5752000"
/>
</task>
<servers
/>
</component>
<component
name=
"TypeScriptGeneratedFilesManager"
>
<option
name=
"version"
value=
"3"
/>
</component>
<component
name=
"Vcs.Log.Tabs.Properties"
>
<option
name=
"TAB_STATES"
>
<map>
<entry
key=
"MAIN"
>
<value>
<State
/>
</value>
</entry>
</map>
</option>
</component>
<component
name=
"VcsManagerConfiguration"
>
<MESSAGE
value=
"fixed readme"
/>
<option
name=
"LAST_COMMIT_MESSAGE"
value=
"fixed readme"
/>
</component>
</project>
\ No newline at end of file
README.md
View file @
3b78e547
...
...
@@ -59,13 +59,12 @@ pip install -r requirements.txt
1666360416.8263636_SEED_4285104386.png
.....
```
## 训练
该模型提供少数据基于预训练的模型的训练方法。
-
使用notebook运行main.ipynb
-
根据提示步骤运行文生图定制化训练代码
## 推理
-
使用notebook运行main.ipynb
-
根据提示步骤运行推理代码
-
方法一:运行inference.py文件
-
```python inference.py ```
-
切换文生图、图生图、文生图定制化训练参考 inference文件内注释
-
方法二:使用notebook运行main.ipynb
-
根据notebook提示运行代码
## 测试
-
测试环境、功能是否够能够正常
```
python
...
...
@@ -73,10 +72,11 @@ python varify.py
```
## result
算法效果图
| 文生图 | 图生图 | 定制化训练 |
| :----: | :-----: | :------: |
!
[
文生图
](
./resources/pic_readme/txt2img.png
)
| !
[
图生图
](
./resources/pic_readme/img2img.png
)
| !
[
定制化训练
](
./resources/pic_readme/train.png
)
| 文生图 | 图生图 | 定制化训练 |
|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------:|
|'prompt':'extremely detailed CG unity 8k wallpaper,black long hair,cute face,1 adult girl,happy, green skirt dress, flower pattern in dress,solo,green gown,art of light novel,in field'
<br>
"negative_prompt":'lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry' | !
[
图生图
](
./resources/cat2.jpg
)
| "prompt": '
<Alice>
at the lake',
<br>
"negative_prompt": ''
<br>

|
| !
[
文生图
](
./resources/pic_readme/txt2img.png
)
| !
[
图生图
](
./resources/pic_readme/img2img.png
)
| !
[
定制化训练
](
./resources/pic_readme/train.png
)
|
## 应用场景
### 算法类别
...
...
inference.py
0 → 100644
View file @
3b78e547
from
ui.config
import
config
from
ui
import
(
StableDiffusionUI_text_inversion
,
StableDiffusionUI_dreambooth
,
pipeline_superres
,
pipeline
,
StableDiffusionUI_convert
,
)
from
ui.StableDiffusionUI_txt2img
import
StableDiffusionUI_txt2img
from
ui.StableDiffusionUI_img2img
import
StableDiffusionUI_img2img
from
ui.SuperResolutionUI
import
SuperResolutionUI
def
start_end
(
name
,
func
):
print
(
f
'------- test
{
name
}
start -------'
)
func
.
on_run_button_click
(
'test'
)
print
(
f
'------- test
{
name
}
finished -------'
)
if
__name__
==
'__main__'
:
# 加载配置信息 具体配置请查看ui.config文件中
# ------------------------------文生图------------------------------
if
True
:
config
[
'txt2img'
][
"prompt"
]
=
'extremely detailed CG unity 8k wallpaper,black long hair,cute face,1 adult girl,happy, green skirt dress, flower pattern in dress,solo,green gown,art of light novel,in field'
config
[
'txt2img'
][
"negative_prompt"
]
=
'lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry'
config
[
'txt2img'
][
"model_name"
]
=
'MoososCap/NOVEL-MODEL'
config
[
'txt2img'
][
"output_dir"
]
=
'outputs/txt2img'
gui_txt2img
=
StableDiffusionUI_txt2img
(
**
config
[
'txt2img'
]
)
start_end
(
'txt2img'
,
gui_txt2img
)
# ------------------------------图生图------------------------------
if
False
:
config
[
'img2img'
][
"prompt"
]
=
'red dress'
config
[
'img2img'
][
"negative_prompt"
]
=
'lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry'
config
[
'img2img'
][
"model_name"
]
=
'MoososCap/NOVEL-MODEL'
config
[
'img2img'
][
"image_path"
]
=
'resources/cat2.jpg'
config
[
'img2img'
][
"mask_path"
]
=
'resources/mask8.jpg'
config
[
'img2img'
][
"output_dir"
]
=
'outputs/img2img'
gui_img2img
=
StableDiffusionUI_img2img
(
**
config
[
'img2img'
]
)
start_end
(
'img2img'
,
gui_img2img
)
# ------------------------------文生图定制化训练--------------------------
if
False
:
config
[
'train_text_inversion'
]
=
{
"learnable_property"
:
'object'
,
"placeholder_token"
:
'<Alice>'
,
"initializer_token"
:
'girl'
,
"repeats"
:
'100'
,
"train_data_dir"
:
'resources/Alices'
,
"output_dir"
:
'outputs/textual_inversion'
,
"height"
:
512
,
"width"
:
512
,
"learning_rate"
:
5e-4
,
"max_train_steps"
:
1000
,
"save_steps"
:
200
,
"model_name"
:
"MoososCap/NOVEL-MODEL"
,
},
gui_train_text_inversion
=
StableDiffusionUI_text_inversion
(
**
config
[
'train_text_inversion'
]
)
start_end
(
'txt2img train'
,
gui_train_text_inversion
)
# 定制化训练文生图推理
if
False
:
config
[
'text_inversion'
]
=
{
"width"
:
512
,
"height"
:
512
,
"prompt"
:
'<Alice> at the lake'
,
"negative_prompt"
:
''
,
"output_dir"
:
'outputs/text_inversion_txt2img'
,
}
gui_text_inversion
=
StableDiffusionUI_txt2img
(
**
config
[
'text_inversion'
]
)
start_end
(
'txt2img inference'
,
gui_train_text_inversion
)
requirement.txt
View file @
3b78e547
...
...
@@ -2,7 +2,7 @@ OmegaConf
safetensors
ppdiffusers==0.9.0
paddlenlp==2.4.9
ipython==8.14.0
#
ipython==8.14.0
ipywidgets==8.0.7
pillow==9.5.0
tqdm==4.65.0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment