Spaces:
Sleeping
Sleeping
Commit
·
993f1e3
1
Parent(s):
72c1acf
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
from happytransformer import HappyGeneration
|
4 |
+
|
5 |
+
happy_gen = HappyGeneration("GPT-NEO", "DarwinAnim8or/GPT-DMV-125m")
|
6 |
+
|
7 |
+
from happytransformer import GENSettings
|
8 |
+
args_top_k = GENSettings(no_repeat_ngram_size=3, do_sample=True,top_k=80, temperature=0.4, max_length=50, early_stopping=False)
|
9 |
+
|
10 |
+
def generate(text):
|
11 |
+
inputText = "PLATE: " + text + "\nREVIEW REASON CODE: "
|
12 |
+
|
13 |
+
result = happy_gen.generate_text(inputText, args=args_top_k)
|
14 |
+
generated_text = result.text #returns generated text only
|
15 |
+
|
16 |
+
return generated_text
|
17 |
+
|
18 |
+
examples = [
|
19 |
+
["LUCH"],
|
20 |
+
["LCDR"],
|
21 |
+
["OOGA"],
|
22 |
+
["BANANA"],
|
23 |
+
["JJ BINKS"]
|
24 |
+
]
|
25 |
+
|
26 |
+
demo = gr.Interface(
|
27 |
+
fn=generate,
|
28 |
+
inputs=gr.inputs.Textbox(lines=5, label="Input Text"),
|
29 |
+
outputs=gr.outputs.Textbox(label="Generated Text"),
|
30 |
+
examples=examples
|
31 |
+
)
|
32 |
+
|
33 |
+
demo.launch()
|