zixaphir / Stable-Diffusion-Webui-Civitai-Helper

Stable Diffusion Webui Extension for Civitai, to manage your model much more easily.
175 stars 24 forks source link

增加civitai元数据示例图图片生成信息功能,并将生成信息按照civitai.info的格式保存到meta中 #20

Closed aylz10 closed 8 months ago

aylz10 commented 9 months ago

实现 #17 中提到的功能,结合sd-model-preview-xd插件和lora-prompt-tool插件可以很方便的将示例图的生成信息加载到webui

zixaphir commented 8 months ago

Hello! I think this is looking pretty good so far, but there are a few notes:

Please separate function definitions with 2 completely empty lines.

I don't understand starting variable names with underscore (_) characters. I know these are generally used to mark variables as "private", but in a "function" context, I don't think it's needed. If you have a rational for this, please let me know: I am still a novice at a lot of this and I don't mind learning a thing or two.

Can you run pylint on your added functions? I am not worried about warnings like W1514 - Unspecified Encoding or C0301 - Line too long. Unable to import errors can also be ignored. Largely, this helps with readability and maintainability, and it helps keep the codebase consistent.

with open(filename, flags) as a_file: blocks close files when their scope ends, so you don't need to worry about doing that manually.

Perhaps we can expose Update Image Metadata functionality as a single-model operation, instead of or additionally to scanning every model at once. You can look at Get Model Info from Civitai by URL for an example of how to implement similar functionality.

That said, none of this is required on your part. If you don't feel like doing this, I can take care of it when I merge. Thank you very much for implementing all of this. :)


The following was written by ChatGPT:

你好!我认为目前看起来还不错,但有一些注意事项:

请使用完全空行分隔函数定义。

我不太理解以下划线(_)字符开头的变量名。我知道这通常用于标记变量为"private",但在"function"上下文中,我认为这不是必要的。如果你有理由这样做,请让我知道:我在这方面还是个新手,我不介意学一两件事情。

你能在你添加的函数上运行pylint吗?我不担心像W1514 - Unspecified EncodingC0301 - Line too long这样的警告。无法导入的错误也可以忽略。总的来说,这有助于提高可读性和可维护性,并有助于保持代码库的一致性。

with open(filename, flags) as a_file: 块会在其作用域结束时关闭文件,所以你不需要手动担心关闭文件。

也许我们可以将“更新图像元数据”的功能作为单一模型操作公开,而不是或者除了一次扫描每个模型。你可以查看“Get Model Info from Civitai by URL”以了解如何实现类似的功能。

话虽如此,这一切都不是你必须做的。如果你不想做这些,我可以在合并时处理。非常感谢你实现所有这些。 :)

aylz10 commented 8 months ago

我是个python新手,这只是我的业余爱好,所以我写的代码很糟糕,这也是为什么我首先写issue提需求而不是提交pull requst。我没用过pylint,我是直接使用txt文本编辑器编写的代码,所以代码可读性和可维护性很糟糕,"_"开头的变量没有任何必要,只是我在写代码时增加代码可读性的一种操作,毕竟我的英文很差。我查看过“Get Model Info from Civitai by URL”但是没有完全读懂里面的代码,所以索性直接扫描所有模型以尽快的实现功能。您可以按照您的想法随意修改代码以达到更好的效果