File size: 3,926 Bytes
2db2a17 06fed79 2db2a17 06fed79 2db2a17 06fed79 2db2a17 06fed79 2db2a17 06fed79 2db2a17 06fed79 2db2a17 06fed79 2db2a17 06fed79 2db2a17 06fed79 2db2a17 06fed79 2db2a17 06fed79 2db2a17 06fed79 2db2a17 06fed79 2db2a17 06fed79 2db2a17 06fed79 2db2a17 06fed79 2db2a17 06fed79 2db2a17 06fed79 2db2a17 06fed79 2db2a17 06fed79 2db2a17 06fed79 2db2a17 06fed79 2db2a17 06fed79 2db2a17 06fed79 2db2a17 06fed79 2db2a17 06fed79 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# ArtifyAI v1.0: Text-to-Image Generation
ArtifyAI v1.0 is a project designed to generate images from text using the T5 model for text summarization and the Stable Diffusion model for image generation. This version also provides functionality to save model weights and load them for future use, making it easier to resume your work.
## Overview
ArtifyAI v1.0 uses T5 for text processing, Stable Diffusion for image generation, and includes functionality for saving and loading the model's weights. You can easily store model weights in Google Drive and use them later without re-downloading everything.
## Features
- **Text Processing**: Utilizes T5 for text summarization and generation.
- **Image Generation**: Uses Stable Diffusion for high-quality image generation based on textual descriptions.
- **Model Saving**: Allows you to save and reload 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](https://huggingface.co/transformers/)
4. [Diffusers](https://huggingface.co/docs/diffusers/index)
5. [PyTorch](https://pytorch.org/) with CUDA support
### Step-by-Step Setup
1. **Clone the Repository**:
```bash
git clone https://github.com/your-username/ArtifyAI.git
cd ArtifyAI
```
2. **Install Dependencies**:
```bash
pip install torch transformers diffusers
```
3. **Download the Pretrained Models**:
Use the following code to load the models:
```python
from transformers import T5Tokenizer, T5ForConditionalGeneration
from diffusers import StableDiffusionPipeline
import torch
# Load models
t5_tokenizer = T5Tokenizer.from_pretrained("t5-small")
t5_model = T5ForConditionalGeneration.from_pretrained("t5-small")
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:
```python
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:
```python
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:
```python
# 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.
|