awacke1 commited on
Commit
cbb80ac
1 Parent(s): ed5102c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -0
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'])