Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,22 @@
|
|
1 |
import oneclass
|
2 |
import gradio as gr
|
3 |
import pandas as pd
|
|
|
4 |
|
5 |
def predict_and_download(positive_csv_file, unlabelled_csv_file, n, text):
|
6 |
selected_paper_info = oneclass.select_top_n_papers(n, positive_csv_file, unlabelled_csv_file)
|
7 |
-
|
8 |
-
|
|
|
9 |
|
10 |
# Create the interface
|
11 |
iface = gr.Interface(
|
12 |
fn=predict_and_download,
|
13 |
inputs=["file", "file", "number", "textbox"],
|
14 |
-
outputs=[gr.DataFrame(label="Selected Papers")],
|
15 |
title="Paper Prediction",
|
16 |
description="Enter text and upload CSV files for labelled and unlabelled data.",
|
17 |
allow_flagging='never' # Disable flagging feature
|
18 |
)
|
19 |
|
20 |
-
iface.launch()
|
|
|
1 |
import oneclass
|
2 |
import gradio as gr
|
3 |
import pandas as pd
|
4 |
+
import io
|
5 |
|
6 |
def predict_and_download(positive_csv_file, unlabelled_csv_file, n, text):
|
7 |
selected_paper_info = oneclass.select_top_n_papers(n, positive_csv_file, unlabelled_csv_file)
|
8 |
+
csv_string = selected_paper_info.to_csv(index=False)
|
9 |
+
csv_filename = "selected_papers.csv"
|
10 |
+
return selected_paper_info, {"csv_content": csv_string, "filename": csv_filename}
|
11 |
|
12 |
# Create the interface
|
13 |
iface = gr.Interface(
|
14 |
fn=predict_and_download,
|
15 |
inputs=["file", "file", "number", "textbox"],
|
16 |
+
outputs=[gr.DataFrame(label="Selected Papers"), gr.DownloadButton(label="Download CSV")],
|
17 |
title="Paper Prediction",
|
18 |
description="Enter text and upload CSV files for labelled and unlabelled data.",
|
19 |
allow_flagging='never' # Disable flagging feature
|
20 |
)
|
21 |
|
22 |
+
iface.launch()
|