ahed9x commited on
Commit
d0e4b1b
1 Parent(s): a4ef793

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -2,20 +2,16 @@ import gradio as gr
2
  from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
3
 
4
  # Load the tokenizer and model
5
- tokenizer = AutoTokenizer.from_pretrained("mohamedtolba/franco-arabics")
6
- model = AutoModelForSeq2SeqLM.from_pretrained("mohamedtolba/franco-arabics")
7
 
8
  def translate_text(text):
9
- print(f"Input text: {text}")
10
  # Tokenize the input text
11
  inputs = tokenizer(text, return_tensors="pt", truncation=True)
12
- print(f"Tokenized inputs: {inputs}")
13
  # Generate the output text
14
  outputs = model.generate(**inputs)
15
- print(f"Generated outputs: {outputs}")
16
  # Decode the generated text
17
  translated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
18
- print(f"Translated text: {translated_text}")
19
  return translated_text
20
 
21
  # Create the Gradio interface
@@ -24,8 +20,9 @@ iface = gr.Interface(
24
  inputs=gr.Textbox(lines=2, placeholder="Enter Franco-Arabic text here..."),
25
  outputs="text",
26
  title="Franco-Arabic to Arabic Translator",
27
- description="Translate Franco-Arabic text to Arabic using the mohamedtolba/franco-arabics model."
28
  )
29
 
30
  if __name__ == "__main__":
31
  iface.launch()
 
 
2
  from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
3
 
4
  # Load the tokenizer and model
5
+ tokenizer = AutoTokenizer.from_pretrained("mohamedtolba/franco-arabic")
6
+ model = AutoModelForSeq2SeqLM.from_pretrained("mohamedtolba/franco-arabic")
7
 
8
  def translate_text(text):
 
9
  # Tokenize the input text
10
  inputs = tokenizer(text, return_tensors="pt", truncation=True)
 
11
  # Generate the output text
12
  outputs = model.generate(**inputs)
 
13
  # Decode the generated text
14
  translated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
 
15
  return translated_text
16
 
17
  # Create the Gradio interface
 
20
  inputs=gr.Textbox(lines=2, placeholder="Enter Franco-Arabic text here..."),
21
  outputs="text",
22
  title="Franco-Arabic to Arabic Translator",
23
+ description="Translate Franco-Arabic text to Arabic using the mohamedtolba/franco-arabic model."
24
  )
25
 
26
  if __name__ == "__main__":
27
  iface.launch()
28
+