Spaces:
Runtime error
Runtime error
PierreHanna
commited on
Commit
•
03e603a
1
Parent(s):
ee994fc
Update app.py
Browse files
app.py
CHANGED
@@ -18,13 +18,7 @@ embed_html2 = '" title="YouTube video player" frameborder="0" allow="acceleromet
|
|
18 |
os.environ['CUDA_VISIBLE_DEVICES'] = '-1'
|
19 |
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
|
20 |
|
21 |
-
#
|
22 |
-
|
23 |
-
#python_path = hf_hub_download(repo_id='PierreHanna/AudioSimilarity', repo_type="space", filename='models.py',
|
24 |
-
# use_auth_token='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')
|
25 |
-
#python_path = hf_hub_download(repo_id='PierreHanna/AudioSimilarity', repo_type="space", filename=os.environ['MODEL_FILE'],
|
26 |
-
# use_auth_token=os.environ['TOKEN'])
|
27 |
-
|
28 |
python_path = hf_hub_download(repo_id=os.environ['REPO_ID'], repo_type="space", filename=os.environ['MODEL_FILE'],
|
29 |
use_auth_token=os.environ['TOKEN'])
|
30 |
print(python_path)
|
@@ -54,32 +48,11 @@ def process_file(input_path):
|
|
54 |
return process(input_path, '')
|
55 |
|
56 |
def process(audio_file, embed_html_all):
|
57 |
-
#model = openl3.models.load_audio_embedding_model(input_repr="linear", content_type="music",embedding_size=512)
|
58 |
-
#audio, sr = librosa.load(audio_file, mono=True)
|
59 |
-
#emb, ts = openl3.get_audio_embedding(audio, sr, model=model)
|
60 |
-
#emb = np.mean(emb, axis=0)
|
61 |
-
#print("SHAPE ", emb.shape)
|
62 |
-
|
63 |
emb, ts = get_embed(audio_file)
|
64 |
-
|
65 |
-
#ind = faiss.read_index("index.index")
|
66 |
-
#ind_filenames = pickle.load(open('index.filenames','rb'))
|
67 |
ind, ind_filenames = load_index()
|
68 |
-
|
69 |
-
#dict_bmg = pickle.load(open('dict_bmg.pickle','rb')) # filename to url
|
70 |
catalog = load_catalog()
|
71 |
-
|
72 |
D, I = do_search(emb, ind)
|
73 |
-
|
74 |
-
|
75 |
-
#top1 = dict_bmg[ind_filenames[I[0][0]]]
|
76 |
-
#top2 = dict_bmg[ind_filenames[I[0][1]]]
|
77 |
-
#top3 = dict_bmg[ind_filenames[I[0][2]]]
|
78 |
-
#top4 = dict_bmg[ind_filenames[I[0][3]]]
|
79 |
-
#top5 = dict_bmg[ind_filenames[I[0][4]]]
|
80 |
-
|
81 |
-
top1, top2, top3, top4, top5 = get_top(I, ind_filenames, catalog)
|
82 |
-
|
83 |
return top1, top2, top3, top4, top5
|
84 |
|
85 |
|
|
|
18 |
os.environ['CUDA_VISIBLE_DEVICES'] = '-1'
|
19 |
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
|
20 |
|
21 |
+
#
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
python_path = hf_hub_download(repo_id=os.environ['REPO_ID'], repo_type="space", filename=os.environ['MODEL_FILE'],
|
23 |
use_auth_token=os.environ['TOKEN'])
|
24 |
print(python_path)
|
|
|
48 |
return process(input_path, '')
|
49 |
|
50 |
def process(audio_file, embed_html_all):
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
emb, ts = get_embed(audio_file)
|
|
|
|
|
|
|
52 |
ind, ind_filenames = load_index()
|
|
|
|
|
53 |
catalog = load_catalog()
|
|
|
54 |
D, I = do_search(emb, ind)
|
55 |
+
top1, top2, top3, top4, top5 = get_top(I, ind_filenames, catalog)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
return top1, top2, top3, top4, top5
|
57 |
|
58 |
|