Spaces:
Sleeping
Sleeping
SpyCoder77
commited on
Commit
•
ad41eed
1
Parent(s):
060e154
Update src/webui.py
Browse files- src/webui.py +10 -18
src/webui.py
CHANGED
@@ -4,7 +4,6 @@ import shutil
|
|
4 |
import urllib.request
|
5 |
import zipfile
|
6 |
from argparse import ArgumentParser
|
7 |
-
import spaces
|
8 |
import gradio as gr
|
9 |
import requests
|
10 |
|
@@ -107,26 +106,19 @@ def upload_local_model(zip_path, dir_name, progress=gr.Progress()):
|
|
107 |
def filter_models(tags, query):
|
108 |
models_table = []
|
109 |
|
110 |
-
# no filter
|
111 |
if len(tags) == 0 and len(query) == 0:
|
112 |
for model in public_models['voice_models']:
|
113 |
models_table.append([model['name'], model['description'], model['credit'], model['url'], model['tags']])
|
114 |
-
|
115 |
-
# filter based on tags and query
|
116 |
elif len(tags) > 0 and len(query) > 0:
|
117 |
for model in public_models['voice_models']:
|
118 |
if all(tag in model['tags'] for tag in tags):
|
119 |
model_attributes = f"{model['name']} {model['description']} {model['credit']} {' '.join(model['tags'])}".lower()
|
120 |
if query.lower() in model_attributes:
|
121 |
models_table.append([model['name'], model['description'], model['credit'], model['url'], model['tags']])
|
122 |
-
|
123 |
-
# filter based on only tags
|
124 |
elif len(tags) > 0:
|
125 |
for model in public_models['voice_models']:
|
126 |
if all(tag in model['tags'] for tag in tags):
|
127 |
models_table.append([model['name'], model['description'], model['credit'], model['url'], model['tags']])
|
128 |
-
|
129 |
-
# filter based on only query
|
130 |
else:
|
131 |
for model in public_models['voice_models']:
|
132 |
model_attributes = f"{model['name']} {model['description']} {model['credit']} {' '.join(model['tags'])}".lower()
|
@@ -182,16 +174,17 @@ if __name__ == '__main__':
|
|
182 |
)
|
183 |
gr.Markdown("Duplicate the old CPU space for use in private: [![Duplicate this Space](https://huggingface.co/datasets/huggingface/badges/raw/main/duplicate-this-space-sm-dark.svg)](https://huggingface.co/spaces/r3gm/AICoverGen_old_stable_cpu?duplicate=true)\n\n")
|
184 |
|
185 |
-
# main tab
|
186 |
with gr.Tab("Find Models"):
|
187 |
-
gr.Textbox(placeholder="Eg: Taylor Swift, Drake", max_lines=1, lines=1)
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
|
|
|
|
195 |
with gr.Tab("Generate"):
|
196 |
|
197 |
with gr.Accordion('Main Options'):
|
@@ -338,7 +331,6 @@ if __name__ == '__main__':
|
|
338 |
|
339 |
app.launch(
|
340 |
share=args.share_enabled,
|
341 |
-
# enable_queue=True,
|
342 |
server_name=None if not args.listen else (args.listen_host or '0.0.0.0'),
|
343 |
server_port=args.listen_port,
|
344 |
)
|
|
|
4 |
import urllib.request
|
5 |
import zipfile
|
6 |
from argparse import ArgumentParser
|
|
|
7 |
import gradio as gr
|
8 |
import requests
|
9 |
|
|
|
106 |
def filter_models(tags, query):
|
107 |
models_table = []
|
108 |
|
|
|
109 |
if len(tags) == 0 and len(query) == 0:
|
110 |
for model in public_models['voice_models']:
|
111 |
models_table.append([model['name'], model['description'], model['credit'], model['url'], model['tags']])
|
|
|
|
|
112 |
elif len(tags) > 0 and len(query) > 0:
|
113 |
for model in public_models['voice_models']:
|
114 |
if all(tag in model['tags'] for tag in tags):
|
115 |
model_attributes = f"{model['name']} {model['description']} {model['credit']} {' '.join(model['tags'])}".lower()
|
116 |
if query.lower() in model_attributes:
|
117 |
models_table.append([model['name'], model['description'], model['credit'], model['url'], model['tags']])
|
|
|
|
|
118 |
elif len(tags) > 0:
|
119 |
for model in public_models['voice_models']:
|
120 |
if all(tag in model['tags'] for tag in tags):
|
121 |
models_table.append([model['name'], model['description'], model['credit'], model['url'], model['tags']])
|
|
|
|
|
122 |
else:
|
123 |
for model in public_models['voice_models']:
|
124 |
model_attributes = f"{model['name']} {model['description']} {model['credit']} {' '.join(model['tags'])}".lower()
|
|
|
174 |
)
|
175 |
gr.Markdown("Duplicate the old CPU space for use in private: [![Duplicate this Space](https://huggingface.co/datasets/huggingface/badges/raw/main/duplicate-this-space-sm-dark.svg)](https://huggingface.co/spaces/r3gm/AICoverGen_old_stable_cpu?duplicate=true)\n\n")
|
176 |
|
|
|
177 |
with gr.Tab("Find Models"):
|
178 |
+
model_query = gr.Textbox(placeholder="Eg: Taylor Swift, Drake", max_lines=1, lines=1)
|
179 |
+
model_display = gr.Dataframe(
|
180 |
+
headers=["name", "author", "url"],
|
181 |
+
datatype=["str", "str", "str"],
|
182 |
+
row_count=5,
|
183 |
+
col_count=(3, "fixed"),
|
184 |
+
)
|
185 |
+
filter_btn = gr.Button("Search")
|
186 |
+
filter_btn.click(lambda query: filter_models([], query), inputs=model_query, outputs=model_display)
|
187 |
+
|
188 |
with gr.Tab("Generate"):
|
189 |
|
190 |
with gr.Accordion('Main Options'):
|
|
|
331 |
|
332 |
app.launch(
|
333 |
share=args.share_enabled,
|
|
|
334 |
server_name=None if not args.listen else (args.listen_host or '0.0.0.0'),
|
335 |
server_port=args.listen_port,
|
336 |
)
|