| import streamlit as st | |
| import transformers | |
| from transformers import AutoTokenizer, AutoModelForTokenClassification | |
| from transformers import pipeline | |
| st.title("This is a Machine Learning app!") | |
| #Now, we work on text summarization (TS) | |
| #Using Facebook’s pre-trained BART Large which was fine-tuned on CNN Daily mail. | |
| # from transformers import pipeline | |
| model_TS= "facebook/bart-large-cnn" | |
| #Use the pipeline API to load the summarization model you want to use. | |
| summarizer = pipeline("summarization", model=model_TS) | |
| # max_length=st.text_input("This is meant for text summarization tasks. What is the maximum text length you want? 130 words?") | |
| # min_length=st.text_input("This is meant for text summarization tasks. What is the minimum text length you want? 30 words") | |
| ARTICLE=st.text_input("This is meant for text summarization tasks: Provide your text!!") | |
| #Now, apply model results | |
| results = summarizer(ARTICLE, max_length=1000, min_length=500, do_sample=False) | |
| #Now let’s see the results. | |
| st.header("Your results are below") | |
| st.subheader("This is your result for the text summary task:") | |
| st.write(results[0]["summary_text"]) | |
| # x1 = st.slider('Select a value') | |
| # st.write(x1, 'squared is', x1 * x1) | |
| # x2 = st.slider('Select a second value') | |
| # st.write(x2, 'squared is', x2 * x2) | |
| #Unused models | |
| #----------------------------------- | |
| # 1.NER | |
| #Loading pretrained tokenizers and models: Named Entity recognition task | |
| # tokenizer = AutoTokenizer.from_pretrained("dslim/bert-base-NER") | |
| # modeL_NER = AutoModelForTokenClassification.from_pretrained("dslim/bert-base-NER") | |
| # #Now, create a pipeline using the above | |
| # nlp = pipeline("ner", model=modeL_NER, tokenizer=tokenizer) | |
| # text_NER=st.text_input("This is meant for Named Entity Recognition (NER) tasks: Provide your text!!") | |
| # #Now, apply model results | |
| # ner_results = nlp(text_NER) | |
| # for item in ner_results: | |
| # st.write(item) | |
| #---------------------- |