force to use optimized sha256, update document for updating SD webui's version

pull/39/head
butaixianran 2023-03-09 23:12:22 +08:00
parent 963cf63750
commit fc0f1dfaea
5 changed files with 24 additions and 7 deletions

View File

@ -19,6 +19,12 @@ Stable Diffusion Webui 扩展Civitai助手用于更轻松的管理和使用Ci
# 使用方法 # 使用方法
## 更新你的SD webui
本扩展需要取到 Extra Network的卡片列表id。**这个是从2023-02-06才添加到SD webui里面的。**
所以如果你用的版本比这个早你就需要先更新你的SD Webui
## 扫描模型 ## 扫描模型
前往扩展页面"Civitai Helper",有个按钮叫:"Scan Model" 前往扩展页面"Civitai Helper",有个按钮叫:"Scan Model"

View File

@ -26,6 +26,11 @@ Then reload UI with "Reload UI" Button in Setting tab.
Done. Done.
# How to Use # How to Use
## Update Your SD Webui
This extension need to get extra network's cards id. **Which is added to SD webui since 2023-02-06.**
So, if you are using a version older than this, you need to update your SD Webui!
## Scanning Models ## Scanning Models
Go to extension tab "Civitai Helper". There is a button called "Scan model". Go to extension tab "Civitai Helper". There is a button called "Scan model".

View File

@ -72,7 +72,7 @@ def on_ui_tabs():
with gr.Column(): with gr.Column():
gr.Markdown("### Scan Models for Civitai") gr.Markdown("### Scan Models for Civitai")
with gr.Row(): with gr.Row():
low_memory_sha_ckb = gr.Checkbox(label="Memory Optimized SHA256", value=low_memory_sha, elem_id="ch_low_memory_sha_ckb") low_memory_sha_ckb = gr.Checkbox(label="Memory Optimized SHA256", value=low_memory_sha, visible=False, elem_id="ch_low_memory_sha_ckb")
max_size_preview_ckb = gr.Checkbox(label="Download Max Size Preview", value=max_size_preview, elem_id="ch_max_size_preview_ckb") max_size_preview_ckb = gr.Checkbox(label="Download Max Size Preview", value=max_size_preview, elem_id="ch_max_size_preview_ckb")
skip_nsfw_preview_ckb = gr.Checkbox(label="SKip NSFW Preview images", value=skip_nsfw_preview, elem_id="ch_skip_nsfw_preview_ckb") skip_nsfw_preview_ckb = gr.Checkbox(label="SKip NSFW Preview images", value=skip_nsfw_preview, elem_id="ch_skip_nsfw_preview_ckb")

View File

@ -29,6 +29,7 @@ def scan_model(low_memory_sha, max_size_preview, skip_nsfw_preview):
info_file = base + civitai.suffix + model.info_ext info_file = base + civitai.suffix + model.info_ext
# check info file # check info file
if not os.path.isfile(info_file): if not os.path.isfile(info_file):
util.printD("Creating model info for: " + filename)
# get model's sha256 # get model's sha256
hash = util.gen_file_sha256(item, low_memory_sha) hash = util.gen_file_sha256(item, low_memory_sha)

View File

@ -12,12 +12,17 @@ def gen_file_sha256(filname, is_low_memory=True):
printD("Calculate SHA256") printD("Calculate SHA256")
hash_sha256 = hashlib.sha256() hash_sha256 = hashlib.sha256()
with open(filname, "rb") as f: with open(filname, "rb") as f:
if is_low_memory: # force to use Memory Optimized SHA256
# In case people don't understand this and uncheck it then stuck their system
printD("Using Memory Optimized SHA256") printD("Using Memory Optimized SHA256")
for chunk in iter(lambda: f.read(4096), b""): for chunk in iter(lambda: f.read(4096), b""):
hash_sha256.update(chunk) hash_sha256.update(chunk)
else: # if is_low_memory:
hash_sha256.update(f.read()) # printD("Using Memory Optimized SHA256")
# for chunk in iter(lambda: f.read(4096), b""):
# hash_sha256.update(chunk)
# else:
# hash_sha256.update(f.read())
hash_value = hash_sha256.hexdigest() hash_value = hash_sha256.hexdigest()