Spaces:
Running
Running
Deepak Sahu
commited on
Commit
·
37f6f60
1
Parent(s):
69b5f29
Update app.py
Browse files
app.py
CHANGED
@@ -1,28 +1,33 @@
|
|
|
|
|
|
1 |
# CONST
|
2 |
CLEAN_DF_UNIQUE_TITLES = "unique_titles_books_summary.csv"
|
3 |
N_RECOMMENDS = 5
|
4 |
|
5 |
-
|
6 |
|
7 |
# # CONST
|
8 |
# set_seed(42)
|
9 |
-
|
10 |
|
11 |
|
12 |
-
|
|
|
|
|
13 |
|
14 |
-
|
15 |
|
16 |
-
|
17 |
-
from z_similarity import computes_similarity_w_hypothetical
|
18 |
-
from z_hypothetical_summary import generate_summaries
|
19 |
-
|
20 |
-
from z_utils import get_dataframe
|
21 |
|
22 |
-
|
|
|
|
|
23 |
|
24 |
|
25 |
def get_recommendation(book_title: str) -> str:
|
|
|
|
|
|
|
26 |
fake_summaries = generate_summaries(book_title=book_title, n_samples=5) # other parameters are set to default in the function
|
27 |
|
28 |
return fake_summaries[0]
|
|
|
1 |
+
from z_utils import get_dataframe
|
2 |
+
|
3 |
# CONST
|
4 |
CLEAN_DF_UNIQUE_TITLES = "unique_titles_books_summary.csv"
|
5 |
N_RECOMMENDS = 5
|
6 |
|
7 |
+
from transformers import pipeline, set_seed
|
8 |
|
9 |
# # CONST
|
10 |
# set_seed(42)
|
11 |
+
TRAINED_CASUAL_MODEL = "LunaticMaestro/gpt2-book-summary-generator"
|
12 |
|
13 |
|
14 |
+
if gr.NO_RELOAD:
|
15 |
+
# Load store books
|
16 |
+
books_df = get_dataframe(CLEAN_DF_UNIQUE_TITLES)
|
17 |
|
18 |
+
generator_model = pipeline('text-generation', model=TRAINED_CASUAL_MODEL)
|
19 |
|
20 |
+
import gradio as gr
|
|
|
|
|
|
|
|
|
21 |
|
22 |
+
# if gr.NO_RELOAD:
|
23 |
+
# from z_similarity import computes_similarity_w_hypothetical
|
24 |
+
# from z_hypothetical_summary import generate_summaries
|
25 |
|
26 |
|
27 |
def get_recommendation(book_title: str) -> str:
|
28 |
+
global generator_model
|
29 |
+
output = generator_model("Love")
|
30 |
+
return str(output)
|
31 |
fake_summaries = generate_summaries(book_title=book_title, n_samples=5) # other parameters are set to default in the function
|
32 |
|
33 |
return fake_summaries[0]
|