Spaces:
Sleeping
Sleeping
Commit
·
e644d85
1
Parent(s):
b9ef2ed
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,18 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load the Hugging Face pipeline
|
5 |
+
nlp_pipeline = pipeline("text-generation", model="gpt2")
|
6 |
+
|
7 |
+
# Streamlit app title and description
|
8 |
+
st.title("Hugging Face Streamlit Demo")
|
9 |
+
st.write("This app demonstrates how to use Hugging Face's models with Streamlit.")
|
10 |
+
|
11 |
+
# User input for text generation
|
12 |
+
user_input = st.text_input("Enter some text:", "")
|
13 |
+
|
14 |
+
# Generate text using the Hugging Face model
|
15 |
+
if user_input:
|
16 |
+
generated_text = nlp_pipeline(user_input, max_length=50, num_return_sequences=1)
|
17 |
+
st.write("Generated Text:")
|
18 |
+
st.write(generated_text[0]['generated_text'])
|