FDSRashid's picture
Update app.py
12ead2a verified
raw
history blame
863 Bytes
import numpy as np
import gradio as gr
import os
import pandas as pd
from datasets import load_dataset
from sklearn.metrics.pairwise import cosine_similarity
import plotly.express as px
Secret_token = os.getenv('token')
dataset = load_dataset("FDSRashid/embed_matn")
df = dataset["train"].to_pandas()
taraf_max = np.max(df['taraf_ID'].unique())
def plot_similarity_score(taraf_num):
embed_taraf = df[df['taraf_ID']== taraf_num]['embed'].to_list()
cos_score = cosine_similarity(embed_taraf)
fig = px.imshow(cos_score)
fig.write_html("test1.html")
return 'test1.html'
with gr.Blocks() as demo:
taraf_number = gr.Slider(1,taraf_max , value=10000, label="Taraf", info="Choose the Taraf to Input", step = 1)
btn = gr.Button('Submit')
btn.click(fn = plot_similarity_score, inputs = [taraf_number], outputs = [gr.HTML()])
demo.launch()