Update src/webui.py
Browse files- src/webui.py +3 -50
src/webui.py
CHANGED
|
@@ -40,15 +40,7 @@ def get_current_models(models_dir):
|
|
| 40 |
def update_models_list():
|
| 41 |
models_l = get_current_models(rvc_models_dir)
|
| 42 |
return gr.update(choices=models_l)
|
| 43 |
-
|
| 44 |
-
def load_public_models():
|
| 45 |
-
models_table = []
|
| 46 |
-
for model in public_models['voice_models']:
|
| 47 |
-
if not model['name'] in voice_models:
|
| 48 |
-
model = [model['name'], model['description'], model['credit'], model['url'], ', '.join(model['tags'])]
|
| 49 |
-
models_table.append(model)
|
| 50 |
-
tags = list(public_models['tags'].keys())
|
| 51 |
-
return gr.update(value=models_table), gr.update(choices=tags)
|
| 52 |
|
| 53 |
def extract_zip(extraction_folder, zip_name):
|
| 54 |
os.makedirs(extraction_folder)
|
|
@@ -109,28 +101,7 @@ def upload_local_model(zip_path, dir_name, progress=gr.Progress()):
|
|
| 109 |
except Exception as e:
|
| 110 |
raise gr.Error(str(e))
|
| 111 |
|
| 112 |
-
|
| 113 |
-
models_table = []
|
| 114 |
-
if len(tags) == 0 and len(query) == 0:
|
| 115 |
-
for model in public_models['voice_models']:
|
| 116 |
-
models_table.append([model['name'], model['description'], model['credit'], model['url'], model['tags']])
|
| 117 |
-
elif len(tags) > 0 and len(query) > 0:
|
| 118 |
-
for model in public_models['voice_models']:
|
| 119 |
-
if all(tag in model['tags'] for tag in tags):
|
| 120 |
-
model_attributes = f"{model['name']} {model['description']} {model['credit']} {' '.join(model['tags'])}".lower()
|
| 121 |
-
if query.lower() in model_attributes:
|
| 122 |
-
models_table.append([model['name'], model['description'], model['credit'], model['url'], model['tags']])
|
| 123 |
-
elif len(tags) > 0:
|
| 124 |
-
for model in public_models['voice_models']:
|
| 125 |
-
if all(tag in model['tags'] for tag in tags):
|
| 126 |
-
models_table.append([model['name'], model['description'], model['credit'], model['url'], model['tags']])
|
| 127 |
-
else:
|
| 128 |
-
for model in public_models['voice_models']:
|
| 129 |
-
model_attributes = f"{model['name']} {model['description']} {model['credit']} {' '.join(model['tags'])}".lower()
|
| 130 |
-
if query.lower() in model_attributes:
|
| 131 |
-
models_table.append([model['name'], model['description'], model['credit'], model['url'], model['tags']])
|
| 132 |
-
return gr.update(value=models_table)
|
| 133 |
-
|
| 134 |
def pub_dl_autofill(pub_models, event: gr.SelectData):
|
| 135 |
return gr.update(value=pub_models.loc[event.index[0], 'URL']), gr.update(value=pub_models.loc[event.index[0], 'Model Name'])
|
| 136 |
|
|
@@ -313,25 +284,7 @@ if __name__ == '__main__':
|
|
| 313 |
cache_examples=False,
|
| 314 |
)
|
| 315 |
|
| 316 |
-
|
| 317 |
-
gr.Markdown('## How to use')
|
| 318 |
-
gr.Markdown('- Click Initialize public models table')
|
| 319 |
-
gr.Markdown('- Filter models using tags or search bar')
|
| 320 |
-
gr.Markdown('- Select a row to autofill the download link and model name')
|
| 321 |
-
gr.Markdown('- Click Download')
|
| 322 |
-
|
| 323 |
-
with gr.Row():
|
| 324 |
-
pub_zip_link = gr.Text(label='Download link to model')
|
| 325 |
-
pub_model_name = gr.Text(label='Model name')
|
| 326 |
-
|
| 327 |
-
with gr.Row():
|
| 328 |
-
download_pub_btn = gr.Button('Download 🌐', variant='primary', scale=19)
|
| 329 |
-
pub_dl_output_message = gr.Text(label='Output Message', interactive=False, scale=20)
|
| 330 |
-
|
| 331 |
-
filter_tags = gr.CheckboxGroup(value=[], label='Show voice models with tags', choices=[])
|
| 332 |
-
search_query = gr.Text(label='Search')
|
| 333 |
-
load_public_models_button = gr.Button(value='Initialize public models table', variant='primary')
|
| 334 |
-
|
| 335 |
public_models_table = gr.DataFrame(value=[], headers=['Model Name', 'Description', 'Credit', 'URL', 'Tags'], label='Available Public Models', interactive=False)
|
| 336 |
public_models_table.select(pub_dl_autofill, inputs=[public_models_table], outputs=[pub_zip_link, pub_model_name])
|
| 337 |
load_public_models_button.click(load_public_models, outputs=[public_models_table, filter_tags])
|
|
|
|
| 40 |
def update_models_list():
|
| 41 |
models_l = get_current_models(rvc_models_dir)
|
| 42 |
return gr.update(choices=models_l)
|
| 43 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
def extract_zip(extraction_folder, zip_name):
|
| 46 |
os.makedirs(extraction_folder)
|
|
|
|
| 101 |
except Exception as e:
|
| 102 |
raise gr.Error(str(e))
|
| 103 |
|
| 104 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
def pub_dl_autofill(pub_models, event: gr.SelectData):
|
| 106 |
return gr.update(value=pub_models.loc[event.index[0], 'URL']), gr.update(value=pub_models.loc[event.index[0], 'Model Name'])
|
| 107 |
|
|
|
|
| 284 |
cache_examples=False,
|
| 285 |
)
|
| 286 |
|
| 287 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
public_models_table = gr.DataFrame(value=[], headers=['Model Name', 'Description', 'Credit', 'URL', 'Tags'], label='Available Public Models', interactive=False)
|
| 289 |
public_models_table.select(pub_dl_autofill, inputs=[public_models_table], outputs=[pub_zip_link, pub_model_name])
|
| 290 |
load_public_models_button.click(load_public_models, outputs=[public_models_table, filter_tags])
|