|
import oneclass |
|
import gradio as gr |
|
import pandas as pd |
|
import io |
|
|
|
def predict_and_download(positive_csv_file, unlabelled_csv_file, n, text): |
|
selected_paper_info = oneclass.select_top_n_papers(n, positive_csv_file, unlabelled_csv_file) |
|
|
|
|
|
csv_buffer = StringIO() |
|
|
|
|
|
selected_paper_info.to_csv(csv_buffer, index=False) |
|
|
|
|
|
csv_content = csv_buffer.getvalue() |
|
|
|
|
|
csv_buffer.close() |
|
|
|
|
|
csv_variable = csv_content |
|
|
|
|
|
return selected_paper_info, csv_variable |
|
|
|
|
|
iface = gr.Interface( |
|
fn=predict_and_download, |
|
inputs=["file", "file", "number", "textbox"], |
|
outputs=[gr.DataFrame(label="Selected Papers"), gr.DownloadButton(label="Download CSV")], |
|
title="Paper Prediction", |
|
description="Enter text and upload CSV files for labelled and unlabelled data.", |
|
allow_flagging='never' |
|
) |
|
|
|
iface.launch() |