CherryBOT / demo.py
Annaamalai's picture
init!
6b8e26f verified
raw
history blame
475 Bytes
import streamlit as st
from transformers import pipeline
# Load the text generation pipeline
generator = pipeline("text-generation", model="gpt2")
# Streamlit UI
st.title("Text Generation with Hugging Face")
prompt = st.text_input("Enter your text prompt:", "Once upon a time,")
if st.button("Generate Text"):
# Generate text based on the prompt
generated_text = generator(prompt, max_length=100, do_sample=True)[0]["generated_text"]
st.write(generated_text)