Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: API 的请求增加请求ID,并把这个ID作为生成的文件名中的一部分 #283

Closed
zhangrc opened this issue Nov 6, 2023 · 13 comments

Comments

@zhangrc
Copy link
Contributor

zhangrc commented Nov 6, 2023

Expected behavior

'alwayson_scripts': {
'AnimateDiff': {
'args': [{
.....
'request_id': 11111 # api 的调用方来传入这个参数,
.....
}
]
}
},

file_name = ‘****__request_id’

@continue-revolution
Copy link
Owner

为什么需要这个

@zhangrc
Copy link
Contributor Author

zhangrc commented Nov 6, 2023

多次api 调用的prompt 是不一样的,通过automatic1111合成后的文件无法和调用方进行关联,由调用api 的地方来生成唯一的request_id ,通过request_id 来进行prompt 和生成的文件进行关联

@continue-revolution
Copy link
Owner

返回文件名行不行

@zhangrc
Copy link
Contributor Author

zhangrc commented Nov 6, 2023

返回文件名行不行

可以通过返回文件名的方式,但是这样api调用就只能是同步的方式,需要很长的socket链接时长
通过文件名加id 的方式可以做到请求异步,提交任务的时候,不需要关注结果。

@continue-revolution
Copy link
Owner

你能不能PR,跟在 #224 后面

@zhangrc
Copy link
Contributor Author

zhangrc commented Nov 6, 2023

你能不能PR,跟在 #224 后面

感谢,我试试能不能写出来,目前主业是java

@uk9921
Copy link

uk9921 commented Nov 6, 2023

你能不能PR,跟在 #224 后面

感谢,我试试能不能写出来,目前主业是java

我之前在本地实现过,重点应该是修改这两处:
animatediff_ui.py 中AnimateDiffProcess增加save_path参数,
animatediff_output.py的_save函数中使用params.save_path来保存
希望能加快你的实现,期待你们把这个功能上到master分支,这样以后pull就不用改代码了

@zhangrc
Copy link
Contributor Author

zhangrc commented Nov 6, 2023

你能不能PR,跟在 #224 后面

感谢,我试试能不能写出来,目前主业是java

我之前在本地实现过,重点应该是修改这两处: animatediff_ui.py 中AnimateDiffProcess增加save_path参数, animatediff_output.py的_save函数中使用params.save_path来保存 希望能加快你的实现,期待你们把这个功能上到master分支,这样以后pull就不用改代码了

修改的位置没问题,遇到一些与gradio相关的问题,还在处理中,方便加下微信吗 enJjXzkw (已base64)

@continue-revolution
Copy link
Owner

@uk9921 你能不能pr

@continue-revolution
Copy link
Owner

@zhangrc 我电脑上没有微信,你有问题就发在这里

@zhangrc
Copy link
Contributor Author

zhangrc commented Nov 6, 2023

@zhangrc 我电脑上没有微信,你有问题就发在这里

我在animatediff_ui.py中AnimateDiffProcess的构造方法,倒数第六个参数增加了request_id ,并给默认值1
出现错误:
*** Error calling: /stable-diffusion-webui/extensions/sd-webui-animatediff/scripts/animatediff.py/ui
Traceback (most recent call last):
File "/stable-diffusion-webui/modules/scripts.py", line 402, in wrap_call
return func(*args, **kwargs)
File "/stable-diffusion-webui/extensions/sd-webui-animatediff/scripts/animatediff.py", line 43, in ui
return (AnimateDiffUiGroup().render(is_img2img, model_dir),)
File "/stable-diffusion-webui/extensions/sd-webui-animatediff/scripts/animatediff_ui.py", line 318, in render
return self.register_unit(is_img2img)
File "/stable-diffusion-webui/extensions/sd-webui-animatediff/scripts/animatediff_ui.py", line 323, in register_unit
(
File "/usr/local/lib/python3.10/site-packages/gradio/events.py", line 140, in call
dep, dep_index = self.trigger.set_event_trigger(
File "/usr/local/lib/python3.10/site-packages/gradio/blocks.py", line 286, in set_event_trigger
"inputs": [block._id for block in inputs],
File "/usr/local/lib/python3.10/site-packages/gradio/blocks.py", line 286, in
"inputs": [block._id for block in inputs],
AttributeError: 'int' object has no attribute '_id'


然后我在AnimateDiffUiGroup的render 方法中增加一行

            with gr.Row():
                self.params.interp = gr.Radio(
                    choices=["Off", "FILM"],
                    label="Frame Interpolation",
                    elem_id=f"{elemid_prefix}interp-choice",
                    value=self.params.interp
                )
                self.params.interp_x = gr.Number(
                    value=self.params.interp_x, label="Interp X", precision=0, 
                    elem_id=f"{elemid_prefix}interp-x"
                )
                self.params.request_id = gr.Number( value=self.params.request_id, label="request_id", precision=0, elem_id=f"{elemid_prefix}request_id")

出现以下错误:
self.params.request_id = gr.Number( value=self.params.request_id, label="request_id", precision=0, elem_id=f"{elemid_prefix}request_id")

Loading weights [3b26c9c497] from /stable-diffusion-webui/models/Stable-diffusion/anything-v4.0.ckpt
*** Error calling: /stable-diffusion-webui/extensions/sd-webui-animatediff/scripts/animatediff.py/ui
Traceback (most recent call last):
File "/stable-diffusion-webui/modules/scripts.py", line 402, in wrap_call
return func(*args, **kwargs)
File "/stable-diffusion-webui/extensions/sd-webui-animatediff/scripts/animatediff.py", line 43, in ui
return (AnimateDiffUiGroup().render(is_img2img, model_dir),)
File "/stable-diffusion-webui/extensions/sd-webui-animatediff/scripts/animatediff_ui.py", line 250, in render
value=self.params.request_id, label="request_id", precision=0,
AttributeError: 'AnimateDiffProcess' object has no attribute 'request_id'

@zhangrc
Copy link
Contributor Author

zhangrc commented Nov 6, 2023

@zhangrc 我电脑上没有微信,你有问题就发在这里

我在animatediff_ui.py中AnimateDiffProcess的构造方法,倒数第六个参数增加了request_id ,并给默认值1 出现错误: *** Error calling: /stable-diffusion-webui/extensions/sd-webui-animatediff/scripts/animatediff.py/ui Traceback (most recent call last): File "/stable-diffusion-webui/modules/scripts.py", line 402, in wrap_call return func(*args, **kwargs) File "/stable-diffusion-webui/extensions/sd-webui-animatediff/scripts/animatediff.py", line 43, in ui return (AnimateDiffUiGroup().render(is_img2img, model_dir),) File "/stable-diffusion-webui/extensions/sd-webui-animatediff/scripts/animatediff_ui.py", line 318, in render return self.register_unit(is_img2img) File "/stable-diffusion-webui/extensions/sd-webui-animatediff/scripts/animatediff_ui.py", line 323, in register_unit ( File "/usr/local/lib/python3.10/site-packages/gradio/events.py", line 140, in call dep, dep_index = self.trigger.set_event_trigger( File "/usr/local/lib/python3.10/site-packages/gradio/blocks.py", line 286, in set_event_trigger "inputs": [block._id for block in inputs], File "/usr/local/lib/python3.10/site-packages/gradio/blocks.py", line 286, in "inputs": [block._id for block in inputs], AttributeError: 'int' object has no attribute '_id'

然后我在AnimateDiffUiGroup的render 方法中增加一行

            with gr.Row():
                self.params.interp = gr.Radio(
                    choices=["Off", "FILM"],
                    label="Frame Interpolation",
                    elem_id=f"{elemid_prefix}interp-choice",
                    value=self.params.interp
                )
                self.params.interp_x = gr.Number(
                    value=self.params.interp_x, label="Interp X", precision=0, 
                    elem_id=f"{elemid_prefix}interp-x"
                )
                self.params.request_id = gr.Number( value=self.params.request_id, label="request_id", precision=0, elem_id=f"{elemid_prefix}request_id")

出现以下错误: self.params.request_id = gr.Number( value=self.params.request_id, label="request_id", precision=0, elem_id=f"{elemid_prefix}request_id")

Loading weights [3b26c9c497] from /stable-diffusion-webui/models/Stable-diffusion/anything-v4.0.ckpt *** Error calling: /stable-diffusion-webui/extensions/sd-webui-animatediff/scripts/animatediff.py/ui Traceback (most recent call last): File "/stable-diffusion-webui/modules/scripts.py", line 402, in wrap_call return func(*args, **kwargs) File "/stable-diffusion-webui/extensions/sd-webui-animatediff/scripts/animatediff.py", line 43, in ui return (AnimateDiffUiGroup().render(is_img2img, model_dir),) File "/stable-diffusion-webui/extensions/sd-webui-animatediff/scripts/animatediff_ui.py", line 250, in render value=self.params.request_id, label="request_id", precision=0, AttributeError: 'AnimateDiffProcess' object has no attribute 'request_id'

@continue-revolution 这个问题已解决

@zhangrc
Copy link
Contributor Author

zhangrc commented Nov 6, 2023

本地验证通过,以已pr ,请检查

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants