Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -40,38 +40,39 @@ def process(prompt, lang):
|
|
| 40 |
print('*************')
|
| 41 |
print()
|
| 42 |
|
| 43 |
-
try :
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
|
|
|
| 75 |
except:
|
| 76 |
return ["",
|
| 77 |
"Error input - please try again", "",
|
|
@@ -79,7 +80,7 @@ def process(prompt, lang):
|
|
| 79 |
"Error input - please try again", "",
|
| 80 |
"Error input - please try again", "",
|
| 81 |
"Error input - please try again", "",]
|
| 82 |
-
|
| 83 |
inputs = [gr.Textbox(label="Input", value="type your description", max_lines=2),
|
| 84 |
gr.Radio(label="Language", choices=["en"], value="en")]
|
| 85 |
|
|
|
|
| 40 |
print('*************')
|
| 41 |
print()
|
| 42 |
|
| 43 |
+
#try :
|
| 44 |
+
embed_query = get_predict(encoder_text, prompt, preprocess_model, model)
|
| 45 |
+
do_normalize(embed_query)
|
| 46 |
+
D, I = get_distance(index, embed_query, TOP)
|
| 47 |
+
#print(I)
|
| 48 |
+
#print(D)
|
| 49 |
+
#print("----")
|
| 50 |
+
#for i in range(len(I[0])):
|
| 51 |
+
# print(audio_names[I[0][i]], " with distance ", D[0][i])
|
| 52 |
+
# print(" url : ", get_url_myma(I[0][i], audio_names, url_dict))
|
| 53 |
|
| 54 |
+
formated = []
|
| 55 |
+
output_csv = f"{file_name}_results_text.csv"
|
| 56 |
+
with open(output_csv, "w") as w:
|
| 57 |
+
writer = csv.writer(w)
|
| 58 |
+
count = 0
|
| 59 |
+
for top in tops:
|
| 60 |
+
if count > max_output:
|
| 61 |
+
break
|
| 62 |
+
|
| 63 |
+
formated.append(file)
|
| 64 |
+
formated.append(top)
|
| 65 |
+
#writer.writerow(dict_catalog[file].values())
|
| 66 |
+
count += 1
|
| 67 |
|
| 68 |
+
|
| 69 |
+
return [output_csv,
|
| 70 |
+
audio_names[I[0][0]].split('.')[0], get_url_myma(I[0][0], audio_names, url_dict),
|
| 71 |
+
audio_names[I[0][1]].split('.')[0], get_url_myma(I[0][1], audio_names, url_dict),
|
| 72 |
+
audio_names[I[0][2]].split('.')[0], get_url_myma(I[0][2], audio_names, url_dict),
|
| 73 |
+
audio_names[I[0][3]].split('.')[0], get_url_myma(I[0][3], audio_names, url_dict),
|
| 74 |
+
audio_names[I[0][4]].split('.')[0], get_url_myma(I[0][4], audio_names, url_dict)]
|
| 75 |
+
'''
|
| 76 |
except:
|
| 77 |
return ["",
|
| 78 |
"Error input - please try again", "",
|
|
|
|
| 80 |
"Error input - please try again", "",
|
| 81 |
"Error input - please try again", "",
|
| 82 |
"Error input - please try again", "",]
|
| 83 |
+
'''
|
| 84 |
inputs = [gr.Textbox(label="Input", value="type your description", max_lines=2),
|
| 85 |
gr.Radio(label="Language", choices=["en"], value="en")]
|
| 86 |
|