Spaces:
Sleeping
Sleeping
File size: 962 Bytes
2cfeb94 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import gc
import gradio as gr
from transformers import pipeline
pipe = pipeline('text-generation', model='akhooli/ap2023', tokenizer='akhooli/ap2023')
gc.collect()
def sayPoetry(prompt):
gen = pipe(prompt, max_length=96)[0]["generated_text"]
poetry =""
for line in gen[0].split('.')[:-1]:
poetry += line + "\n"
return poetry
tb = gr.Textbox(label="Enter your prompt or select from examples:", placeholder="أنا الذي", lines=1)
p_app = gr.Interface(fn=sayPoetry, inputs=tb, outputs="text", allow_flagging='never',
title='Arabic Poetry Generation Demo (updated Jan. 2023)',
description = "a simple demo of AI generated poetry based on 1M poems fine-tuned using AraGPT2 (be patient, runs on cpu)",
examples=[['أنت'],['لولا كتاب'], ['ألا ليت'],['يا قدس'],['عيد بأية حال'], ['لكل شيء إذا ما'],['.']])
p_app.launch() |