Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,13 @@
|
|
1 |
import streamlit as st
|
|
|
2 |
|
3 |
-
# Load model
|
4 |
-
|
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
|
26 |
-
st.write("This app translates English text to Hawaiian using
|
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)
|