Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
st.title("NLP pipeling")
|
5 |
+
|
6 |
+
def text_classificer():
|
7 |
+
text_classification = pipeline("text-classification", model="distilbert/distilbert-base-uncased-finetuned-sst-2-english")
|
8 |
+
st.title("Text Classification")
|
9 |
+
|
10 |
+
text=st.text_input("Enter the text :")
|
11 |
+
if st.button("Classife"):
|
12 |
+
output=text_classification(text)
|
13 |
+
st.write(output[0]["label"])
|
14 |
+
|
15 |
+
def text_summarizer():
|
16 |
+
text_summary = pipeline("summarization", model="facebook/bart-large-cnn")
|
17 |
+
st.title("Text Summarizer")
|
18 |
+
|
19 |
+
text=st.text_input("Enter the text")
|
20 |
+
if st.button("summarised"):
|
21 |
+
st.write(text_summary(text)[0]['summary_text'])
|
22 |
+
|
23 |
+
def text_generator():
|
24 |
+
text_generat= pipeline("text-generation")
|
25 |
+
st.title("Text Generation")
|
26 |
+
|
27 |
+
text=st.text_input("Enter the text")
|
28 |
+
if st.button("generate"):
|
29 |
+
result=text_generat(text)
|
30 |
+
st.write(result[0]["generated_text"])
|
31 |
+
def name_enity():
|
32 |
+
name_enity=pipeline("ner")#, model="dbmdz/bert-large-cased-finetuned-conll03-english", grouped_entities=True)
|
33 |
+
st.title("Name Enity")
|
34 |
+
|
35 |
+
text=st.text_input("Enter the text")
|
36 |
+
if st.button("submit"):
|
37 |
+
st.write(name_enity(text)[0]["word"])
|
38 |
+
|
39 |
+
def question_answer():
|
40 |
+
question_answering = pipeline("question-answering", model="google-bert/bert-large-uncased-whole-word-masking-finetuned-squad")
|
41 |
+
st.title("Question & Answers")
|
42 |
+
content=st.text_input("Enter the Content")
|
43 |
+
ques=st.text_input("Enter the Question ")
|
44 |
+
if st.button("submit"):
|
45 |
+
result=question_answering({"question": ques,"context": content})
|
46 |
+
st.write(result["answer"])
|
47 |
+
|
48 |
+
def code_generator():
|
49 |
+
st.title("Code Generator")
|
50 |
+
code_generation = pipeline("text-generation", model="Salesforce/codegen-350M-mono")
|
51 |
+
|
52 |
+
text=st.text_input("Enter the text")
|
53 |
+
if st.button("submit"):
|
54 |
+
st.write(code_generation(text)[0]) #["generated_text"]
|
55 |
+
|
56 |
+
|
57 |
+
file_type=st.sidebar.radio("Select a page:",('Text Classification',"Text Summarizer","Text Generator",'Name Enity','Question-Answer'))# Code Generator"
|
58 |
+
|
59 |
+
if file_type=='Text Classification':
|
60 |
+
text_classificer()
|
61 |
+
elif file_type=="Text Summarizer":
|
62 |
+
text_summarizer()
|
63 |
+
elif file_type=="Text Generator":
|
64 |
+
text_generator()
|
65 |
+
elif file_type=='Name Enity':
|
66 |
+
name_enity()
|
67 |
+
elif file_type=='Question-Answer':
|
68 |
+
question_answer()
|
69 |
+
# elif file_type=="Code Generator":
|
70 |
+
# code_generator()
|
71 |
+
else:
|
72 |
+
st.write(file_type)
|