import gradio as gr from transformers import pipeline # Load a small but good text generation model # You can swap "gpt2" with a better free model like "tiiuae/falcon-7b-instruct" if you have GPU generator = pipeline("text-generation", model="gpt2", device_map="auto") def decode_dream(dream_text): prompt = f"You are a dream interpretation expert. Decode the following dream:\n\n{dream_text}\n\nDream meaning:" result = generator(prompt, max_length=200, num_return_sequences=1, temperature=0.8) return result[0]['generated_text'] demo = gr.Interface( fn=decode_dream, inputs=gr.Textbox(label="Describe your dream", placeholder="I was flying over a city at night..."), outputs=gr.Textbox(label="Dream interpretation"), title="Dream Decoder", description="Describe your dream and get an AI-generated interpretation." ) if __name__ == "__main__": demo.launch()