Spaces:
Running
Running
model and hierarchy details should now save properly
Browse files
app.py
CHANGED
@@ -119,7 +119,7 @@ def save_topic_outputs(topic_model, data_file_name_no_ext, output_list, docs, sa
|
|
119 |
topic_model_save_name_zip = topic_model_save_name_pkl + ".zip"
|
120 |
|
121 |
# Clear folder before replacing files
|
122 |
-
delete_files_in_folder(topic_model_save_name_pkl)
|
123 |
|
124 |
topic_model.save(topic_model_save_name_pkl, serialization='pickle', save_embedding_model=False, save_ctfidf=False)
|
125 |
|
@@ -417,6 +417,15 @@ def visualise_topics(topic_model, docs, data_file_name_no_ext, low_resource_mode
|
|
417 |
topics_vis_2.write_html(topics_vis_2_name)
|
418 |
output_list.append(topics_vis_2_name)
|
419 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
420 |
all_toc = time.perf_counter()
|
421 |
time_out = f"Creating visualisation took {all_toc - vis_tic:0.1f} seconds"
|
422 |
print(time_out)
|
@@ -491,9 +500,10 @@ with block:
|
|
491 |
|
492 |
|
493 |
with gr.Tab("Visualise"):
|
494 |
-
|
495 |
sample_slide = gr.Slider(minimum = 0.01, maximum = 1, value = 0.1, step = 0.01, label = "Proportion of data points to show on output visualisation.")
|
496 |
visualisation_type_radio = gr.Radio(choices=["Topic document graph", "Hierarchical view"])
|
|
|
497 |
out_plot_file = gr.File(label="Output plots to file", file_count="multiple")
|
498 |
plot = gr.Plot(label="Visualise your topics here. Go to the 'Options' tab to enable.")
|
499 |
|
|
|
119 |
topic_model_save_name_zip = topic_model_save_name_pkl + ".zip"
|
120 |
|
121 |
# Clear folder before replacing files
|
122 |
+
#delete_files_in_folder(topic_model_save_name_pkl)
|
123 |
|
124 |
topic_model.save(topic_model_save_name_pkl, serialization='pickle', save_embedding_model=False, save_ctfidf=False)
|
125 |
|
|
|
417 |
topics_vis_2.write_html(topics_vis_2_name)
|
418 |
output_list.append(topics_vis_2_name)
|
419 |
|
420 |
+
# Save new hierarchical topic model to file
|
421 |
+
import pandas as pd
|
422 |
+
hierarchical_topics_name = data_file_name_no_ext + '_' + 'vis_hierarchy_topics' + today_rev + '.csv'
|
423 |
+
hierarchical_topics.to_csv(hierarchical_topics_name)
|
424 |
+
output_list.append(hierarchical_topics_name)
|
425 |
+
#output_list, output_text = save_topic_outputs(topic_model, data_file_name_no_ext, output_list, docs, save_topic_model)
|
426 |
+
|
427 |
+
|
428 |
+
|
429 |
all_toc = time.perf_counter()
|
430 |
time_out = f"Creating visualisation took {all_toc - vis_tic:0.1f} seconds"
|
431 |
print(time_out)
|
|
|
500 |
|
501 |
|
502 |
with gr.Tab("Visualise"):
|
503 |
+
|
504 |
sample_slide = gr.Slider(minimum = 0.01, maximum = 1, value = 0.1, step = 0.01, label = "Proportion of data points to show on output visualisation.")
|
505 |
visualisation_type_radio = gr.Radio(choices=["Topic document graph", "Hierarchical view"])
|
506 |
+
plot_btn = gr.Button("Visualise topic model")
|
507 |
out_plot_file = gr.File(label="Output plots to file", file_count="multiple")
|
508 |
plot = gr.Plot(label="Visualise your topics here. Go to the 'Options' tab to enable.")
|
509 |
|