@@ -418,41 +418,41 @@ def hf_download_model(hub_id: str, token, variant, revision, mirror, custom_pipe
418
418
def civit_search_model (name , tag , model_type ):
419
419
# types = 'LORA' if model_type == 'LoRA' else 'Checkpoint'
420
420
url = 'https://civitai.com/api/v1/models?limit=25&Sort=Newest'
421
- if model_type == 'SD 1.5' or model_type == 'SD XL ' :
421
+ if model_type == 'Model ' :
422
422
url += '&types=Checkpoint'
423
423
elif model_type == 'LoRA' :
424
- url += '&types=LORA'
424
+ url += '&types=LORA&types=DoRA&types=LoCon '
425
425
elif model_type == 'Embedding' :
426
426
url += '&types=TextualInversion'
427
+ elif model_type == 'VAE' :
428
+ url += '&types=VAE'
427
429
if name is not None and len (name ) > 0 :
428
430
url += f'&query={ name } '
429
431
if tag is not None and len (tag ) > 0 :
430
432
url += f'&tag={ tag } '
431
433
r = req (url )
432
434
log .debug (f'CivitAI search: name="{ name } " tag={ tag or "none" } url="{ url } " status={ r .status_code } ' )
433
435
if r .status_code != 200 :
436
+ log .warning (f'CivitAI search: name="{ name } " tag={ tag } status={ r .status_code } ' )
437
+ return [], gr .update (visible = False , value = []), gr .update (visible = False , value = None ), gr .update (visible = False , value = None )
438
+ try :
439
+ body = r .json ()
440
+ except Exception as e :
441
+ log .error (f'CivitAI search: name="{ name } " tag={ tag } { e } ' )
434
442
return [], gr .update (visible = False , value = []), gr .update (visible = False , value = None ), gr .update (visible = False , value = None )
435
- body = r .json ()
436
443
nonlocal data
437
444
data = body .get ('items' , [])
438
445
data1 = []
439
446
for model in data :
440
447
found = 0
441
- if model_type == 'LoRA' and model ['type' ] in ['LORA ' , 'LoCon ' ]:
448
+ if model_type == 'LoRA' and model ['type' ]. lower () in ['lora ' , 'locon' , 'dora' , 'lycoris ' ]:
442
449
found += 1
443
- elif model_type == 'Embedding' and model ['type' ] == 'TextualInversion' :
450
+ elif model_type == 'Embedding' and model ['type' ].lower () in ['textualinversion' , 'embedding' ]:
451
+ found += 1
452
+ elif model_type == 'Model' and model ['type' ].lower () in ['checkpoint' ]:
453
+ found += 1
454
+ elif model_type == 'VAE' and model ['type' ].lower () in ['vae' ]:
444
455
found += 1
445
- elif model_type .startswith ('SD' ) and model ['type' ] == 'Checkpoint' :
446
- for variant in model ['modelVersions' ]:
447
- if model_type == 'SD 1.5' :
448
- if 'SD 1.' in variant ['baseModel' ]:
449
- found += 1
450
- if model_type == 'SD XL' :
451
- if 'SDXL' in variant ['baseModel' ]:
452
- found += 1
453
- else :
454
- if 'SD 1.' not in variant ['baseModel' ] and 'SDXL' not in variant ['baseModel' ]:
455
- found += 1
456
456
elif model_type == 'Other' :
457
457
found += 1
458
458
if found > 0 :
@@ -464,8 +464,7 @@ def civit_search_model(name, tag, model_type):
464
464
model ['stats' ]['rating' ]
465
465
])
466
466
res = f'Search result: name={ name } tag={ tag or "none" } type={ model_type } models={ len (data1 )} '
467
- return res , gr .update (visible = len (data1 ) > 0 , value = data1 if len (data1 ) > 0 else []), gr .update (
468
- visible = False , value = None ), gr .update (visible = False , value = None )
467
+ return res , gr .update (visible = len (data1 ) > 0 , value = data1 if len (data1 ) > 0 else []), gr .update (visible = False , value = None ), gr .update (visible = False , value = None )
469
468
470
469
def civit_select1 (evt : gr .SelectData , in_data ):
471
470
model_id = in_data [evt .index [0 ]][0 ]
@@ -596,7 +595,7 @@ def civit_search_metadata(rehash, title):
596
595
gr .HTML ('<h2>Search for models</h2>' )
597
596
with gr .Row ():
598
597
with gr .Column (scale = 1 ):
599
- civit_model_type = gr .Dropdown (label = 'Model type' , choices = ['SD 1.5 ' , 'SD XL ' , 'LoRA ' , 'Embedding ' , 'Other' ], value = 'LoRA ' )
598
+ civit_model_type = gr .Dropdown (label = 'Model type' , choices = ['Model ' , 'LoRA ' , 'Embedding ' , 'VAE ' , 'Other' ], value = 'Model ' )
600
599
with gr .Column (scale = 15 ):
601
600
with gr .Row ():
602
601
civit_search_text = gr .Textbox ('' , label = 'Search models' , placeholder = 'keyword' )
0 commit comments