samvlad commited on
Commit
a23804c
·
verified ·
1 Parent(s): 484f431

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load a small but good text generation model
5
+ # You can swap "gpt2" with a better free model like "tiiuae/falcon-7b-instruct" if you have GPU
6
+ generator = pipeline("text-generation", model="gpt2", device_map="auto")
7
+
8
+ def decode_dream(dream_text):
9
+ prompt = f"You are a dream interpretation expert. Decode the following dream:\n\n{dream_text}\n\nDream meaning:"
10
+ result = generator(prompt, max_length=200, num_return_sequences=1, temperature=0.8)
11
+ return result[0]['generated_text']
12
+
13
+ demo = gr.Interface(
14
+ fn=decode_dream,
15
+ inputs=gr.Textbox(label="Describe your dream", placeholder="I was flying over a city at night..."),
16
+ outputs=gr.Textbox(label="Dream interpretation"),
17
+ title="Dream Decoder",
18
+ description="Describe your dream and get an AI-generated interpretation."
19
+ )
20
+
21
+ if __name__ == "__main__":
22
+ demo.launch()