Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -169,26 +169,32 @@ def create_embeddings(texts_to_embedd):
|
|
169 |
|
170 |
|
171 |
def predict(text_input, progress=gr.Progress()):
|
172 |
-
|
|
|
173 |
# get data.
|
174 |
records_df = query_records(text_input)
|
175 |
print(records_df)
|
176 |
|
177 |
|
178 |
-
|
179 |
texts_to_embedd = [title + tokenizer.sep_token + publication + tokenizer.sep_token + abstract for title, publication, abstract in zip(records_df['title'],records_df['parsed_publication'], records_df['abstract'])]
|
180 |
|
181 |
embeddings = create_embeddings(texts_to_embedd)
|
182 |
print(embeddings)
|
|
|
|
|
183 |
umap_embeddings = mapper.transform(embeddings)
|
184 |
records_df[['x','y']] = umap_embeddings
|
185 |
|
186 |
basedata_df['color'] = '#ced4d211'
|
187 |
records_df['color'] = '#a81a26'
|
188 |
|
|
|
|
|
189 |
stacked_df = pd.concat([records_df, basedata_df], axis=0, ignore_index=True)
|
190 |
stacked_df = stacked_df.fillna("Unlabelled")
|
191 |
-
|
|
|
192 |
|
193 |
|
194 |
|
@@ -199,7 +205,7 @@ def predict(text_input, progress=gr.Progress()):
|
|
199 |
|
200 |
#
|
201 |
|
202 |
-
progress(0.
|
203 |
|
204 |
plot = datamapplot.create_interactive_plot(
|
205 |
stacked_df[['x','y']].values,
|
@@ -208,7 +214,7 @@ def predict(text_input, progress=gr.Progress()):
|
|
208 |
font_family="Roboto Condensed",marker_color_array=stacked_df['color']
|
209 |
)
|
210 |
|
211 |
-
progress(0.
|
212 |
plot.save(file_path)
|
213 |
|
214 |
progress(1.0, desc="Done!")
|
|
|
169 |
|
170 |
|
171 |
def predict(text_input, progress=gr.Progress()):
|
172 |
+
|
173 |
+
progress(0.1, desc="Getting queried data...")
|
174 |
# get data.
|
175 |
records_df = query_records(text_input)
|
176 |
print(records_df)
|
177 |
|
178 |
|
179 |
+
progress(0.2, desc="Embedding Data...")
|
180 |
texts_to_embedd = [title + tokenizer.sep_token + publication + tokenizer.sep_token + abstract for title, publication, abstract in zip(records_df['title'],records_df['parsed_publication'], records_df['abstract'])]
|
181 |
|
182 |
embeddings = create_embeddings(texts_to_embedd)
|
183 |
print(embeddings)
|
184 |
+
|
185 |
+
progress(0.3, desc="Project into UMAP-embedding...")
|
186 |
umap_embeddings = mapper.transform(embeddings)
|
187 |
records_df[['x','y']] = umap_embeddings
|
188 |
|
189 |
basedata_df['color'] = '#ced4d211'
|
190 |
records_df['color'] = '#a81a26'
|
191 |
|
192 |
+
progress(0.4, desc="Set up data...")
|
193 |
+
|
194 |
stacked_df = pd.concat([records_df, basedata_df], axis=0, ignore_index=True)
|
195 |
stacked_df = stacked_df.fillna("Unlabelled")
|
196 |
+
stacked_df = stacked_df.reset_index(drop=True)
|
197 |
+
print(stacked_df)
|
198 |
|
199 |
|
200 |
|
|
|
205 |
|
206 |
#
|
207 |
|
208 |
+
progress(0.5, desc="Plotting...")
|
209 |
|
210 |
plot = datamapplot.create_interactive_plot(
|
211 |
stacked_df[['x','y']].values,
|
|
|
214 |
font_family="Roboto Condensed",marker_color_array=stacked_df['color']
|
215 |
)
|
216 |
|
217 |
+
progress(0.6, desc="Saving plot...")
|
218 |
plot.save(file_path)
|
219 |
|
220 |
progress(1.0, desc="Done!")
|