GitHub - adnqcr7-code/Data-Adaptive-Network · GitHub
/" data-turbo-transient="true" />
Skip to content
Search or jump to...
Search code, repositories, users, issues, pull requests...
-->
Search
Clear
Search syntax tips
Provide feedback
--><br>We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
Saved searches
Use saved searches to filter your results more quickly
-->
Name
Query
To see all available qualifiers, see our documentation.
Cancel
Create saved search
Sign in
/;ref_cta:Sign up;ref_loc:header logged out"}"<br>Sign up
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
adnqcr7-code
Data-Adaptive-Network
Public
Notifications<br>You must be signed in to change notification settings
Fork
Star
main
BranchesTags
Go to file
CodeOpen more actions menu
Folders and files<br>NameNameLast commit message<br>Last commit date<br>Latest commit
History<br>1 Commit<br>1 Commit
examples
examples
README.md
README.md
dan_model.py
dan_model.py
dictionary_compressor.py
dictionary_compressor.py
make_dataset.py
make_dataset.py
requirements.txt
requirements.txt
rle_compressor.py
rle_compressor.py
test_dan.py
test_dan.py
train_dan.py
train_dan.py
View all files
Repository files navigation
DAN Compressor
An experimental image compression toolkit built specifically for anime-style / flat-color line art . Not a general-purpose codec — it's a testbed for compression techniques tuned to this one content type.
This is an early, honest work-in-progress. Some parts work and beat PNG. Some parts don't work yet. This README tells you which is which.
Status: v0.1 (early prototype)
Component<br>Status<br>Result
rle_compressor.py<br>Working, tested, lossless<br>Beats PNG by ~2.5x on flat-color test images. Slightly behind WebP lossless.
dan_model.py + autoencoder<br>Working, tested, lossy<br>Compresses to a fixed small size but reconstruction is blurry. Only works on images similar to its (small, synthetic) training set. Fails badly on photographic/noisy images - see benchmarks below.
dictionary_compressor.py<br>Working, tested, NOT competitive yet<br>Currently loses to rle_compressor.py on flat-color art. Kept in the repo because the negative result is documented and it may be useful combined with other techniques later.
Edge predictor<br>Not built<br>Design idea only.
Position guesser<br>Not built<br>Design idea only.
Residual encoder<br>Not built<br>Design idea only.
Color graph<br>Not built<br>Design idea only.
Real benchmark numbers (not marketing)
Tested on a 300x300 synthetic anime-style test image (8 unique colors):
Method<br>Size<br>Notes
PNG<br>2858 bytes<br>baseline
WebP (lossless)<br>1084 bytes<br>mature, hard to beat
RLE + zlib (this repo)<br>1137 bytes<br>lossless, 2.5x smaller than PNG
Dictionary matcher (this repo)<br>2001 bytes<br>lossless, beats PNG but loses to RLE
DAN autoencoder (this repo)<br>1024 bytes (fixed)<br>lossy , blurry, only works on faces similar to training data
Tested on a "hard" noisy/textured image (deliberately outside this project's target niche):
Method<br>Size<br>Quality
PNG<br>35824 bytes<br>perfect (lossless)
WebP (lossless)<br>38022 bytes<br>perfect (lossless)
DAN autoencoder<br>1024 bytes<br>unusable - PSNR 7.7dB, image is unrecognizable
Takeaway: this toolkit is not a general image compressor. It's narrowly useful for flat-color line art, and even there, only rle_compressor.py currently earns its place against existing formats.
Why release this now, if it's incomplete?
Because the honest incremental results are still useful: the negative result on the dictionary matcher, and the failure mode of the autoencoder on out-of-distribution images, are real findings that took real testing to get. Better to document what's true than claim more than what's built.
Usage
# Lossless RLE compressor (recommended, actually works)<br>python rle_compressor.py input.png output.dan_rle
# Decompress<br>python -c "from rle_compressor import decompress; decompress('output.dan_rle', 'restored.png')"
# Experimental dictionary matcher<br>python dictionary_compressor.py input.png output.dan_dict
# Train the autoencoder on your own dataset<br>python make_dataset.py # generates synthetic training data, or supply your own<br>python train_dan.py # trains, saves dan_model.pt<br>python test_dan.py # tests compression + reconstruction quality
Requires: pillow, numpy, torch, torchvision
Known limitations (read before using)
rle_compressor.py only supports images with The autoencoder model (dan_model.pt) was trained on ~300 small synthetic images. It has not been trained on real anime art and will likely need retraining on a proper dataset before it's useful.
The autoencoder's current architecture has an oversized fully-connected bottleneck (contributes ~68MB...