Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,19 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
# Create a
|
5 |
-
pipe = pipeline("text2text-generation", model="
|
6 |
|
7 |
-
|
8 |
-
st.
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
# Use the specified pipeline to generate text
|
17 |
-
generated_text = pipe(user_input, max_length=100, do_sample=True)[0]["generated_text"]
|
18 |
-
st.write("Generated Text:")
|
19 |
-
st.write(generated_text)
|
20 |
else:
|
21 |
st.warning("Please enter text.")
|
22 |
|
23 |
-
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Create a text2text-generation pipeline with the "google/flan-t5-base" model
|
5 |
+
pipe = pipeline("text2text-generation", model="google/flan-t5-base")
|
6 |
|
7 |
+
st.title("Text Explanation Model")
|
8 |
+
user_text = st.text_area("Enter text:")
|
9 |
|
10 |
+
if st.button("Generate Explanation"):
|
11 |
+
if user_text:
|
12 |
+
# Use the pipeline to generate an explanation for the input text
|
13 |
+
explanation = pipe(user_text, max_length=100, do_sample=True)[0]["generated_text"]
|
14 |
+
st.markdown("**Explanation:**")
|
15 |
+
st.markdown(explanation)
|
|
|
|
|
|
|
|
|
16 |
else:
|
17 |
st.warning("Please enter text.")
|
18 |
|
19 |
+
st.markdown("Use the 'Generate Explanation' button to generate an explanation for the provided text.")
|