Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Overbill1683
Stable Diffusion Webui
提交
8ff6f093
S
Stable Diffusion Webui
项目概览
Overbill1683
/
Stable Diffusion Webui
10 个月 前同步成功
通知
1748
Star
81
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
S
Stable Diffusion Webui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
8ff6f093
编写于
9月 17, 2022
作者:
A
AUTOMATIC1111
提交者:
GitHub
9月 17, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #587 from JashoBell/Base
Basic documentation for custom_code.py template
上级
23a0ec04
98a6644b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
2 deletion
+23
-2
modules/scripts.py
modules/scripts.py
+19
-0
scripts/custom_code.py
scripts/custom_code.py
+4
-2
未找到文件。
modules/scripts.py
浏览文件 @
8ff6f093
...
...
@@ -13,18 +13,37 @@ class Script:
args_from
=
None
args_to
=
None
# The title of the script. This is what will be displayed in the dropdown menu.
def
title
(
self
):
raise
NotImplementedError
()
# How the script is displayed in the UI. See https://gradio.app/docs/#components
# for the different UI components you can use and how to create them.
# Most UI components can return a value, such as a boolean for a checkbox.
# The returned values are passed to the run method as parameters.
def
ui
(
self
,
is_img2img
):
pass
# Determines when the script should be shown in the dropdown menu via the
# returned value. As an example:
# is_img2img is True if the current tab is img2img, and False if it is txt2img.
# Thus, return is_img2img to only show the script on the img2img tab.
def
show
(
self
,
is_img2img
):
return
True
# This is where the additional processing is implemented. The parameters include
# self, the model object "p" (a StableDiffusionProcessing class, see
# processing.py), and the parameters returned by the ui method.
# Custom functions can be defined here, and additional libraries can be imported
# to be used in processing. The return value should be a Processed object, which is
# what is returned by the process_images method.
def
run
(
self
,
*
args
):
raise
NotImplementedError
()
# The description method is currently unused.
# To add a description that appears when hovering over the title, amend the "titles"
# dict in script.js to include the script title (returned by title) as a key, and
# your description as the value.
def
describe
(
self
):
return
""
...
...
scripts/custom_code.py
浏览文件 @
8ff6f093
...
...
@@ -4,8 +4,8 @@ import gradio as gr
from
modules.processing
import
Processed
from
modules.shared
import
opts
,
cmd_opts
,
state
class
Script
(
scripts
.
Script
):
def
title
(
self
):
return
"Custom code"
...
...
@@ -18,6 +18,7 @@ class Script(scripts.Script):
return
[
code
]
def
run
(
self
,
p
,
code
):
assert
cmd_opts
.
allow_code
,
'--allow-code option must be enabled'
...
...
@@ -37,4 +38,5 @@ class Script(scripts.Script):
exec
(
compiled
,
module
.
__dict__
)
return
Processed
(
p
,
*
display_result_data
)
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录