Update app.py
Browse files
app.py
CHANGED
|
@@ -5,20 +5,7 @@ from transformers import pipeline
|
|
| 5 |
|
| 6 |
st.title("This is a Machine Learning app!")
|
| 7 |
|
| 8 |
-
#Loading pretrained tokenizers and models: Named Entity recognition task
|
| 9 |
-
tokenizer = AutoTokenizer.from_pretrained("dslim/bert-base-NER")
|
| 10 |
-
|
| 11 |
-
modeL_NER = AutoModelForTokenClassification.from_pretrained("dslim/bert-base-NER")
|
| 12 |
-
|
| 13 |
-
#Now, create a pipeline using the above
|
| 14 |
-
|
| 15 |
-
nlp = pipeline("ner", model=modeL_NER, tokenizer=tokenizer)
|
| 16 |
-
|
| 17 |
-
text_NER=st.text_input("This is meant for Named Entity Recognition (NER) tasks: Provide your text!!")
|
| 18 |
-
|
| 19 |
-
#Now, apply model results
|
| 20 |
|
| 21 |
-
ner_results = nlp(text_NER)
|
| 22 |
|
| 23 |
|
| 24 |
|
|
@@ -48,14 +35,10 @@ results = summarizer(ARTICLE, max_length=130, min_length=30, do_sample=False)
|
|
| 48 |
#Now let’s see the results.
|
| 49 |
st.header("Your results are below")
|
| 50 |
|
| 51 |
-
st.subheader("This is your result for the NER task:")
|
| 52 |
-
|
| 53 |
-
for item in ner_results:
|
| 54 |
-
st.write(item)
|
| 55 |
|
| 56 |
st.subheader("This is your result for the text summary task:")
|
| 57 |
|
| 58 |
-
st.write(
|
| 59 |
|
| 60 |
|
| 61 |
|
|
@@ -63,4 +46,31 @@ x1 = st.slider('Select a value')
|
|
| 63 |
st.write(x1, 'squared is', x1 * x1)
|
| 64 |
|
| 65 |
# x2 = st.slider('Select a second value')
|
| 66 |
-
# st.write(x2, 'squared is', x2 * x2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
st.title("This is a Machine Learning app!")
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
|
|
|
|
| 35 |
#Now let’s see the results.
|
| 36 |
st.header("Your results are below")
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
st.subheader("This is your result for the text summary task:")
|
| 40 |
|
| 41 |
+
st.write(results[0]["summary_text"])
|
| 42 |
|
| 43 |
|
| 44 |
|
|
|
|
| 46 |
st.write(x1, 'squared is', x1 * x1)
|
| 47 |
|
| 48 |
# x2 = st.slider('Select a second value')
|
| 49 |
+
# st.write(x2, 'squared is', x2 * x2)
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
#Unused models
|
| 57 |
+
|
| 58 |
+
#-----------------------------------
|
| 59 |
+
# 1.NER
|
| 60 |
+
#Loading pretrained tokenizers and models: Named Entity recognition task
|
| 61 |
+
# tokenizer = AutoTokenizer.from_pretrained("dslim/bert-base-NER")
|
| 62 |
+
|
| 63 |
+
# modeL_NER = AutoModelForTokenClassification.from_pretrained("dslim/bert-base-NER")
|
| 64 |
+
|
| 65 |
+
# #Now, create a pipeline using the above
|
| 66 |
+
|
| 67 |
+
# nlp = pipeline("ner", model=modeL_NER, tokenizer=tokenizer)
|
| 68 |
+
|
| 69 |
+
# text_NER=st.text_input("This is meant for Named Entity Recognition (NER) tasks: Provide your text!!")
|
| 70 |
+
|
| 71 |
+
# #Now, apply model results
|
| 72 |
+
|
| 73 |
+
# ner_results = nlp(text_NER)
|
| 74 |
+
# for item in ner_results:
|
| 75 |
+
# st.write(item)
|
| 76 |
+
#----------------------
|