AhmedMOstaFA10 commited on
Commit
a73bf7c
·
verified ·
1 Parent(s): 2154b7b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +84 -72
README.md CHANGED
@@ -1,98 +1,110 @@
1
- # ArtifyAI: Text-to-Image Generation
2
 
3
- ArtifyAI is an innovative project that combines the power of Natural Language Processing (NLP) with image generation. This repository implements a pipeline using the T5 Transformer model for text summarization or generation and the Stable Diffusion model for creating images based on the generated text.
 
4
 
5
- ## Overview
6
 
7
- ArtifyAI takes a text input, processes it through a T5 model, and then uses the processed output to generate an image using Stable Diffusion. This allows for seamless conversion of text descriptions into AI-generated images.
 
 
 
8
 
9
- ## Features
10
 
11
- - **Text Processing**: Uses T5 (Text-to-Text Transfer Transformer) for summarizing or generating text from user inputs.
12
- - **Image Generation**: Uses Stable Diffusion to create high-quality images from the text processed by the T5 model.
13
- - **Combined Pipeline**: A simple Python function combines these models to produce stunning images from text.
14
 
15
- ## Installation
16
 
17
- ### Prerequisites
18
 
19
- To run this project locally, ensure you have the following:
 
 
20
 
21
- 1. Python 3.7+
22
- 2. CUDA-compatible GPU (for faster performance with Stable Diffusion)
23
- 3. [Hugging Face Transformers](https://huggingface.co/transformers/) library
24
- 4. [Diffusers](https://huggingface.co/docs/diffusers/index) for Stable Diffusion
25
- 5. [PyTorch](https://pytorch.org/) with CUDA support (optional for faster image generation)
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
- It's best to use a virtual environment to manage dependencies.
37
- ```bash
38
- pip install torch transformers diffusers
39
- ```
40
 
41
- 3. **Download the Pretrained Models**:
42
- You'll need to load the models locally from Hugging Face. You can either download them using the code inside the notebook or by modifying it as follows:
43
- ```python
44
- from transformers import T5Tokenizer, T5ForConditionalGeneration
45
- from diffusers import StableDiffusionPipeline
46
- import torch
47
 
48
- # Load models
49
- t5_tokenizer = T5Tokenizer.from_pretrained("t5-small")
50
- t5_model = T5ForConditionalGeneration.from_pretrained("t5-small")
51
- ArtifyAI_model = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", torch_dtype=torch.float16)
52
 
53
- # Set model to GPU (if available)
54
- ArtifyAI_model = ArtifyAI_model.to("cuda" if torch.cuda.is_available() else "cpu")
55
- ```
56
 
57
- 4. **Run the Pipeline**:
58
- A sample pipeline is included in `pipeline.py`. You can run it using:
59
- ```bash
60
- python pipeline.py
61
- ```
62
 
63
- 5. **Text to Image Generation**:
64
- You can generate images from text input using the following function:
65
- ```python
66
- def t5_to_image_pipeline(input_text):
67
- # T5 model processing
68
- t5_inputs = t5_tokenizer.encode(input_text, return_tensors='pt', truncation=True)
69
- summary_ids = t5_model.generate(t5_inputs, max_length=50, num_beams=5, early_stopping=True)
70
- generated_text = t5_tokenizer.decode(summary_ids[0], skip_special_tokens=True)
71
 
72
- # Generate image from text using Stable Diffusion
73
- image = ArtifyAI_model(generated_text).images[0]
74
- return image
75
- ```
76
 
77
- ## Usage
78
 
79
- 1. **Run the Jupyter Notebook**: You can open `ArtifyAI_v1_1.ipynb` in Jupyter to run the code interactively.
80
- 2. **Save and Load Models**: You can modify the notebook to save your models to Google Drive or a local directory.
81
- 3. **Custom Inputs**: Modify the text input in the pipeline to generate customized images based on different descriptions.
82
 
83
- ## Example
 
84
 
85
- Here's an example of generating an image from text:
86
- ```python
87
- image = t5_to_image_pipeline("A futuristic city skyline at sunset")
 
 
 
 
88
  image.show()
 
89
 
90
- ## For Non-Technical Users
91
 
92
- Even if you are new to AI, you can use ArtifyAI by following these simple steps:
93
 
94
- 1. **Install Python**: Download and install Python 3.7+ from the [official Python website](https://www.python.org/downloads/).
95
-
96
- 2. **Install Dependencies**: Follow the steps in the Installation section to install necessary packages using the `pip` command.
97
-
98
- 3. **Run the Code**: You can run the project directly by using the provided code snippets. If you face any issues, you can refer to [Hugging Face](https://huggingface.co/) or [PyTorch](https://pytorch.org/) for troubleshooting.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Model Card: **T5 + ArtifyAI v1.1** (Text-to-Image Model)
2
 
3
+ ### **Overview**
4
+ Welcome to the model card for **T5 + ArtifyAI v1.1**! This model allows you to take text descriptions and turn them into vivid, high-quality images. Even if you have no experience with AI, this guide will walk you through every step, making it easy and fun to create your own AI-generated images.
5
 
6
+ ---
7
 
8
+ ### **What Does This Model Do?**
9
+ This model combines two key components:
10
+ - **T5**: A powerful text-processing model that understands and generates text.
11
+ - **ArtifyAI v1.1**: A text-to-image model that takes your descriptions and creates stunning images from them.
12
 
13
+ By combining these two, you can create detailed visuals based on any text input you provide.
14
 
15
+ ---
 
 
16
 
17
+ ### **Why Use Google Colab?**
18
 
19
+ **Google Colab** is an easy-to-use, cloud-based platform that allows you to run Python code without needing to install anything on your local machine. Here are some reasons why it’s beneficial:
20
 
21
+ 1. **Free Access to GPUs**: Colab offers free access to powerful hardware like GPUs, which can speed up the process of generating images, especially when working with large AI models.
22
+
23
+ 2. **No Local Setup Required**: You don’t need to worry about setting up a development environment on your computer. Colab has everything pre-installed, including libraries like `torch`, `transformers`, and `diffusers`.
24
 
25
+ 3. **Code and Documentation in One Place**: With Colab, you can write code, visualize results, and document your process all in one place. It’s perfect for both beginners and experienced users who want to experiment with machine learning models.
 
 
 
 
26
 
27
+ 4. **Save and Share Your Work**: Colab lets you save your notebooks to Google Drive or share them with others, making collaboration easy.
28
 
29
+ #### **How to Use Google Colab**
30
+ If you’re new to Google Colab, here’s a quick guide on how to get started:
 
 
 
31
 
32
+ 1. Go to [Google Colab](https://colab.research.google.com/).
33
+ 2. Click "New Notebook."
34
+ 3. You can now copy and paste the Python code provided below to start generating images.
35
+ 4. Once the notebook is ready, go to "Runtime" > "Change runtime type" and select **GPU** for faster image generation.
36
+ 5. Hit "Run" and watch as the model processes your input to generate images.
37
 
38
+ ---
 
 
 
 
 
39
 
40
+ ### **How to Install the Required Libraries**
41
+ In Google Colab, you can install the necessary libraries by running the following command:
 
 
42
 
43
+ ```bash
44
+ !pip install transformers diffusers torch huggingface_hub
45
+ ```
46
 
47
+ This installs the libraries required to run the model, including Transformers for text processing, Diffusers for image generation, and Torch for managing computations.
 
 
 
 
48
 
49
+ ---
 
 
 
 
 
 
 
50
 
51
+ ### **How to Use the Model**
 
 
 
52
 
53
+ Once you have your environment set up in Google Colab (or any Python environment), you can use the following code to generate images from text.
54
 
55
+ ```python
56
+ from diffusers import DiffusionPipeline
 
57
 
58
+ # Load the model from HuggingFace
59
+ pipe = DiffusionPipeline.from_pretrained("ImageInception/ArtifyAI-v1.1")
60
 
61
+ # Provide your text prompt
62
+ prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
63
+
64
+ # Generate the image
65
+ image = pipe(prompt).images[0]
66
+
67
+ # Display the generated image
68
  image.show()
69
+ ```
70
 
71
+ With this code, you can generate an image of an astronaut in a jungle with a cool color palette. Feel free to customize the prompt with your own creative ideas!
72
 
73
+ ---
74
 
75
+ ### **Creative Prompt Ideas**
76
+ Here are some example prompts to inspire you:
77
+
78
+ 1. **"An enchanted forest filled with tall, ancient trees and glowing fireflies."**
79
+ - Creates a mystical forest scene with glowing fireflies.
80
+
81
+ 2. **"A vintage car parked on a quiet countryside road lined with autumn leaves."**
82
+ - Produces a peaceful image of a countryside scene with a vintage car and fall colors.
83
+
84
+ 3. **"A futuristic city skyline at dusk with flying cars and glowing neon lights."**
85
+ - Visualizes a futuristic world with flying cars and vibrant city lights.
86
+
87
+ ---
88
+
89
+ ### **Why Use This Model?**
90
+ - **Beginner-Friendly**: You don’t need any prior experience with AI. Just install the libraries, run the code, and start generating images.
91
+ - **Versatile**: You can generate various types of images, from realistic to abstract, based on your text input.
92
+ - **High-Quality Images**: The model produces detailed images that are perfect for creative projects, inspiration, or fun.
93
+
94
+ ---
95
+
96
+ ### **How to Save the Generated Image**
97
+ Once you generate an image, you can save it to your Google Drive or local system:
98
+
99
+ ```python
100
+ image.save("your_image.png")
101
+ ```
102
+
103
+ This saves the generated image as a PNG file, which you can share or further edit.
104
+
105
+ ---
106
+
107
+ ### **Conclusion**
108
+ This **T5 + ArtifyAI v1.1** model brings your ideas to life by turning text descriptions into images. Whether you're working on art, design, or just experimenting with AI, this model is a powerful and easy-to-use tool that anyone can enjoy.
109
+
110
+ Start experimenting today with your own creative prompts and explore the magic of text-to-image generation with ease, especially using the power of Google Colab!