Skip to content

MatthewRInnes/smallTextandImagesgeneratorPython

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

🎨 AI Generator: Text & Image

A Python Streamlit application that generates text using OpenAI's GPT models and images using DALL-E.

✨ Features

  • Text Generation: Generate text using GPT-3.5 or GPT-4
  • Image Generation: Create images using DALL-E
  • Download Results: Save generated text and images
  • User-Friendly Interface: Clean, intuitive design
  • Error Handling: Robust error handling and user feedback
  • Customizable: Adjust creativity levels and model parameters

🚀 Quick Start

1. Install Dependencies

pip install -r requirements.txt

2. Set Up OpenAI API Key

You'll need an OpenAI API key. Get one from OpenAI's website.

Set your API key as an environment variable:

Windows:

set OPENAI_API_KEY=your-api-key-here

macOS/Linux:

export OPENAI_API_KEY=your-api-key-here

3. Run the Application

streamlit run ai_generator.py

The app will open at: http://localhost:8501

📖 How to Use

Text Generation

  1. Select "Generate Text" from the dropdown
  2. Choose your preferred model (GPT-3.5 or GPT-4)
  3. Enter your prompt in the text area
  4. Click "Generate"
  5. Download the generated text if needed

Image Generation

  1. Select "Generate Image" from the dropdown
  2. Choose your preferred image size
  3. Enter a detailed description of the image you want
  4. Click "Generate"
  5. Download the generated image if needed

⚙️ Configuration Options

Text Generation

  • Model Selection: Choose between GPT-3.5 (faster, cheaper) or GPT-4 (more powerful, expensive)
  • Creativity Level: Adjust how creative the AI responses should be (0.0 to 1.0)

Image Generation

  • Image Size: Choose from 256x256, 512x512, or 1024x1024 pixels
  • Creativity Level: Adjust how creative the image generation should be

💡 Tips for Better Results

Text Generation

  • Be specific and detailed in your prompts
  • Ask for different writing styles (creative, formal, technical, etc.)
  • Include context for better results
  • Try different prompts for varied outputs

Image Generation

  • Be descriptive about style and mood
  • Mention art style (realistic, cartoon, oil painting, etc.)
  • Include details about composition and lighting
  • Specify colors and atmosphere

🔧 Customization

Adding New Models

To add support for other AI models, modify the generate_text() function:

def generate_text(prompt, model="gpt-3.5-turbo"):
    # Add your custom model logic here
    pass

Styling

The app uses custom CSS for styling. Modify the CSS in the st.markdown() section to change the appearance.

📁 File Structure

pythonwebsiteai/
├── ai_generator.py      # Main application
├── requirements.txt     # Python dependencies
├── README.md          # This file
└── generated_images/   # Downloaded images (created automatically)

🛠️ Troubleshooting

Common Issues

  1. "OpenAI API key not found"

    • Make sure you've set the OPENAI_API_KEY environment variable
    • Restart your terminal after setting the variable
  2. "Error generating text/image"

    • Check your internet connection
    • Verify your OpenAI API key is valid
    • Ensure you have sufficient API credits
  3. App won't start

    • Make sure all dependencies are installed: pip install -r requirements.txt
    • Check that Streamlit is installed: pip install streamlit

API Rate Limits

  • OpenAI has rate limits on API calls
  • If you hit limits, wait a moment and try again
  • Consider upgrading your OpenAI plan for higher limits

🔒 Security Notes

  • Never commit your API key to version control
  • Use environment variables for sensitive data
  • The app doesn't store your API key locally

📈 Future Enhancements

  • Add support for more AI models
  • Implement conversation history
  • Add batch processing capabilities
  • Include more image generation options
  • Add user authentication
  • Implement usage analytics

🤝 Contributing

Feel free to submit issues and enhancement requests!

📄 License

This project is open source and available under the MIT License.


Happy Generating! 🎨✨

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages