create and convert image to ascii in a single prompt
Here's Colab Notebook for the same:
https://colab.research.google.com/drive/1jh3aDOkxTV5mGiDtUWSFTAJTfUI6VTMh?usp=sharing
- Generate images from text prompts using Stable Diffusion 2
- Convert existing images (from local files or URLs) to ASCII art
- Save both the generated image and ASCII art output
- Python 3.7+
- CUDA-capable GPU (for Stable Diffusion image generation)
-
Clone this repository:
git clone https://github.com/yourusername/askcii.git cd askcii
-
Install the required dependencies:
pip install -r requirements.txt
The basic syntax for using ASKCII is:
usage: askcii.py [-h] [-u [URL]] [-p PROMPT] [-wt WIDTH] [-ht HEIGHT] [-s STEPS] [-m MODEL] {create}
ASKCII: ASCII Art Generator
positional arguments:
{create} Command to execute
options:
-h, --help show this help message and exit
-u [URL], --url [URL]
URL or path to the image file
-p PROMPT, --prompt PROMPT
Prompt to generate the ASCII art
-wt WIDTH, --width WIDTH
Width to resize the image (default: original width)
-ht HEIGHT, --height HEIGHT
Height to resize the image (default: original height)
-s STEPS, --steps STEPS
Number of inference steps for Stable Diffusion (default: 50)
-m MODEL, --model MODEL
Diffusion model to use (default: stable-diffusion-2-1-base)
-
Generate ASCII art from a text prompt:
python askcii.py create -p "{prompt}" -s {steps} -wt {width} -ht {height} --model {model_id}
-
Generate ASCII art from a local image:
python askcii.py create -u path/to/your/image.jpg
-
Generate ASCII art from an online image:
python askcii.py create -u https://example.com/image.jpg
For each run, ASKCII will:
- Print the ASCII art to the console
- Save the ASCII art to a file named
ascii_output.txt
The first time you run ASKCII with a text prompt, it will download the Stable Diffusion 2 model, which is several gigabytes in size. This may take some time depending on your internet connection.
- The script is currently set up to use CUDA for GPU acceleration. If you're running on a CPU or a different GPU architecture, you may need to modify the
generate_image_from_prompt()
function. - Image generation can be computationally intensive and may take some time, depending on your hardware.
Contributions to ASKCII are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- This project uses the Stable Diffusion model via the 🤗 Diffusers library.
- ASCII art conversion inspired by various open-source projects in the community.