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]为是否生成.json文件添加开关 #14

Closed
aylz10 opened this issue Sep 18, 2023 · 2 comments
Closed

[Feature]为是否生成.json文件添加开关 #14

aylz10 opened this issue Sep 18, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@aylz10
Copy link

aylz10 commented Sep 18, 2023

可否为是否生成.json文件添加控制开关
我修改了sd-webui的modules\extra_networks.py使其可以直接读取civitai.info文件的元数据,当我需要更改模型信息、描述内容、自动选择vae等信息时,直接保存为json文件的数据,并且可以直接在文件夹中看有没有json文件可以很直观的判断出哪些是自己修改了内容,哪些使用的是原始的civitai元数据.如果每个模型都生成civitai.info和.json文件,那么就失去了这个便利的判断方法

@aylz10
Copy link
Author

aylz10 commented Sep 18, 2023

修改sd-webui的modules\extra_networks.py使其直接读取civitai.info文件的元数据的方法很简单
修改def get_user_metadata(filename):函数
将内容从

def get_user_metadata(filename):
if filename is None:
return {}

basename, ext = os.path.splitext(filename)
metadata_filename = basename + '.json'

metadata = {}
try:
    if os.path.isfile(metadata_filename):
        with open(metadata_filename, "r", encoding="utf8") as file:
            metadata = json.load(file)
except Exception as e:
    errors.display(e, f"reading extra network user metadata from {metadata_filename}")

return metadata

变更为

def get_user_metadata(filename):
if filename is None:
return {}

basename, ext = os.path.splitext(filename)
metadata_filename = basename + '.json'
metadata_filename1 = basename + '.civitai.info'

metadata = {}
try:
    if os.path.isfile(metadata_filename):
        with open(metadata_filename, "r", encoding="utf8") as file:
            metadata = json.load(file)
    elif os.path.isfile(metadata_filename1):
        with open(metadata_filename1, "r", encoding="utf8") as file:
            metadata = json.load(file)
except Exception as e:
    errors.display(e, f"reading extra network user metadata from {metadata_filename}")

return metadata

zixaphir added a commit that referenced this issue Sep 18, 2023
@zixaphir zixaphir added the enhancement New feature or request label Sep 21, 2023
@zixaphir
Copy link
Owner

Added in v1.7.3

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

No branches or pull requests

2 participants