myte commited on
Commit
5e65d9b
·
1 Parent(s): 40793d0

entertainment title app done

Browse files
Files changed (3) hide show
  1. app.py +26 -4
  2. entertainment-title-stage-1.pkl +3 -0
  3. requirements.txt +5 -1
app.py CHANGED
@@ -1,9 +1,31 @@
 
 
1
  import gradio as gr
2
 
3
 
4
- def greet(name):
5
- return "Hello " + name + "!!"
 
 
6
 
7
 
8
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
9
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.text.all import *
2
+ from blurr.text.modeling.all import *
3
  import gradio as gr
4
 
5
 
6
+ if platform.system() == "Windows":
7
+ import pathlib
8
+ temp = pathlib.PosixPath
9
+ pathlib.PosixPath = pathlib.WindowsPath
10
 
11
 
12
+ model_path = "entertainment-title-stage-1.pkl"
13
+ model = load_learner(model_path)
14
+
15
+
16
+ def entertainment_title(description):
17
+ outputs = model.blurr_summarize(description, early_stopping=True, num_beams=20, num_return_sequences=5)
18
+ return {key: 1 for key in list(outputs[0].values())[0]}
19
+
20
+
21
+ example = [
22
+ ["When the menace known as the Joker wreaks havoc and chaos on the people of Gotham, Batman must accept one of "
23
+ "the greatest psychological and physical tests of his ability to fight injustice."],
24
+ ["The story of American scientist, J. Robert Oppenheimer, and his role in the development of the atomic."]
25
+ ]
26
+
27
+
28
+ labels = gr.outputs.Label(num_top_classes=5)
29
+ iface = gr.Interface(fn=entertainment_title, inputs="text", outputs=labels, examples=example)
30
+ iface.interpretation = "default"
31
+ iface.launch(inline=False, share=True)
entertainment-title-stage-1.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6278ad7a89c9571fe8030c296f9fd385ad62a496a9fb56c1ab7ac822e106e234
3
+ size 246483451
requirements.txt CHANGED
@@ -1 +1,5 @@
1
- gradio
 
 
 
 
 
1
+ fastai==2.7.12
2
+ gradio==3.44.2
3
+ ohmeow-blurr==1.0.5
4
+ sentencepiece==0.1.99
5
+ transformers==4.33.1