Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
st.title("Text Generation with Hugging Face")
|
5 |
+
|
6 |
+
model_name = "gpt2"
|
7 |
+
generator = pipeline("text-generation", model=model_name, device=0)
|
8 |
+
|
9 |
+
prompt = st.text_input("Enter text prompt:", "Once upon a time")
|
10 |
+
|
11 |
+
if st.button("Generate Text"):
|
12 |
+
output = generator(prompt, max_length=100, do_sample=True)
|
13 |
+
st.write(output[0]['generated_text'])
|