Update README.md
Browse files
README.md
CHANGED
@@ -1,83 +1,102 @@
|
|
1 |
-
|
2 |
-
license: mit
|
3 |
-
---
|
4 |
|
5 |
-
|
6 |
|
7 |
-
|
8 |
|
9 |
-
|
10 |
|
11 |
-
|
12 |
|
13 |
-
|
|
|
|
|
14 |
|
15 |
-
|
16 |
|
17 |
-
|
18 |
-
- Google Drive (to store the dataset)
|
19 |
-
- Basic knowledge of Python (optional)
|
20 |
-
- Internet connection (for downloading images)
|
21 |
-
- Libraries:
|
22 |
-
- `pycocotools`
|
23 |
-
- `requests`
|
24 |
-
- `tqdm`
|
25 |
-
- `matplotlib`
|
26 |
-
- `numpy`
|
27 |
-
- `shutil`
|
28 |
|
29 |
-
|
30 |
|
31 |
-
1.
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
|
37 |
-
|
38 |
-
- You can directly upload the notebook (`ArtifyAI_v1_0.ipynb`) to your Google Colab environment or use it locally in your Python environment.
|
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 |
-
1. **
|
67 |
-
|
|
|
68 |
|
69 |
-
|
70 |
-
- The notebook includes a step to mount Google Drive for file storage. Follow the on-screen instructions to authorize access.
|
71 |
|
72 |
-
|
73 |
-
|
|
|
|
|
74 |
|
75 |
-
|
|
|
76 |
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
-
|
80 |
|
81 |
-
|
82 |
|
83 |
-
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
|
1 |
+
# ArtifyAI v1.0: Text-to-Image Generation
|
|
|
|
|
2 |
|
3 |
+
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.
|
4 |
|
5 |
+
## Overview
|
6 |
|
7 |
+
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.
|
8 |
|
9 |
+
## Features
|
10 |
|
11 |
+
- **Text Processing**: Utilizes T5 for text summarization and generation.
|
12 |
+
- **Image Generation**: Uses Stable Diffusion for high-quality image generation based on textual descriptions.
|
13 |
+
- **Model Saving**: Allows you to save and reload model weights (e.g., UNet) to/from Google Drive.
|
14 |
|
15 |
+
## Installation
|
16 |
|
17 |
+
### Prerequisites
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
+
Ensure that you have the following to run this project:
|
20 |
|
21 |
+
1. Python 3.7+
|
22 |
+
2. CUDA-compatible GPU (for faster performance)
|
23 |
+
3. [Hugging Face Transformers](https://huggingface.co/transformers/)
|
24 |
+
4. [Diffusers](https://huggingface.co/docs/diffusers/index)
|
25 |
+
5. [PyTorch](https://pytorch.org/) with CUDA support
|
26 |
|
27 |
+
### Step-by-Step Setup
|
|
|
28 |
|
29 |
+
1. **Clone the Repository**:
|
30 |
+
```bash
|
31 |
+
git clone https://github.com/your-username/ArtifyAI.git
|
32 |
+
cd ArtifyAI
|
33 |
+
```
|
34 |
|
35 |
+
2. **Install Dependencies**:
|
36 |
+
```bash
|
37 |
+
pip install torch transformers diffusers
|
38 |
+
```
|
39 |
|
40 |
+
3. **Download the Pretrained Models**:
|
41 |
+
Use the following code to load the models:
|
42 |
+
```python
|
43 |
+
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
44 |
+
from diffusers import StableDiffusionPipeline
|
45 |
+
import torch
|
46 |
|
47 |
+
# Load models
|
48 |
+
t5_tokenizer = T5Tokenizer.from_pretrained("t5-small")
|
49 |
+
t5_model = T5ForConditionalGeneration.from_pretrained("t5-small")
|
50 |
+
ArtifyAI_model = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", torch_dtype=torch.float16)
|
51 |
+
|
52 |
+
# Set model to GPU if available
|
53 |
+
ArtifyAI_model = ArtifyAI_model.to("cuda" if torch.cuda.is_available() else "cpu")
|
54 |
+
```
|
55 |
|
56 |
+
4. **Mount Google Drive for Model Saving**:
|
57 |
+
To save model weights in Google Drive, mount your drive and specify the save path:
|
58 |
+
```python
|
59 |
+
from google.colab import drive
|
60 |
+
drive.mount('/content/drive')
|
61 |
|
62 |
+
save_path = '/content/drive/My Drive/models/unet_weights.pth'
|
63 |
+
torch.save(ArtifyAI_model.unet.state_dict(), save_path)
|
64 |
+
```
|
65 |
|
66 |
+
5. **Load Model Weights**:
|
67 |
+
Reload the model's weights later using:
|
68 |
+
```python
|
69 |
+
ArtifyAI_model.unet.load_state_dict(torch.load('/content/drive/My Drive/models/unet_weights.pth'))
|
70 |
+
```
|
71 |
|
72 |
+
## Usage
|
73 |
|
74 |
+
1. **Run the Jupyter Notebook**: Open `ArtifyAI_v1_0.ipynb` in Jupyter to run the code and explore the pipeline.
|
75 |
+
2. **Save/Load Model Weights**: Use the provided code to store and retrieve model weights from Google Drive.
|
76 |
+
3. **Generate Custom Images**: Modify the text input to generate unique images.
|
77 |
|
78 |
+
## Example
|
|
|
79 |
|
80 |
+
Here's how you can save and reload model weights:
|
81 |
+
```python
|
82 |
+
# Save the UNet model's weights
|
83 |
+
torch.save(ArtifyAI_model.unet.state_dict(), '/content/drive/My Drive/models/unet_weights.pth')
|
84 |
|
85 |
+
# Load the saved weights
|
86 |
+
ArtifyAI_model.unet.load_state_dict(torch.load('/content/drive/My Drive/models/unet_weights.pth'))
|
87 |
|
88 |
+
## For Non-Technical Users
|
89 |
+
|
90 |
+
If you're not familiar with coding or AI, follow these steps to use ArtifyAI:
|
91 |
+
|
92 |
+
1. **Install Python**: Download and install Python 3.7+ from the [official Python website](https://www.python.org/downloads/).
|
93 |
+
|
94 |
+
2. **Install Dependencies**: After installing Python, open a terminal and run:
|
95 |
+
```bash
|
96 |
+
pip install torch transformers diffusers
|
97 |
+
```
|
98 |
|
99 |
+
3. **Run the Project**: Use the code snippets provided in the notebook or above to generate images from text.
|
100 |
|
101 |
+
4. **Save Your Work**: If you are using Google Colab, remember to save your models to Google Drive to keep your work.
|
102 |
|
|