Joschka Strueber commited on
Commit
2f2195a
·
1 Parent(s): 2c585a5

[Add] Test version for gradio app

Browse files
Files changed (2) hide show
  1. app.py +28 -0
  2. requirements.txt +8 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datasets import load_dataset
2
+ import numpy as np
3
+ import matplotlib.pyplot as plt
4
+ import gradio as gr
5
+
6
+ def compute_similarity(dataset_name):
7
+ # Load dataset
8
+ dataset = load_dataset(dataset_name)
9
+ # Dummy similarity computation (replace with your metric)
10
+ data = np.random.rand(10, 10)
11
+ # Create heatmap
12
+ fig, ax = plt.subplots()
13
+ cax = ax.matshow(data, cmap='viridis')
14
+ plt.colorbar(cax)
15
+ return fig
16
+
17
+ with gr.Blocks() as demo:
18
+ dataset_name = gr.Textbox(label="Enter Dataset Name (e.g., 'imdb')")
19
+ heatmap_plot = gr.Plot(label="Similarity Heatmap")
20
+ compute_button = gr.Button("Compute Similarity")
21
+
22
+ compute_button.click(
23
+ fn=compute_similarity,
24
+ inputs=dataset_name,
25
+ outputs=heatmap_plot
26
+ )
27
+
28
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ gradio
2
+ numpy
3
+ datasets
4
+ matplotlib
5
+ seaborn
6
+ plotly
7
+ pandas
8
+ scienceplots