Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,6 +5,11 @@ from transformers import pipeline
|
|
5 |
pipe = pipeline('text-generation', framework='pt', model='akhooli/ap2023', tokenizer='akhooli/ap2023')
|
6 |
#gc.collect()
|
7 |
samples = [['أنت', 0.95],['لولا كتاب'],['ألا ليت'],['يا قدس'],['عيد بأية حال'],['لكل شيء إذا ما'],['.']]
|
|
|
|
|
|
|
|
|
|
|
8 |
def sayPoetry(prompt, temp):
|
9 |
gen = pipe(prompt, max_length=96, temperature = temp)[0]["generated_text"]
|
10 |
poetry =""
|
@@ -13,11 +18,12 @@ def sayPoetry(prompt, temp):
|
|
13 |
return poetry
|
14 |
tempreature = gr.Slider(0.70, 1.0, value=0.94, step=0.01),
|
15 |
input_prompt = gr.inputs.Textbox(label="Enter your prompt or select from examples:", placeholder="أنا الذي", lines=1)
|
16 |
-
output_text = gr.outputs.Textbox(label="Generated Poetry:"
|
17 |
poetry = gr.Interface(fn=sayPoetry, inputs=[input_prompt, temperature], outputs=output_text, allow_flagging='never',
|
18 |
title='Arabic Poetry Generation Demo (updated Jan. 2023)',
|
19 |
description = "a simple demo of AI generated poetry based on 1M poems fine-tuned using AraGPT2 (be patient, runs on cpu)",
|
20 |
examples=samples,
|
|
|
21 |
theme = 'darkhuggingface')
|
22 |
|
23 |
poetry.launch()
|
|
|
5 |
pipe = pipeline('text-generation', framework='pt', model='akhooli/ap2023', tokenizer='akhooli/ap2023')
|
6 |
#gc.collect()
|
7 |
samples = [['أنت', 0.95],['لولا كتاب'],['ألا ليت'],['يا قدس'],['عيد بأية حال'],['لكل شيء إذا ما'],['.']]
|
8 |
+
notes = """
|
9 |
+
- Enter a short prompt or select one of the examples
|
10 |
+
- generate poetry
|
11 |
+
- be patient: this runs on CPU (free tier)
|
12 |
+
"""
|
13 |
def sayPoetry(prompt, temp):
|
14 |
gen = pipe(prompt, max_length=96, temperature = temp)[0]["generated_text"]
|
15 |
poetry =""
|
|
|
18 |
return poetry
|
19 |
tempreature = gr.Slider(0.70, 1.0, value=0.94, step=0.01),
|
20 |
input_prompt = gr.inputs.Textbox(label="Enter your prompt or select from examples:", placeholder="أنا الذي", lines=1)
|
21 |
+
output_text = gr.outputs.Textbox(label="Generated Poetry:")
|
22 |
poetry = gr.Interface(fn=sayPoetry, inputs=[input_prompt, temperature], outputs=output_text, allow_flagging='never',
|
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()
|