Deepak Sahu commited on
Commit
bafb8fc
·
1 Parent(s): ee6f8cb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -5
app.py CHANGED
@@ -8,6 +8,16 @@
8
  # def get_recommendation(book_title: str) -> str:
9
  # return book_title
10
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  # def sanity_check():
13
  # '''Validates whether the vectors count is of same as summaries present else RAISES Error
@@ -22,16 +32,16 @@
22
 
23
  import gradio as gr
24
  # from z_similarity import computes_similarity_w_hypothetical
25
- from z_hypothetical_summary import generate_summaries, generator_model
26
 
27
  def get_recommendation(book_title: str) -> str:
28
  global generator_model
29
  # return "Hello"
30
  # # Generate hypothetical summary
31
- value = generator_model("hello", max_length=50)
32
- # # fake_summaries = generate_summaries(book_title=book_title, n_samples=5) # other parameters are set to default in the function
33
- # # return fake_summaries[0]
34
- return str(value)
35
 
36
  # We instantiate the Textbox class
37
  textbox = gr.Textbox(label="Write truth you wana Know:", placeholder="John Doe", lines=2)
 
8
  # def get_recommendation(book_title: str) -> str:
9
  # return book_title
10
 
11
+ from transformers import pipeline, set_seed
12
+
13
+ # CONST
14
+ set_seed(42)
15
+ TRAINED_CASUAL_MODEL = "LunaticMaestro/gpt2-book-summary-generator"
16
+
17
+
18
+ generator_model = pipeline('text-generation', model=TRAINED_CASUAL_MODEL)
19
+
20
+
21
 
22
  # def sanity_check():
23
  # '''Validates whether the vectors count is of same as summaries present else RAISES Error
 
32
 
33
  import gradio as gr
34
  # from z_similarity import computes_similarity_w_hypothetical
35
+ from z_hypothetical_summary import generate_summaries
36
 
37
  def get_recommendation(book_title: str) -> str:
38
  global generator_model
39
  # return "Hello"
40
  # # Generate hypothetical summary
41
+ # value = generator_model("hello", max_length=50)
42
+ fake_summaries = generate_summaries(book_title=book_title, n_samples=5) # other parameters are set to default in the function
43
+ return fake_summaries[0]
44
+ # return str(value)
45
 
46
  # We instantiate the Textbox class
47
  textbox = gr.Textbox(label="Write truth you wana Know:", placeholder="John Doe", lines=2)