AbdulmohsenA commited on
Commit
9758705
·
1 Parent(s): 7a3b33f

Add application file

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the translation pipeline
5
+ model_name = "AbdulmohsenA/Faseeh" # Replace with your model name
6
+ translator = pipeline("translation_en_to_ar", model=model_name)
7
+
8
+ # Define translation function
9
+ def translate_text(text):
10
+ result = translator(text)
11
+ return result[0]['translation_text']
12
+
13
+ # Gradio interface
14
+ with gr.Blocks() as demo:
15
+ gr.Markdown("# Machine Translation to Classical Arabic")
16
+
17
+ # Input text box
18
+ input_text = gr.Textbox(label="Input Text", placeholder="Enter text to translate from English to Classical Arabic")
19
+
20
+ # Output text box
21
+ output_text = gr.Textbox(label="Translated Text")
22
+
23
+ # Button to trigger translation
24
+ translate_btn = gr.Button("Translate")
25
+
26
+ # Button action
27
+ translate_btn.click(translate_text, inputs=input_text, outputs=output_text)
28
+
29
+ # Launch the Gradio app
30
+ if __name__ == "__main__":
31
+ demo.launch()