Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,36 +1,21 @@
|
|
1 |
import streamlit as st
|
2 |
-
from transformers import
|
3 |
|
4 |
-
#
|
5 |
-
|
6 |
-
model1 = AutoModelForTokenClassification.from_pretrained("ml6team/keyphrase-extraction-kbir-inspec")
|
7 |
-
extractor1 = pipeline("ner", model=model1, tokenizer=tokenizer1)
|
8 |
-
|
9 |
-
tokenizer2 = AutoTokenizer.from_pretrained("aglazkova/bart_finetuned_keyphrase_extraction")
|
10 |
-
model2 = AutoModelForSeq2SeqLM.from_pretrained("aglazkova/bart_finetuned_keyphrase_extraction")
|
11 |
-
extractor2 = pipeline("text2text-generation", model=model2, tokenizer=tokenizer2)
|
12 |
|
13 |
# Streamlit app
|
14 |
-
st.title("
|
15 |
-
st.write("Enter text below to extract keyphrases using two different models:")
|
16 |
-
|
17 |
-
# Text input
|
18 |
-
user_input = st.text_area("Text Input", "")
|
19 |
|
20 |
-
#
|
21 |
-
|
22 |
-
if user_input:
|
23 |
-
# Extract keyphrases using the first model
|
24 |
-
keyphrases_model1 = extractor1(user_input)
|
25 |
-
st.write("Extracted Keyphrases from `ml6team/keyphrase-extraction-kbir-inspec`:")
|
26 |
-
for keyphrase in keyphrases_model1:
|
27 |
-
st.write(keyphrase['word'])
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
st.write(
|
|
|
35 |
else:
|
36 |
-
st.write("Please enter some text to
|
|
|
1 |
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
# Initialize the translation pipeline
|
5 |
+
translator = pipeline("translation_ro_to_en")
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
# Streamlit app
|
8 |
+
st.title("Romanian to English Translator")
|
|
|
|
|
|
|
|
|
9 |
|
10 |
+
# Input text
|
11 |
+
input_text = st.text_area("Enter text in Romanian:")
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
+
# Translate button
|
14 |
+
if st.button("Translate"):
|
15 |
+
if input_text:
|
16 |
+
# Perform translation
|
17 |
+
translation = translator(input_text)[0]['translation_text']
|
18 |
+
st.write("Translation:")
|
19 |
+
st.write(translation)
|
20 |
else:
|
21 |
+
st.write("Please enter some text to translate.")
|