mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 09:14:35 +02:00
civitai enable embedding download
This commit is contained in:
@@ -238,6 +238,7 @@ As of this release, default backend is set to **diffusers** as its more feature
|
||||
- reduce system memory usage after compile
|
||||
- fix cache loading with multiple models
|
||||
- **fixes**
|
||||
- civitai model download: enable downloads of embeddings
|
||||
- ipadapter: allow changing of model/image on-the-fly
|
||||
- ipadapter: fix fallback of cross-attention on unload
|
||||
- rebasin iterations, thanks @AI-Casanova
|
||||
|
||||
@@ -80,11 +80,14 @@ def download_civit_model_thread(model_name, model_url, model_path, model_type, p
|
||||
if model_type == 'LoRA':
|
||||
model_file = os.path.join(shared.opts.lora_dir, model_path, model_name)
|
||||
temp_file = os.path.join(shared.opts.lora_dir, model_path, temp_file)
|
||||
elif model_type == 'Embedding':
|
||||
model_file = os.path.join(shared.opts.embeddings_dir, model_path, model_name)
|
||||
temp_file = os.path.join(shared.opts.embeddings_dir, model_path, temp_file)
|
||||
else:
|
||||
model_file = os.path.join(shared.opts.ckpt_dir, model_path, model_name)
|
||||
temp_file = os.path.join(shared.opts.ckpt_dir, model_path, temp_file)
|
||||
|
||||
res = f'CivitAI download: name={model_name} url={model_url} path={model_path} temp={temp_file}'
|
||||
res = f'CivitAI download: name="{model_name}" url="{model_url}" path="{model_path}" temp="{temp_file}"'
|
||||
if os.path.isfile(model_file):
|
||||
res += ' already exists'
|
||||
shared.log.warning(res)
|
||||
@@ -101,7 +104,7 @@ def download_civit_model_thread(model_name, model_url, model_path, model_type, p
|
||||
|
||||
r = shared.req(model_url, headers=headers, stream=True)
|
||||
total_size = int(r.headers.get('content-length', 0))
|
||||
res += f' size={round((starting_pos + total_size)/1024/1024)}Mb'
|
||||
res += f' size={round((starting_pos + total_size)/1024/1024, 2)}Mb'
|
||||
shared.log.info(res)
|
||||
shared.state.begin('civitai')
|
||||
block_size = 16384 # 16KB blocks
|
||||
@@ -117,7 +120,7 @@ def download_civit_model_thread(model_name, model_url, model_path, model_type, p
|
||||
written = written + len(data)
|
||||
f.write(data)
|
||||
download_pbar.update(task, description="Download", completed=written)
|
||||
if written < 1024 * 1024: # min threshold
|
||||
if written < 1024: # min threshold
|
||||
os.remove(temp_file)
|
||||
raise ValueError(f'removed invalid download: bytes={written}')
|
||||
if preview is not None:
|
||||
|
||||
+24
-13
@@ -417,13 +417,19 @@ def create_ui():
|
||||
|
||||
def civit_search_model(name, tag, model_type):
|
||||
# types = 'LORA' if model_type == 'LoRA' else 'Checkpoint'
|
||||
url = 'https://civitai.com/api/v1/models?limit=25&&Sort=Newest'
|
||||
url = 'https://civitai.com/api/v1/models?limit=25&Sort=Newest'
|
||||
if model_type == 'SD 1.5' or model_type == 'SD XL':
|
||||
url += '&types=Checkpoint'
|
||||
elif model_type == 'LoRA':
|
||||
url += '&types=LORA'
|
||||
elif model_type == 'Embedding':
|
||||
url += '&types=TextualInversion'
|
||||
if name is not None and len(name) > 0:
|
||||
url += f'&query={name}'
|
||||
if tag is not None and len(tag) > 0:
|
||||
url += f'&tag={tag}'
|
||||
r = req(url)
|
||||
log.debug(f'CivitAI search: name="{name}" tag={tag or "none"} status={r.status_code}')
|
||||
log.debug(f'CivitAI search: name="{name}" tag={tag or "none"} url="{url}" status={r.status_code}')
|
||||
if r.status_code != 200:
|
||||
return [], [], []
|
||||
body = r.json()
|
||||
@@ -434,16 +440,21 @@ def create_ui():
|
||||
found = 0
|
||||
if model_type == 'LoRA' and model['type'] in ['LORA', 'LoCon']:
|
||||
found += 1
|
||||
for variant in model['modelVersions']:
|
||||
if model_type == 'SD 1.5':
|
||||
if 'SD 1.' in variant['baseModel']:
|
||||
found += 1
|
||||
if model_type == 'SD XL':
|
||||
if 'SDXL' in variant['baseModel']:
|
||||
found += 1
|
||||
else:
|
||||
if 'SD 1.' not in variant['baseModel'] and 'SDXL' not in variant['baseModel']:
|
||||
found += 1
|
||||
elif model_type == 'Embedding' and model['type'] == 'TextualInversion':
|
||||
found += 1
|
||||
elif model_type.startswith('SD') and model['type'] == 'Checkpoint':
|
||||
for variant in model['modelVersions']:
|
||||
if model_type == 'SD 1.5':
|
||||
if 'SD 1.' in variant['baseModel']:
|
||||
found += 1
|
||||
if model_type == 'SD XL':
|
||||
if 'SDXL' in variant['baseModel']:
|
||||
found += 1
|
||||
else:
|
||||
if 'SD 1.' not in variant['baseModel'] and 'SDXL' not in variant['baseModel']:
|
||||
found += 1
|
||||
elif model_type == 'Other':
|
||||
found += 1
|
||||
if found > 0:
|
||||
data1.append([
|
||||
model['id'],
|
||||
@@ -581,7 +592,7 @@ def create_ui():
|
||||
gr.HTML('<h2>Search for models</h2>')
|
||||
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')
|
||||
civit_model_type = gr.Dropdown(label='Model type', choices=['SD 1.5', 'SD XL', 'LoRA', 'Embedding', 'Other'], value='LoRA')
|
||||
with gr.Column(scale=15):
|
||||
with gr.Row():
|
||||
civit_search_text = gr.Textbox('', label='Search models', placeholder='keyword')
|
||||
|
||||
Reference in New Issue
Block a user