Spaces:
Paused
Paused
Replace static model list with function for removing extension and id
Browse files
app.py
CHANGED
|
@@ -10,54 +10,6 @@ import PIL
|
|
| 10 |
from PIL.ExifTags import TAGS
|
| 11 |
import html
|
| 12 |
|
| 13 |
-
model_names = {
|
| 14 |
-
'absolutereality_V16': 'absolutereality_V16.safetensors [37db0fc3]',
|
| 15 |
-
'absolutereality_v181': 'absolutereality_v181.safetensors [3d9d4d2b]',
|
| 16 |
-
'analog-diffusion-1.0': 'analog-diffusion-1.0.ckpt [9ca13f02]',
|
| 17 |
-
'anythingv3_0-pruned': 'anythingv3_0-pruned.ckpt [2700c435]',
|
| 18 |
-
'anything-v4.5-pruned': 'anything-v4.5-pruned.ckpt [65745d25]',
|
| 19 |
-
'anythingV5_PrtRE': 'anythingV5_PrtRE.safetensors [893e49b9]',
|
| 20 |
-
'AOM3A3_orangemixs': 'AOM3A3_orangemixs.safetensors [9600da17]',
|
| 21 |
-
'childrensStories_v13D': 'childrensStories_v13D.safetensors [9dfaabcb]',
|
| 22 |
-
'childrensStories_v1SemiReal': 'childrensStories_v1SemiReal.safetensors [a1c56dbb]',
|
| 23 |
-
'childrensStories_v1ToonAnime': 'childrensStories_v1ToonAnime.safetensors [2ec7b88b]',
|
| 24 |
-
'cyberrealistic_v33': 'cyberrealistic_v33.safetensors [82b0d085]',
|
| 25 |
-
'deliberate_v2': 'deliberate_v2.safetensors [10ec4b29]',
|
| 26 |
-
'deliberate_v3': 'deliberate_v3.safetensors [afd9d2d4]',
|
| 27 |
-
'dreamlike-anime-1.0': 'dreamlike-anime-1.0.safetensors [4520e090]',
|
| 28 |
-
'dreamlike-diffusion-1.0': 'dreamlike-diffusion-1.0.safetensors [5c9fd6e0]',
|
| 29 |
-
'dreamlike-photoreal-2.0': 'dreamlike-photoreal-2.0.safetensors [fdcf65e7]',
|
| 30 |
-
'dreamshaper_6BakedVae': 'dreamshaper_6BakedVae.safetensors [114c8abb]',
|
| 31 |
-
'dreamshaper_7': 'dreamshaper_7.safetensors [5cf5ae06]',
|
| 32 |
-
'dreamshaper_8': 'dreamshaper_8.safetensors [9d40847d]',
|
| 33 |
-
'edgeOfRealism_eorV20': 'edgeOfRealism_eorV20.safetensors [3ed5de15]',
|
| 34 |
-
'EimisAnimeDiffusion_V1': 'EimisAnimeDiffusion_V1.ckpt [4f828a15]',
|
| 35 |
-
'elldreths-vivid-mix': 'elldreths-vivid-mix.safetensors [342d9d26]',
|
| 36 |
-
'epicrealism_naturalSinRC1VAE': 'epicrealism_naturalSinRC1VAE.safetensors [90a4c676]',
|
| 37 |
-
'ICantBelieveItsNotPhotography_seco': 'ICantBelieveItsNotPhotography_seco.safetensors [4e7a3dfd]',
|
| 38 |
-
'juggernaut_aftermath': 'juggernaut_aftermath.safetensors [5e20c455]',
|
| 39 |
-
'lyriel_v16': 'lyriel_v16.safetensors [68fceea2]',
|
| 40 |
-
'mechamix_v10': 'mechamix_v10.safetensors [ee685731]',
|
| 41 |
-
'meinamix_meinaV9': 'meinamix_meinaV9.safetensors [2ec66ab0]',
|
| 42 |
-
'meinamix_meinaV11': 'meinamix_meinaV11.safetensors [b56ce717]',
|
| 43 |
-
'openjourney_V4': 'openjourney_V4.ckpt [ca2f377f]',
|
| 44 |
-
'portraitplus_V1.0': 'portraitplus_V1.0.safetensors [1400e684]',
|
| 45 |
-
'Realistic_Vision_V1.4-pruned-fp16': 'Realistic_Vision_V1.4-pruned-fp16.safetensors [8d21810b]',
|
| 46 |
-
'Realistic_Vision_V2.0': 'Realistic_Vision_V2.0.safetensors [79587710]',
|
| 47 |
-
'Realistic_Vision_V4.0': 'Realistic_Vision_V4.0.safetensors [29a7afaa]',
|
| 48 |
-
'Realistic_Vision_V5.0': 'Realistic_Vision_V5.0.safetensors [614d1063]',
|
| 49 |
-
'redshift_diffusion-V10': 'redshift_diffusion-V10.safetensors [1400e684]',
|
| 50 |
-
'revAnimated_v122': 'revAnimated_v122.safetensors [3f4fefd9]',
|
| 51 |
-
'rundiffusionFX25D_v10': 'rundiffusionFX25D_v10.safetensors [cd12b0ee]',
|
| 52 |
-
'rundiffusionFX_v10': 'rundiffusionFX_v10.safetensors [cd4e694d]',
|
| 53 |
-
'sdv1_4': 'sdv1_4.ckpt [7460a6fa]',
|
| 54 |
-
'v1-5-pruned-emaonly': 'v1-5-pruned-emaonly.safetensors [d7049739]',
|
| 55 |
-
'shoninsBeautiful_v10': 'shoninsBeautiful_v10.safetensors [25d8c546]',
|
| 56 |
-
'theallys-mix-ii-churned': 'theallys-mix-ii-churned.safetensors [5d9225a4]',
|
| 57 |
-
'timeless-1.0': 'timeless-1.0.ckpt [7c4971d4]',
|
| 58 |
-
'toonyou_beta6': 'toonyou_beta6.safetensors [980f6b15]'
|
| 59 |
-
}
|
| 60 |
-
|
| 61 |
|
| 62 |
class Prodia:
|
| 63 |
def __init__(self, api_key, base=None):
|
|
@@ -128,6 +80,16 @@ def image_to_base64(image_path):
|
|
| 128 |
|
| 129 |
return img_str.decode('utf-8') # Convert bytes to string
|
| 130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
def get_data(text):
|
| 132 |
results = {}
|
| 133 |
patterns = {
|
|
@@ -193,6 +155,12 @@ def send_to_txt2img(image):
|
|
| 193 |
|
| 194 |
|
| 195 |
prodia_client = Prodia(api_key=os.getenv("PRODIA_API_KEY"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
|
| 197 |
def flip_text(prompt, negative_prompt, model, steps, sampler, cfg_scale, width, height, seed):
|
| 198 |
result = prodia_client.generate({
|
|
|
|
| 10 |
from PIL.ExifTags import TAGS
|
| 11 |
import html
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
class Prodia:
|
| 15 |
def __init__(self, api_key, base=None):
|
|
|
|
| 80 |
|
| 81 |
return img_str.decode('utf-8') # Convert bytes to string
|
| 82 |
|
| 83 |
+
def remove_id_and_ext(text):
|
| 84 |
+
text = re.sub(r'\[.*\]$', '', text)
|
| 85 |
+
extension = text[-12:].strip()
|
| 86 |
+
print(extension)
|
| 87 |
+
if extension == "safetensors":
|
| 88 |
+
text = text[:-13]
|
| 89 |
+
elif extension == "ckpt":
|
| 90 |
+
text = text[:-4]
|
| 91 |
+
return text
|
| 92 |
+
|
| 93 |
def get_data(text):
|
| 94 |
results = {}
|
| 95 |
patterns = {
|
|
|
|
| 155 |
|
| 156 |
|
| 157 |
prodia_client = Prodia(api_key=os.getenv("PRODIA_API_KEY"))
|
| 158 |
+
model_list = prodia_client.list_models()
|
| 159 |
+
model_names = {}
|
| 160 |
+
|
| 161 |
+
for model_name in model_list:
|
| 162 |
+
name_without_ext = remove_id_and_ext(model_name)
|
| 163 |
+
model_names[name_without_ext] = model_name
|
| 164 |
|
| 165 |
def flip_text(prompt, negative_prompt, model, steps, sampler, cfg_scale, width, height, seed):
|
| 166 |
result = prodia_client.generate({
|