Skip to main content

Ascii Artist

An ascii art generator that's actually good. Does edge detection and selects the most appropriate characters.

Blue Tit

Blue Tit

Niko from oneshot!

Installing

Installing with pip:

pip install asciiartist

Installing from wheel:

Download the wheel file from this project's releases and run

pip install <path/to/wheel>

Quick Start

from asciiartist import asciiartist, display_edges
from PIL import Image

img = Image.open("niko.png")

art, edges = asciiartist(
    img, # The image!
    30,  # Number of lines of the output ascii art
    noise_reduction=2,  # Level of noise reduction (optional)
    line_weight=1,      # Weight of the lines to draw (optional)
    text_ratio=2.2      # Height/width ratio of each character (optional)
)

print(art) # `art` is a string u can just print

# v Display the result of edge detection. 
#   Good for finetuning params.
display_edges(edges)

Build from Source

Run the script ./model/model-gen.py and build the wheel with poetry build -f wheel.

How it works

Roughly, how Ascii Artist generates the drawings:

  1. Run edge detection
  2. Segment the image for each char
  3. Pass each segment through a CNN to get the most appropriate character.

The CNN is trained with distorted images of characters (in font consolas), created in a way that emulates the output of the edge detection.

Bye

^-^

                                          __=E.L__      
                                        >#-=@>@F* `<_   
                                      _/`@o<FTFC@[_~_.__
                                   _./`\_`<__      @@7*`
                              _,~``      *v `^L_  )(    
                         _,~^C___ _    ````*@```````    
                   __,;@"*'`C` *@@_       _-V           
               __,@'^`CC)-[_L-----o,,}<@F--             
    __,-Ec>C<4@'C`'`"-[_,/   _,L-L             ,"       
 -`````          ````                       _-'         
                        _   _           __~``           
                        ``  "<`  _                      
                              `(V\_                     
                                `V(<_                   
                   _____,,~~<7oEE(@@_Eo@@Fo,            
       ___,-~-^````               .-.__V)  ,_           

Metadata

Release files for asciiartist 0.5.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asciiartist 0.5.4
File Size Uploaded
asciiartist-0.5.4.tar.gz 3.6 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for asciiartist 0.5.4
File Interpreter ABI Platform
asciiartist-0.5.4-py3-none-any.whl Python 3 none any Details

Total release size: 7.1 MB

Release files / asciiartist-0.5.4.tar.gz

Download URL asciiartist-0.5.4.tar.gz
Size 3.6 MB
Tags Source
SHA-256 checksum
How to use checksums
7f02b93509dd99feda953141f87041a11fdec3edf3d47da5d6ab0011a57635e8
BLAKE2b-256 checksum
How to use checksums
2101c9dc763b314863bd6041623406fe1206ca40e14bc4833bbdf6745cb011a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.11 CPython/3.7.9 Windows/10

Release files / asciiartist-0.5.4-py3-none-any.whl

Download URL asciiartist-0.5.4-py3-none-any.whl
Size 3.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
ff4b2abb25fd631ad11b5117e408b3967670d2a86cf258f4a903f68c550af8dd
BLAKE2b-256 checksum
How to use checksums
310c4bc3d1956479746846e4311206b15017698eb79771c4a84f94b6a1be5d82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.11 CPython/3.7.9 Windows/10

Release history Release notifications | RSS feed

This release

0.5.4 This release

2 release files

0.5.3

2 release files

0.5.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page