Spaces:
Running
Running
admin
commited on
Commit
·
2ac0792
1
Parent(s):
d323e45
fix examples
Browse files
app.py
CHANGED
@@ -166,19 +166,18 @@ if __name__ == "__main__":
|
|
166 |
|
167 |
os.environ["PATH"] = f"{folder_path}:{os.environ.get('PATH', '')}"
|
168 |
|
169 |
-
models = get_modelist()
|
170 |
examples = []
|
171 |
example_mp3s = find_mp3_files()
|
172 |
-
model_num = len(models)
|
173 |
for mp3 in example_mp3s:
|
174 |
-
examples.append([mp3, models[
|
175 |
|
176 |
with gr.Blocks() as demo:
|
177 |
gr.Interface(
|
178 |
fn=inference,
|
179 |
inputs=[
|
180 |
gr.Audio(label="Upload MP3", type="filepath"),
|
181 |
-
gr.Dropdown(choices=models, label="Select a model", value=models[
|
182 |
],
|
183 |
outputs=[
|
184 |
gr.Textbox(label="Audio filename", show_copy_button=True),
|
|
|
166 |
|
167 |
os.environ["PATH"] = f"{folder_path}:{os.environ.get('PATH', '')}"
|
168 |
|
169 |
+
models = get_modelist(assign_model="VGG19_BN_cqt")
|
170 |
examples = []
|
171 |
example_mp3s = find_mp3_files()
|
|
|
172 |
for mp3 in example_mp3s:
|
173 |
+
examples.append([mp3, models[0]])
|
174 |
|
175 |
with gr.Blocks() as demo:
|
176 |
gr.Interface(
|
177 |
fn=inference,
|
178 |
inputs=[
|
179 |
gr.Audio(label="Upload MP3", type="filepath"),
|
180 |
+
gr.Dropdown(choices=models, label="Select a model", value=models[0]),
|
181 |
],
|
182 |
outputs=[
|
183 |
gr.Textbox(label="Audio filename", show_copy_button=True),
|
utils.py
CHANGED
@@ -28,7 +28,7 @@ def find_mp3_files(folder_path=f"{MODEL_DIR}/examples"):
|
|
28 |
return wav_files
|
29 |
|
30 |
|
31 |
-
def get_modelist(model_dir=MODEL_DIR):
|
32 |
try:
|
33 |
entries = os.listdir(model_dir)
|
34 |
except OSError as e:
|
@@ -43,7 +43,11 @@ def get_modelist(model_dir=MODEL_DIR):
|
|
43 |
continue
|
44 |
|
45 |
if os.path.isdir(full_path):
|
46 |
-
|
|
|
|
|
|
|
|
|
47 |
|
48 |
return output
|
49 |
|
|
|
28 |
return wav_files
|
29 |
|
30 |
|
31 |
+
def get_modelist(model_dir=MODEL_DIR, assign_model=""):
|
32 |
try:
|
33 |
entries = os.listdir(model_dir)
|
34 |
except OSError as e:
|
|
|
43 |
continue
|
44 |
|
45 |
if os.path.isdir(full_path):
|
46 |
+
model = os.path.basename(full_path)
|
47 |
+
if assign_model and assign_model.lower() in model:
|
48 |
+
output.insert(0, model)
|
49 |
+
else:
|
50 |
+
output.append(model)
|
51 |
|
52 |
return output
|
53 |
|