adnaniqbal001 commited on
Commit
7a35f5a
·
verified ·
1 Parent(s): 295c331

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -34
app.py DELETED
@@ -1,34 +0,0 @@
1
- import streamlit as st
2
- from transformers import MarianMTModel, MarianTokenizer
3
-
4
- # Load pre-trained multilingual model and tokenizer
5
- model_name = 'Helsinki-NLP/opus-mt-mul-de' # Multilingual to German model
6
- model = MarianMTModel.from_pretrained(model_name)
7
- tokenizer = MarianTokenizer.from_pretrained(model_name)
8
-
9
- # Function to translate text
10
- def translate_text(text):
11
- # Tokenize input text
12
- inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
13
-
14
- # Translate and decode
15
- translated = model.generate(**inputs)
16
- translated_text = tokenizer.decode(translated[0], skip_special_tokens=True)
17
- return translated_text
18
-
19
- # Streamlit app layout
20
- st.title("Real-Time Urdu to German Translation")
21
- st.write("Enter Urdu text below, and the app will translate it into German.")
22
-
23
- # Input text area for Urdu text
24
- input_text = st.text_area("Urdu Text", "", height=200)
25
-
26
- # Translate when the button is pressed
27
- if st.button("Translate"):
28
- if input_text:
29
- # Translate the text
30
- translated_text = translate_text(input_text)
31
- st.subheader("Translated German Text:")
32
- st.write(translated_text)
33
- else:
34
- st.write("Please enter some Urdu text to translate.")