akhooli commited on
Commit
6db59ad
1 Parent(s): 50c95fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -4,20 +4,20 @@ from transformers import pipeline
4
 
5
  pipe = pipeline('text-generation', framework='pt', model='akhooli/ap2023', tokenizer='akhooli/ap2023')
6
  #gc.collect()
7
- samples = [['أنت'],['لولا كتاب'],['ألا ليت'],['يا قدس'],['عيد بأية حال'],['لكل شيء إذا ما'],['.']]
8
- def sayPoetry(prompt):
9
- gen = pipe(prompt, max_length=96, temperature = 0.95)[0]["generated_text"]
10
  poetry =""
11
  for line in gen.split('.')[:-1]:
12
  poetry += line + "\n"
13
  return poetry
14
-
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:", lines=4)
17
- poetry = gr.Interface(fn=sayPoetry, inputs=input_prompt, 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()
 
4
 
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 =""
11
  for line in gen.split('.')[:-1]:
12
  poetry += line + "\n"
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:", lines=4)
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()