Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
3 |
+
|
4 |
+
# Load your trained model and tokenizer from Hugging Face
|
5 |
+
model_name = "ENGLISH TO TELUGU"
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
7 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
8 |
+
|
9 |
+
# Streamlit UI
|
10 |
+
st.title("Colloquial Language Translator")
|
11 |
+
st.write("Enter English text to translate into the colloquial language of your choice.")
|
12 |
+
|
13 |
+
# User input
|
14 |
+
input_text = st.text_input("Enter English text:")
|
15 |
+
|
16 |
+
# When the button is clicked
|
17 |
+
if st.button("Translate"):
|
18 |
+
if input_text:
|
19 |
+
# Tokenize and generate output
|
20 |
+
inputs = tokenizer(input_text, return_tensors="pt", padding=True, truncation=True)
|
21 |
+
outputs = model.generate(**inputs)
|
22 |
+
translation = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
23 |
+
|
24 |
+
# Display the result
|
25 |
+
st.success(f"Translation: {translation}")
|
26 |
+
else:
|
27 |
+
st.warning("Please enter some text to translate.")
|