John6666 commited on
Commit
7099cd8
1 Parent(s): ae677ba

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -27
app.py CHANGED
@@ -1,31 +1,7 @@
1
  import gradio as gr
2
  from pathlib import Path
3
 
4
- models = [
5
- 'cagliostrolab/animagine-xl-3.1',
6
- 'votepurchase/ponyDiffusionV6XL',
7
- 'yodayo-ai/kivotos-xl-2.0',
8
- 'yodayo-ai/holodayo-xl-2.1',
9
- 'stabilityai/stable-diffusion-xl-base-1.0',
10
- 'eienmojiki/Anything-XL',
11
- 'eienmojiki/Starry-XL-v5.2',
12
- 'digiplay/majicMIX_sombre_v2',
13
- 'digiplay/majicMIX_realistic_v7',
14
- 'digiplay/DreamShaper_8',
15
- 'digiplay/BeautifulArt_v1',
16
- 'digiplay/DarkSushi2.5D_v1',
17
- 'digiplay/darkphoenix3D_v1.1',
18
- 'digiplay/BeenYouLiteL11_diffusers',
19
- 'votepurchase/counterfeitV30_v30',
20
- 'Meina/MeinaMix_V11',
21
- 'Meina/MeinaUnreal_V5',
22
- 'Meina/MeinaPastel_V7',
23
- 'KBlueLeaf/Kohaku-XL-Epsilon-rev2',
24
- 'KBlueLeaf/Kohaku-XL-Epsilon-rev3',
25
- 'kayfahaarukku/UrangDiffusion-1.1',
26
- 'Raelina/Rae-Diffusion-XL-V2',
27
- 'Raelina/Raemu-XL-V4',
28
- ]
29
  loaded_models = {}
30
  model_info_dict = {}
31
 
@@ -34,11 +10,38 @@ def list_sub(a, b):
34
  return [e for e in a if e not in b]
35
 
36
 
 
 
 
 
37
  def is_repo_name(s):
38
  import re
39
  return re.fullmatch(r'^[^/]+?/[^/]+?$', s)
40
 
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  def get_t2i_model_info_dict(repo_id: str):
43
  from huggingface_hub import HfApi
44
  api = HfApi()
@@ -176,8 +179,6 @@ with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", css=css) as demo:
176
  f"""This demo was created in reference to the following demos.
177
  - [Nymbo/Flood](https://huggingface.co/spaces/Nymbo/Flood).
178
  - [Yntec/ToyWorldXL](https://huggingface.co/spaces/Yntec/ToyWorldXL).
179
- <br>The first startup takes a mind-boggling amount of time, but not so much after the second.
180
- This is due to the time it takes for Gradio to generate an example image to cache.
181
  """
182
  )
183
  gr.DuplicateButton(value="Duplicate Space")
 
1
  import gradio as gr
2
  from pathlib import Path
3
 
4
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  loaded_models = {}
6
  model_info_dict = {}
7
 
 
10
  return [e for e in a if e not in b]
11
 
12
 
13
+ def list_uniq(l):
14
+ return sorted(set(l), key=l.index)
15
+
16
+
17
  def is_repo_name(s):
18
  import re
19
  return re.fullmatch(r'^[^/]+?/[^/]+?$', s)
20
 
21
 
22
+ def find_model_list(author: str="", tags: list[str]=[], not_tag="", sort: str="last_modified", limit: int=30):
23
+ from huggingface_hub import HfApi
24
+ api = HfApi()
25
+ default_tags = ["diffusers"]
26
+ models = []
27
+ try:
28
+ model_infos = api.list_models(author=author, task="text-to-image", pipeline_tag="text-to-image",
29
+ tags=list_uniq(default_tags + tags), cardData=True, sort=sort, limit=limit * 5)
30
+ except Exception as e:
31
+ print(f"Error: Failed to list models.")
32
+ print(e)
33
+ return models
34
+ for model in model_infos:
35
+ if not model.private and not model.gated:
36
+ if not_tag and not_tag in model.tags: continue
37
+ models.append(model.id)
38
+ if len(models) == limit: break
39
+ return models
40
+
41
+
42
+ models = find_model_list("John6666", ["anime"])
43
+
44
+
45
  def get_t2i_model_info_dict(repo_id: str):
46
  from huggingface_hub import HfApi
47
  api = HfApi()
 
179
  f"""This demo was created in reference to the following demos.
180
  - [Nymbo/Flood](https://huggingface.co/spaces/Nymbo/Flood).
181
  - [Yntec/ToyWorldXL](https://huggingface.co/spaces/Yntec/ToyWorldXL).
 
 
182
  """
183
  )
184
  gr.DuplicateButton(value="Duplicate Space")