varun500 commited on
Commit
43dfcb4
·
1 Parent(s): 2db65ef

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer
3
+ import streamlit as st
4
+ model = AutoModelForCausalLM.from_pretrained("RWKV/rwkv-4-169m-pile")
5
+ tokenizer = AutoTokenizer.from_pretrained("RWKV/rwkv-4-169m-pile")
6
+ def main():
7
+ st.title("Dragon Text Generator")
8
+ st.write("Enter a prompt and generate dragon-inspired text!")
9
+
10
+ # Input prompt
11
+ prompt = st.text_area("Enter your prompt", value="", height=150)
12
+
13
+ if st.button("Generate Text"):
14
+ if prompt.strip() != "":
15
+ # Generate text based on the provided prompt
16
+ inputs = tokenizer(prompt, return_tensors="pt")
17
+ output = model.generate(inputs["input_ids"], max_new_tokens=20)
18
+ generated_text = tokenizer.decode(output[0].tolist())
19
+ st.markdown("## Generated Text")
20
+ st.write(generated_text)
21
+ else:
22
+ st.warning("Please enter a prompt.")
23
+
24
+ if __name__ == "__main__":
25
+ main()