fix new k-diffusers

This commit is contained in:
Vladimir Mandic
2023-09-26 08:53:46 -04:00
parent 6650602289
commit 38402c8e6e
6 changed files with 29 additions and 6 deletions
+3
View File
@@ -7,7 +7,10 @@ from modules import timer, errors
initialized = False
logging.getLogger("DeepSpeed").disabled = True
# os.environ.setdefault('OMP_NUM_THREADS', 1)
# os.environ.setdefault('MKL_NUM_THREADS', 1)
import torch # pylint: disable=C0411
# torch.set_num_threads(1)
try:
import intel_extension_for_pytorch as ipex # pylint: disable=import-error, unused-import
errors.log.debug(f'Loaded IPEX=={ipex.__version__}')
+15 -1
View File
@@ -174,10 +174,24 @@ def download_diffusers_model(hub_id: str, cache_dir: str = None, download_config
shared.log.debug(f"Diffusers authentication: {token}")
hf.login(token)
pipeline_dir = None
ok = True
try:
pipeline_dir = DiffusionPipeline.download(hub_id, **download_config)
except Exception as e:
shared.log.error(f"Diffusers download error: {hub_id} {e}")
ok = False
shared.log.warning(f"Diffusers download error: {hub_id} {e}")
if not ok:
try:
download_config.pop('load_connected_pipeline')
download_config.pop('variant')
pipeline_dir = hf.snapshot_download(hub_id, **download_config)
except Exception as e:
shared.log.warning(f"Diffusers hub download error: {hub_id} {e}")
if pipeline_dir is None:
shared.log.error(f"Diffusers no pipeline folder: {hub_id}")
return
try:
model_info_dict = hf.model_info(hub_id).cardData if pipeline_dir is not None else None # pylint: disable=no-member # TODO Diffusers is this real error?
except Exception:
+4 -1
View File
@@ -2,7 +2,10 @@ from collections import deque
import inspect
import torch
import k_diffusion.sampling
from modules import prompt_parser, devices, sd_samplers_common
from modules import prompt_parser
from modules import devices
from modules import sd_samplers_common
from modules.shared import opts, state
import modules.shared as shared
+5 -3
View File
@@ -144,7 +144,7 @@ def create_ui():
model_checkhash_btn.click(fn=sd_models.update_model_hashes, inputs=[], outputs=[models_outcome])
with gr.Row():
model_table = gr.DataFrame(
value = model_data,
value = None,
headers = model_headers,
label = 'Model data',
show_label = True,
@@ -209,6 +209,7 @@ def create_ui():
return f'Diffuser model downloaded: model="{hub_id}"'
with gr.Column(scale=6):
gr.HTML('<h2>Search for models</h2>Select a model from the search results to download<br><br>')
with gr.Row():
hf_search_text = gr.Textbox('', label = 'Search models', placeholder='search huggingface models')
hf_search_btn = ToolButton(value="🔍", label="Search")
@@ -224,12 +225,13 @@ def create_ui():
hf_token = gr.Textbox('', label = 'Huggingface token', placeholder='optional access token for private or gated models')
hf_mirror = gr.Textbox('', label = 'Huggingface mirror', placeholder='optional mirror site for downloads')
with gr.Column(scale=1):
gr.HTML('<br>')
hf_download_model_btn = gr.Button(value="Download model", variant='primary')
with gr.Row():
hf_headers = ['Name', 'Pipeline', 'Tags', 'Downloads', 'Updated', 'URL']
hf_types = ['str', 'str', 'str', 'number', 'date', 'markdown']
hf_results = gr.DataFrame([], label = 'Search results', show_label = True, interactive = False, wrap = True, overflow_row_behaviour = 'paginate', max_rows = 10, headers = hf_headers, datatype = hf_types, type='array')
hf_results = gr.DataFrame(None, label = 'Search results', show_label = True, interactive = False, wrap = True, overflow_row_behaviour = 'paginate', max_rows = 10, headers = hf_headers, datatype = hf_types, type='array')
hf_search_text.submit(fn=hf_search, inputs=[hf_search_text], outputs=[hf_results])
hf_search_btn.click(fn=hf_search, inputs=[hf_search_text], outputs=[hf_results])
@@ -377,7 +379,7 @@ def create_ui():
civit_previews_rehash = gr.Checkbox(value=True, label="Check alternative hash")
with gr.Row(style={'margin-top': '1em'}):
gr.HTML('<h2>Search for models</h2>')
gr.HTML('<h2>Search for models</h2>Select a model, model version and and model variant from the search results to download<br>')
with gr.Row():
with gr.Column(scale=1):
civit_model_type = gr.Dropdown(label='Model type', choices=['SD 1.5', 'SD XL', 'LoRA', 'Other'], value='LoRA')