File size: 1,327 Bytes
5e9beb0
 
61a185c
 
e920e6e
61a185c
5e9beb0
c55a023
5e9beb0
 
 
 
25d5cc9
 
 
 
 
 
 
 
 
 
 
eb5788b
61a185c
 
 
 
c55a023
5e9beb0
 
 
61a185c
 
 
b1c8440
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import oneclass
import Cosine_distance
import gradio as gr
import pandas as pd
from io import StringIO

def predict_and_download(classifier_oneclass_or_Cosine_distance ,positive_csv_file, unlabelled_csv_file, n,Hyperparameter_nu):
    if classifier_oneclass_or_Cosine_distance == "oneclass" :
       selected_paper_info = oneclass.select_top_n_papers(n, positive_csv_file, unlabelled_csv_file,Hyperparameter_nu)
    else :    
       selected_paper_info = Cosine_distance.recommend_papers(positive_csv_file, positive_csv_file, n)
        
    # Create a StringIO object to store CSV data
    csv_buffer = StringIO()
    
    # Write DataFrame to the StringIO buffer as CSV
    selected_paper_info.to_csv(csv_buffer, index=False)
    
    # Get the CSV data from the buffer
    csv_content = csv_buffer.getvalue()
    
    
    # Return selected_paper_info and CSV content
    return selected_paper_info, csv_buffer

# Create the interface
iface = gr.Interface(
    fn=predict_and_download,
    inputs=["text","file", "file", "number"],
    outputs=[gr.DataFrame(label="Recommended Papers"), gr.DownloadButton(label="Download CSV")],
    title="Personalized Arxiv Feed",
    description="Enter text and upload CSV files for labelled and unlabelled data.",
    allow_flagging='never'  # Disable flagging feature
)

iface.launch()