Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,8 +6,10 @@ pipe = pipeline('text-generation', framework='pt', model='akhooli/ap2023', token
|
|
6 |
#gc.collect()
|
7 |
samples = [['أنت'],['لولا كتاب'],['ألا ليت'],['يا قدس'],['عيد بأية حال'],['لكل شيء إذا ما'],['.']]
|
8 |
notes = """
|
9 |
-
- Enter a short prompt or select one of the examples
|
10 |
-
-
|
|
|
|
|
11 |
- be patient: this runs on CPU (free tier)
|
12 |
"""
|
13 |
def sayPoetry(prompt, temp=0.95):
|
@@ -16,14 +18,17 @@ def sayPoetry(prompt, temp=0.95):
|
|
16 |
for line in gen.split('.')[:-1]:
|
17 |
poetry += line + "\n"
|
18 |
return poetry
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
23 |
title='Arabic Poetry Generation Demo (updated Jan. 2023)',
|
24 |
description = "a simple demo of AI generated poetry based on 1M poems fine-tuned using AraGPT2 (be patient, runs on cpu)",
|
25 |
examples=samples,
|
26 |
article = notes,
|
27 |
theme = 'darkhuggingface')
|
28 |
-
|
29 |
-
poetry.launch()
|
|
|
6 |
#gc.collect()
|
7 |
samples = [['أنت'],['لولا كتاب'],['ألا ليت'],['يا قدس'],['عيد بأية حال'],['لكل شيء إذا ما'],['.']]
|
8 |
notes = """
|
9 |
+
- Enter a short prompt or select (click) one of the examples
|
10 |
+
- Control temperture (adjust) through slider (default = 0.95 for all examples)
|
11 |
+
- Clear and enter new prompt or select another example to rerenerate
|
12 |
+
- The '.' means start a new line (your prompt need not be long)
|
13 |
- be patient: this runs on CPU (free tier)
|
14 |
"""
|
15 |
def sayPoetry(prompt, temp=0.95):
|
|
|
18 |
for line in gen.split('.')[:-1]:
|
19 |
poetry += line + "\n"
|
20 |
return poetry
|
21 |
+
poetry = gr.Interface(fn=sayPoetry,
|
22 |
+
inputs=[
|
23 |
+
gr.inputs.Textbox(label="Enter your prompt or select from examples:", placeholder="أنا الذي", lines=1),
|
24 |
+
gr.inputs.Slider(0.70, 1.0, step=0.01, label='control temperature')
|
25 |
+
],
|
26 |
+
outputs=[gr.outputs.Textbox(label="Generated Poetry:")],
|
27 |
+
|
28 |
+
allow_flagging='never',
|
29 |
title='Arabic Poetry Generation Demo (updated Jan. 2023)',
|
30 |
description = "a simple demo of AI generated poetry based on 1M poems fine-tuned using AraGPT2 (be patient, runs on cpu)",
|
31 |
examples=samples,
|
32 |
article = notes,
|
33 |
theme = 'darkhuggingface')
|
34 |
+
poetry.launch()
|
|