Spaces:
Runtime error
Runtime error
ncoop57
commited on
Commit
•
50e6fbc
1
Parent(s):
4b039b3
Add secret
Browse files
app.py
CHANGED
@@ -1,8 +1,18 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
import matplotlib.pyplot as plt
|
3 |
import numpy as np
|
4 |
from functools import partial
|
5 |
from datasets import load_dataset
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
dataset_names = [
|
8 |
"AI4Code",
|
@@ -67,6 +77,9 @@ def plt_plot(ratio, dataset, threshold):
|
|
67 |
plt.tight_layout()
|
68 |
return fig
|
69 |
|
|
|
|
|
|
|
70 |
with gr.Blocks() as demo:
|
71 |
dataset = gr.Radio(dataset_names, label="Dataset", value="arXiv")
|
72 |
print(dataset.value)
|
@@ -76,6 +89,7 @@ with gr.Blocks() as demo:
|
|
76 |
plot = gr.Plot()
|
77 |
threshold = gr.Slider(minimum=0, maximum=1, label="Threshold")
|
78 |
calculate = gr.Button("Calculate")
|
|
|
79 |
plot_fn = partial(plt_plot, "char_rep_ratios")
|
80 |
calculate.click(plot_fn, [dataset, threshold], plot)
|
81 |
|
|
|
1 |
+
import os
|
2 |
import gradio as gr
|
3 |
import matplotlib.pyplot as plt
|
4 |
import numpy as np
|
5 |
from functools import partial
|
6 |
from datasets import load_dataset
|
7 |
+
from pathlib import Path
|
8 |
+
|
9 |
+
# get secret environment variable
|
10 |
+
token = os.environ["HF_TOKEN"]
|
11 |
+
# write to disk
|
12 |
+
path = "./huggingface"
|
13 |
+
Path(path).mkdir(parents=True, exist_ok=True)
|
14 |
+
with open(path/"token", "w") as f:
|
15 |
+
f.write(token)
|
16 |
|
17 |
dataset_names = [
|
18 |
"AI4Code",
|
|
|
77 |
plt.tight_layout()
|
78 |
return fig
|
79 |
|
80 |
+
def check_filtered():
|
81 |
+
...
|
82 |
+
|
83 |
with gr.Blocks() as demo:
|
84 |
dataset = gr.Radio(dataset_names, label="Dataset", value="arXiv")
|
85 |
print(dataset.value)
|
|
|
89 |
plot = gr.Plot()
|
90 |
threshold = gr.Slider(minimum=0, maximum=1, label="Threshold")
|
91 |
calculate = gr.Button("Calculate")
|
92 |
+
check = gr.Button("Check Filtered Data")
|
93 |
plot_fn = partial(plt_plot, "char_rep_ratios")
|
94 |
calculate.click(plot_fn, [dataset, threshold], plot)
|
95 |
|