FDSRashid commited on
Commit
a110314
·
verified ·
1 Parent(s): 94bf643

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import numpy as np
3
+ import gradio as gr
4
+ import os
5
+ import pandas as pd
6
+ from datasets import load_dataset
7
+ from sklearn.metrics.pairwise import cosine_similarity
8
+
9
+ import plotly.express as px
10
+ Secret_token = os.getenv('token')
11
+
12
+ dataset = load_dataset("FDSRashid/embed_matn")
13
+ df = dataset["train"].to_pandas()
14
+ taraf_max = np.max(df['taraf_ID'].unique())
15
+
16
+ def plot_similarity_score(taraf_num):
17
+ embed_taraf = df[df['taraf_ID']== taraf_num]['embed']to_list()
18
+ cos_score = cosine_similarity(embed_taraf)
19
+ fig = px.imshow(cos_score)
20
+ fig.write_html("test1.html")
21
+ return 'test1.html'
22
+
23
+ with gr.Blocks() as demo:
24
+ taraf_number = gr.Slider(1,taraf_max , value=10000, label="Taraf", info="Choose the Taraf to Input", step = 1)
25
+ btn = gr.Button('Submit')
26
+ btn.click(fn = plot_similarity_score, inputs = [taraf_number], outputs = [gr.HTML()])
27
+ demo.launch()