Spaces:
Sleeping
Sleeping
Initial Draft
Browse files
app.py
CHANGED
@@ -47,7 +47,7 @@ def sentiment_analysis():
|
|
47 |
|
48 |
def sentiment_analysis_btn():
|
49 |
classifier = pipeline("sentiment-analysis")
|
50 |
-
st.session_state.output_text=classifier(st.session_state.input_text)
|
51 |
|
52 |
def zero_shot_classification():
|
53 |
st.session_state.input_text="This is a course about the transformers library"
|
@@ -55,10 +55,10 @@ def zero_shot_classification():
|
|
55 |
|
56 |
def zero_shot_classification_btn():
|
57 |
classifier = pipeline("zero-shot-classification")
|
58 |
-
st.session_state.output_text=classifier(
|
59 |
st.session_state.input_text,
|
60 |
candidate_labels=["education", "politics", "business"],
|
61 |
-
)
|
62 |
|
63 |
def text_generation():
|
64 |
st.session_state.input_text="In this course, we will teach you how to"
|
@@ -66,7 +66,7 @@ def text_generation():
|
|
66 |
|
67 |
def text_generation_btn():
|
68 |
generator = pipeline("text-generation")
|
69 |
-
st.session_state.output_text=generator(st.session_state.input_text)
|
70 |
|
71 |
def mask_filling():
|
72 |
st.session_state.input_text="This course will teach you all about <mask> models."
|
@@ -74,7 +74,7 @@ def mask_filling():
|
|
74 |
|
75 |
def mask_filling_btn():
|
76 |
unmasker = pipeline("fill-mask")
|
77 |
-
st.session_state.output_text=unmasker(st.session_state.input_text, top_k=2)
|
78 |
|
79 |
def named_entity_recognition():
|
80 |
st.session_state.input_text="My name is Sylvain and I work at Hugging Face in Brooklyn."
|
@@ -82,7 +82,7 @@ def named_entity_recognition():
|
|
82 |
|
83 |
def named_entity_recognition_btn():
|
84 |
ner = pipeline("ner", grouped_entities=True)
|
85 |
-
st.session_state.output_text=ner(st.session_state.input_text)
|
86 |
|
87 |
def qna():
|
88 |
st.session_state.input_text="My name is Sylvain and I work at Hugging Face in Brooklyn"
|
@@ -91,10 +91,10 @@ def qna():
|
|
91 |
def qna_btn():
|
92 |
question_answerer = pipeline("question-answering")
|
93 |
st.session_state.output_text="Questionn: Where do I work?\n Answer: "
|
94 |
-
st.session_state.output_text=st.session_state.output_text + question_answerer(
|
95 |
question=st.session_state.input_text,
|
96 |
context="My name is Sylvain and I work at Hugging Face in Brooklyn",
|
97 |
-
)
|
98 |
|
99 |
def summarization():
|
100 |
st.session_state.input_text= """America has changed dramatically during recent years. Not only has the number of
|
@@ -120,7 +120,7 @@ def summarization():
|
|
120 |
|
121 |
def summarization_btn():
|
122 |
summarizer = pipeline("summarization")
|
123 |
-
st.session_state.output_text=summarizer(st.session_state.input_text)
|
124 |
|
125 |
def translation_eng2frn():
|
126 |
st.session_state.input_text= "This course is produced by Hugging Face."
|
@@ -128,7 +128,7 @@ def translation_eng2frn():
|
|
128 |
|
129 |
def translation_eng2frn_btn():
|
130 |
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-en-fr")
|
131 |
-
st.session_state.output_text=translator(st.session_state.input_text)
|
132 |
|
133 |
################################
|
134 |
####### Display of data ########
|
|
|
47 |
|
48 |
def sentiment_analysis_btn():
|
49 |
classifier = pipeline("sentiment-analysis")
|
50 |
+
st.session_state.output_text=str(classifier(st.session_state.input_text))
|
51 |
|
52 |
def zero_shot_classification():
|
53 |
st.session_state.input_text="This is a course about the transformers library"
|
|
|
55 |
|
56 |
def zero_shot_classification_btn():
|
57 |
classifier = pipeline("zero-shot-classification")
|
58 |
+
st.session_state.output_text=str(classifier(
|
59 |
st.session_state.input_text,
|
60 |
candidate_labels=["education", "politics", "business"],
|
61 |
+
))
|
62 |
|
63 |
def text_generation():
|
64 |
st.session_state.input_text="In this course, we will teach you how to"
|
|
|
66 |
|
67 |
def text_generation_btn():
|
68 |
generator = pipeline("text-generation")
|
69 |
+
st.session_state.output_text=str(generator(st.session_state.input_text))
|
70 |
|
71 |
def mask_filling():
|
72 |
st.session_state.input_text="This course will teach you all about <mask> models."
|
|
|
74 |
|
75 |
def mask_filling_btn():
|
76 |
unmasker = pipeline("fill-mask")
|
77 |
+
st.session_state.output_text=str(unmasker(st.session_state.input_text, top_k=2))
|
78 |
|
79 |
def named_entity_recognition():
|
80 |
st.session_state.input_text="My name is Sylvain and I work at Hugging Face in Brooklyn."
|
|
|
82 |
|
83 |
def named_entity_recognition_btn():
|
84 |
ner = pipeline("ner", grouped_entities=True)
|
85 |
+
st.session_state.output_text=str(ner(st.session_state.input_text))
|
86 |
|
87 |
def qna():
|
88 |
st.session_state.input_text="My name is Sylvain and I work at Hugging Face in Brooklyn"
|
|
|
91 |
def qna_btn():
|
92 |
question_answerer = pipeline("question-answering")
|
93 |
st.session_state.output_text="Questionn: Where do I work?\n Answer: "
|
94 |
+
st.session_state.output_text=st.session_state.output_text + str(question_answerer(
|
95 |
question=st.session_state.input_text,
|
96 |
context="My name is Sylvain and I work at Hugging Face in Brooklyn",
|
97 |
+
))
|
98 |
|
99 |
def summarization():
|
100 |
st.session_state.input_text= """America has changed dramatically during recent years. Not only has the number of
|
|
|
120 |
|
121 |
def summarization_btn():
|
122 |
summarizer = pipeline("summarization")
|
123 |
+
st.session_state.output_text=str(summarizer(st.session_state.input_text))
|
124 |
|
125 |
def translation_eng2frn():
|
126 |
st.session_state.input_text= "This course is produced by Hugging Face."
|
|
|
128 |
|
129 |
def translation_eng2frn_btn():
|
130 |
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-en-fr")
|
131 |
+
st.session_state.output_text=str(translator(st.session_state.input_text))
|
132 |
|
133 |
################################
|
134 |
####### Display of data ########
|