ArtifyAI-v1.0 / README.md
AhmedMOstaFA10's picture
Update README.md
ad9591a verified
|
raw
history blame
3.64 kB

ArtifyAI v1.0: Text-to-Image Generation

ArtifyAI v1.0 is a project designed to generate images using the Stable Diffusion model. This version focuses on saving and loading model weights, specifically for the image generation pipeline. It also provides functionality to store and retrieve models using Google Drive.

Overview

ArtifyAI v1.0 uses Stable Diffusion for high-quality image generation based on descriptive inputs. The project allows saving and loading of model weights to/from Google Drive, so you don't need to re-download models in future sessions.

Features

  • Image Generation: Uses Stable Diffusion to generate images from text descriptions.
  • Model Saving: Supports saving and loading of model weights (e.g., UNet) to/from Google Drive.

Installation

Prerequisites

Ensure that you have the following to run this project:

  1. Python 3.7+
  2. CUDA-compatible GPU (for faster performance)
  3. Hugging Face Transformers library
  4. Diffusers
  5. PyTorch with CUDA support

Step-by-Step Setup

  1. Clone the Repository:

    git clone https://github.com/your-username/ArtifyAI.git
    cd ArtifyAI
    
  2. Install Dependencies:

    pip install torch transformers diffusers
    
  3. Download the Pretrained Model: Use the following code to load the Stable Diffusion model:

    from diffusers import StableDiffusionPipeline
    import torch
    
    # Load the Stable Diffusion model
    ArtifyAI_model = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", torch_dtype=torch.float16)
    
    # Set model to GPU if available
    ArtifyAI_model = ArtifyAI_model.to("cuda" if torch.cuda.is_available() else "cpu")
    
  4. Mount Google Drive for Model Saving: To save model weights in Google Drive, mount your drive and specify the save path:

    from google.colab import drive
    drive.mount('/content/drive')
    
    save_path = '/content/drive/My Drive/models/unet_weights.pth'
    torch.save(ArtifyAI_model.unet.state_dict(), save_path)
    
  5. Load Model Weights: Reload the model's weights later using:

    ArtifyAI_model.unet.load_state_dict(torch.load('/content/drive/My Drive/models/unet_weights.pth'))
    

Usage

  1. Run the Jupyter Notebook: Open ArtifyAI_v1_0.ipynb in Jupyter to run the code and explore the pipeline.
  2. Save/Load Model Weights: Use the provided code to store and retrieve model weights from Google Drive.
  3. Generate Custom Images: Modify the text input to generate unique images.

Example

Here's how you can save and reload model weights:

# Save the UNet model's weights
torch.save(ArtifyAI_model.unet.state_dict(), '/content/drive/My Drive/models/unet_weights.pth')

# Load the saved weights
ArtifyAI_model.unet.load_state_dict(torch.load('/content/drive/My Drive/models/unet_weights.pth'))

## For Non-Technical Users

If you're not familiar with coding or AI, follow these steps to use ArtifyAI:

1. **Install Python**: Download and install Python 3.7+ from the [official Python website](https://www.python.org/downloads/).
   
2. **Install Dependencies**: After installing Python, open a terminal and run:
    ```bash
    pip install torch transformers diffusers
    ```

3. **Run the Project**: Use the code snippets provided in the notebook or above to generate images from text.

4. **Save Your Work**: If you are using Google Colab, remember to save your models to Google Drive to keep your work.