Karzan's picture
Update app.py
8995d89 verified
import gradio as gr
from transformers import pipeline
# model = AutoModelForCausalLM.from_pretrained("Karzan/ckb-gpt2-medium-base-test-1024")
model_id = "Karzan/bart-base-quran-transliteration"
pipe = pipeline("text2text-generation", model=model_id, max_length=1024)
def casual_model_function(input_text):
# Replace the line below with the code for your casual model
output_text = pipe(input_text)[0]["generated_text"]
return output_text
text_input = gr.Textbox(lines=10, placeholder="Enter your text here", label="Your Text")
text_outputs = gr.Textbox(lines=10)
# submit_btn = gr.Button(value="Generate",variant="secondary")
interface = gr.Interface(
fn=casual_model_function,
inputs=text_input,
outputs=text_outputs,
examples=[
["ٱلْحَمْدُ لِلَّهِ رَبِّ ٱلْعَـٰلَمِينَ", "ئەل حەمدو ليل لاهـى ڕەببـيل عالەمين"],
["ٱلرَّحْمَـٰنِ ٱلرَّحِيمِ", "ئەڕ ڕەحمانـيـڕ ڕەحيم"],
["فِى قُلُوبِهِم مَّرَضٌۭ فَزَادَهُمُ ٱللَّهُ مَرَضًۭا ۖ وَلَهُمْ عَذَابٌ أَلِيمٌۢ بِمَا كَانُوا۟ يَكْذِبُونَ","فـى قولوبـيـهيـم مەڕەضونۖ فەزادەهوموڵڵاهـو مەڕەض ۖ وەلەهوم عەذابـون ئەليمون بيـما كانوۗ يەكذيبـون"]
],
# submit_btn=submit_btn,
)
if __name__ == "__main__":
interface.launch()