AndrewLam489 commited on
Commit
4e3d055
·
verified ·
1 Parent(s): ce2ceca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -10
app.py CHANGED
@@ -1,15 +1,13 @@
1
  import streamlit as st
 
2
 
3
- # Load model directly
4
- from transformers import AutoTokenizer, AutoModelForCausalLM
5
-
6
- tokenizer = AutoTokenizer.from_pretrained("goldfish-models/haw_latn_full")
7
- model = AutoModelForCausalLM.from_pretrained("goldfish-models/haw_latn_full")
8
-
9
 
10
  def translate_to_hawaiian(text):
11
  # Add language direction instruction (this may improve translation)
12
- input_text = f"translate English to Hawaiian: {text}"
13
 
14
  # Encoding the input text for the model
15
  inputs = tokenizer(input_text, return_tensors="pt", padding=True, truncation=True)
@@ -22,8 +20,8 @@ def translate_to_hawaiian(text):
22
  return translated_text
23
 
24
  # Streamlit interface
25
- st.title("Hawaiian Language Translator")
26
- st.write("This app translates English text to Hawaiian using the mT5 model.")
27
 
28
  # Input text from the user
29
  text_input = st.text_area("Enter text to translate:")
@@ -32,4 +30,4 @@ text_input = st.text_area("Enter text to translate:")
32
  if text_input:
33
  translation = translate_to_hawaiian(text_input)
34
  st.subheader("Translation:")
35
- st.write(translation)
 
1
  import streamlit as st
2
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
3
 
4
+ # Load the model and tokenizer for English to Hawaiian Pidgin translation
5
+ tokenizer = AutoTokenizer.from_pretrained("claudiatang/flan-t5-base-eng-hwp")
6
+ model = AutoModelForSeq2SeqLM.from_pretrained("claudiatang/flan-t5-base-eng-hwp")
 
 
 
7
 
8
  def translate_to_hawaiian(text):
9
  # Add language direction instruction (this may improve translation)
10
+ input_text = f"translate English to Hawaiian Pidgin: {text}"
11
 
12
  # Encoding the input text for the model
13
  inputs = tokenizer(input_text, return_tensors="pt", padding=True, truncation=True)
 
20
  return translated_text
21
 
22
  # Streamlit interface
23
+ st.title("Hawaiian Pidgin Translator")
24
+ st.write("This app translates English text to Hawaiian Pidgin using a language model.")
25
 
26
  # Input text from the user
27
  text_input = st.text_area("Enter text to translate:")
 
30
  if text_input:
31
  translation = translate_to_hawaiian(text_input)
32
  st.subheader("Translation:")
33
+ st.write(translation)