File size: 2,201 Bytes
010f6f2
 
 
 
e99d24b
a8b487b
010f6f2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
---
license: mit
---

# ZipPlus Model Card
**A pre-trained 4-layer GRU model for neural file compression. Compress any file into a PNG image using a neural network and extract it back.**
This is a pre-trained ByteGRU model for [Zip+](https://github.com/CompactAIOfficial/ZipPlus) - use this instead of training your own.

## What is this
This model compresses any file into a PNG image using a neural network (GRU + range coding) and extracts it back. The compressed files look like weird colorful static - perfect for confusing anyone who peeks at your folder.
```
file.txt → [ByteGRU + Range Coding] → file.txt.zpng.png → [ByteGRU + Range Coding] → file.txt
```
**The PNG contains a special `ZPNG` magic header**, so random images won't decompress. Your cat photos are safe. Mostly.

## Model Details
- **Architecture**: 2-layer GRU over byte embeddings
- **Embedding dim**: 64 → Hidden dim: 256
- **Trained on**: A variety of file types
- **Entropy coding**: Range coding via Constriction
- **Output format**: PNG where payload lives in RGB pixel bytes
- **Magic header**: `ZPNG` (first 4 bytes)
- 
## Requirements
- Python 3.10+
- PyTorch
- Constriction (`pip install constriction`)
- Pillow
- numpy
```bash
pip install torch constriction pillow numpy
```
## Quick Start

### Compress a file

```bash
python inference.py compress myfile.txt -o myfile.zpng.png -m model.pt
```
### Decompress

```bash
python inference.py decompress myfile.zpng.png -o restored.txt -m model.pt
```
Done. Your file is back. Hopefully.

## Interactive Menu

Just run `python compressor.py -m model.pt` for the menu. It's vaguely intuitive if you squint.

## Performance

Compression ratio varies. Text files compress okay. Binary files? Less okay. Random data? It might actually grow. That's the fun part.

## Warnings

- **Don't lose this model**. Without the model file, your `.zpng.png` files are colorful but useless.
- **Lossiness is possible**. If the compression produces artifacts, restored files may differ. Check with checksums.
- **GPU recommended**. CPU inference is tolerable.
- 
## License

MIT. I'm not liable if this eats your thesis/pixels/anything.
---
Use it because it's amusing. Or don't