AhsanShahid commited on
Commit
d3d192f
·
verified ·
1 Parent(s): d6ef9af

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import AutoTokenizer, AutoModelForCausalLM
3
+
4
+ # Load the model and tokenizer
5
+ tokenizer = AutoTokenizer.from_pretrained("AhsanShahid/Creative_AI")
6
+ model = AutoModelForCausalLM.from_pretrained("AhsanShahid/Creative_AI")
7
+
8
+ # Streamlit app
9
+ st.title("Creative AI Writing Assistant")
10
+
11
+ prompt = st.text_area("Enter your prompt here:", "")
12
+
13
+ if st.button("Generate Text"):
14
+ if prompt:
15
+ inputs = tokenizer(prompt, return_tensors="pt")
16
+ outputs = model.generate(**inputs)
17
+ generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
18
+ st.subheader("Generated Text")
19
+ st.write(generated_text)
20
+ else:
21
+ st.warning("Please enter a prompt to generate text.")