Spaces:
Sleeping
Sleeping
File size: 858 Bytes
bd201c2 3558ad8 80c53ff 3558ad8 80c53ff 3558ad8 e1c02b0 3558ad8 3558000 3558ad8 db26e83 ba0b88d 80c53ff bd201c2 ba0b88d ebd56e0 bd201c2 |
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 |
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() |