Commit
•
8ed8ae5
1
Parent(s):
a8128aa
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
|
|
2 |
from sentence_transformers import SentenceTransformer, util
|
3 |
import numpy as np
|
4 |
import pandas as pd
|
|
|
5 |
import spacy
|
6 |
import torch
|
7 |
import plotly.express as px
|
@@ -56,10 +57,8 @@ def compare_text(transcript, categories):
|
|
56 |
# Compute cosine-similarities
|
57 |
cosine_scores = util.cos_sim(embeddings, phrases).numpy()
|
58 |
max_scores = np.max(cosine_scores, axis=1)
|
59 |
-
df_results_plot[df_category.iloc[0,2]] = max_scores
|
60 |
-
df_results_grid[df_category.iloc[0,2]] = max_scores
|
61 |
-
df_results_plot = df_results_plot.round(decimals = 2)
|
62 |
-
df_results_grid = df_results_grid.round(decimals = 3)
|
63 |
# Plot
|
64 |
fig = px.imshow(
|
65 |
df_results_plot,
|
|
|
2 |
from sentence_transformers import SentenceTransformer, util
|
3 |
import numpy as np
|
4 |
import pandas as pd
|
5 |
+
import math
|
6 |
import spacy
|
7 |
import torch
|
8 |
import plotly.express as px
|
|
|
57 |
# Compute cosine-similarities
|
58 |
cosine_scores = util.cos_sim(embeddings, phrases).numpy()
|
59 |
max_scores = np.max(cosine_scores, axis=1)
|
60 |
+
df_results_plot[df_category.iloc[0,2]] = math.ceil(max_scores * 100) / 100.0 # .round(decimals = 2)
|
61 |
+
df_results_grid[df_category.iloc[0,2]] = math.ceil(max_scores * 1000) / 1000.0 # .round(decimals = 3)
|
|
|
|
|
62 |
# Plot
|
63 |
fig = px.imshow(
|
64 |
df_results_plot,
|