File size: 1,374 Bytes
3500733
14a4fe8
5af62b0
 
 
 
 
 
 
3500733
a1dd328
 
 
 
 
 
 
5af62b0
 
 
 
 
 
 
 
a1dd328
 
 
5af62b0
 
 
 
 
a1dd328
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import gradio as gr
from bertopic import BERTopic
import numpy as np
import pickle

with open('C1_msg.pkl', 'rb') as f:
  C1_msg = pickle.load(f)
    
reduced_embeddings = np.load('C1_reduced_embeddings.npy')

model = BERTopic.load("AlexanderHolmes0/C1-Topic-Model-100")
model2 = BERTopic.load("AlexanderHolmes0/C2-Topic-Model-100")

with gr.Blocks() as demo:
   with gr.Tab("C1 Topic Model"):
        gr.load("models/AlexanderHolmes0/C1-Topic-Model-100")
        with gr.Row():
            gr.Plot(model.visualize_topics(width=650),
                    min_width=650)
            gr.Plot(model.visualize_documents(C1_msg, 
                                              reduced_embeddings=reduced_embeddings,
                                              hide_annotations = True,
                                              topics = range(0,7), 
                                              width = 725),
                    min_width=725)
   with gr.Tab("C2 Topic Model"): 
            gr.load("models/AlexanderHolmes0/C2-Topic-Model-100",alias = "C2 Topic Model")
            with gr.Row():
                gr.Plot(model2.visualize_topics(width=650),
                        min_width=650)
                gr.Plot(model2.visualize_hierarchy(width=650,
                                                   height=650),
                        min_width=650)

demo.launch()