samyhusy commited on
Commit
f1df127
·
verified ·
1 Parent(s): 48e3908

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -7,7 +7,7 @@ model_name = "jbochi/madlad400-3b-mt"
7
  tokenizer = AutoTokenizer.from_pretrained(model_name)
8
  model = AutoModelForSeq2SeqLM.from_pretrained(
9
  model_name,
10
- torch_dtype=torch.float16, # Use float16 to reduce memory usage
11
  device_map="auto"
12
  )
13
 
@@ -53,14 +53,14 @@ def translate_text(text, source_lang, target_lang):
53
  except Exception as e:
54
  return f"Error during translation: {str(e)}"
55
 
56
- # Create the Gradio interface
57
  with gr.Blocks(title="English-Persian Translator") as demo:
58
  gr.Markdown(
59
  """
60
  # 🌍 English-Persian Translator
61
- **Powered by MADLAD-400-3B Model**
62
 
63
- Translate text between English and Persian using the state-of-the-art MADLAD-400 model.
64
  """
65
  )
66
 
@@ -122,9 +122,8 @@ with gr.Blocks(title="English-Persian Translator") as demo:
122
  )
123
 
124
  if __name__ == "__main__":
125
- # Launch the app
126
  demo.launch(
127
- server_name="0.0.0.0", # Allow external access
128
- share=False, # Set to True to get a public URL
129
  debug=True
130
  )
 
7
  tokenizer = AutoTokenizer.from_pretrained(model_name)
8
  model = AutoModelForSeq2SeqLM.from_pretrained(
9
  model_name,
10
+ torch_dtype=torch.float16,
11
  device_map="auto"
12
  )
13
 
 
53
  except Exception as e:
54
  return f"Error during translation: {str(e)}"
55
 
56
+ # Gradio interface
57
  with gr.Blocks(title="English-Persian Translator") as demo:
58
  gr.Markdown(
59
  """
60
  # 🌍 English-Persian Translator
61
+ **Author: Saman Zeitouinan**
62
 
63
+ Translate text between English and Persian.
64
  """
65
  )
66
 
 
122
  )
123
 
124
  if __name__ == "__main__":
 
125
  demo.launch(
126
+ server_name="0.0.0.0",
127
+ share=False,
128
  debug=True
129
  )