firagne commited on
Commit
043c163
1 Parent(s): 0c1bb10

dynamic num results to output

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -32,6 +32,7 @@ from models import *
32
 
33
  max_results = 100
34
  max_output = 50
 
35
 
36
  # global (faster)
37
  ind = get_index()
@@ -79,7 +80,7 @@ def process(file_name, embed_html_all):
79
  print(traceback.format_exc())
80
 
81
  # => global
82
-
83
  timestart = time.time()
84
  _, I = do_search(emb, ind)
85
  print("search time :", time.time() - timestart)
@@ -89,9 +90,9 @@ def process(file_name, embed_html_all):
89
  output_csv = f"{file_name}_results.csv"
90
  with open(output_csv, "w") as w:
91
  writer = csv.writer(w)
92
- count = 0
93
  for top in tops:
94
- if count > max_output:
95
  break
96
 
97
  file = os.path.splitext(os.path.basename(top))[0]
@@ -101,7 +102,7 @@ def process(file_name, embed_html_all):
101
  formated.append(file)
102
  formated.append(top)
103
  writer.writerow(dict_catalog[file].values())
104
- count += 1
105
 
106
  return (embed_html_all, output_csv, *formated)
107
  """except:
@@ -135,7 +136,7 @@ with gr.Blocks() as demo:
135
 
136
  with gr.Row():
137
  with gr.Column():
138
- for i in range(max_output):
139
  tops.append(
140
  gr.Textbox(label=f"top{i} track name", show_label=True)
141
  )
 
32
 
33
  max_results = 100
34
  max_output = 50
35
+ num_results = 0
36
 
37
  # global (faster)
38
  ind = get_index()
 
80
  print(traceback.format_exc())
81
 
82
  # => global
83
+
84
  timestart = time.time()
85
  _, I = do_search(emb, ind)
86
  print("search time :", time.time() - timestart)
 
90
  output_csv = f"{file_name}_results.csv"
91
  with open(output_csv, "w") as w:
92
  writer = csv.writer(w)
93
+ num_results = 0
94
  for top in tops:
95
+ if num_results > max_output:
96
  break
97
 
98
  file = os.path.splitext(os.path.basename(top))[0]
 
102
  formated.append(file)
103
  formated.append(top)
104
  writer.writerow(dict_catalog[file].values())
105
+ num_results += 1
106
 
107
  return (embed_html_all, output_csv, *formated)
108
  """except:
 
136
 
137
  with gr.Row():
138
  with gr.Column():
139
+ for i in range(num_results):
140
  tops.append(
141
  gr.Textbox(label=f"top{i} track name", show_label=True)
142
  )