Spaces:
Sleeping
Sleeping
import gradio as gr | |
from Recommender import Recommender | |
from Preprocess import ModelUtils, Preprocess | |
import numpy as np | |
import pandas as pd | |
data_path = "result.csv" | |
model_path = "model_root" | |
data = pd.read_csv(data_path) | |
modelu = ModelUtils(model_path) | |
modelu.make_dirs() | |
modelu.download_model() | |
p = Preprocess(model_path) | |
data = pd.read_csv(data_path) | |
rec = Recommender (1, 2, 3, 5, 4) | |
k = 3 | |
table = [tuple(row) for row in data.to_numpy()] | |
def recom (input) : | |
# id = input.split("-")[-1] | |
indices, scores, title_scores = rec.recommend_k(table, k, input) | |
out = list(data[indices]['title']) | |
return "\n".join(out) | |
demo = gr.Interface(fn=recom, | |
inputs=[gr.Dropdown(choices = list(data['title'][:20]), multiselect=False, label="Titles")], | |
outputs=gr.Textbox(label="Titles of recommended items")) | |
demo.launch() |