3 min readfrom Machine Learning

I Compressed Bad Apple into a 3MB Neural Network [P]

Our take

Researchers have achieved a remarkable feat: compressing the iconic "Bad Apple" animation—approximately 2.7 billion pixels—into a remarkably compact 3MB neural network. This MLP, utilizing 790,000 parameters and sine activations (SIREN), effectively memorizes the video by predicting grayscale values based on spatial and temporal coordinates. Through innovations like time-stretching and motion-focused sampling, the model demonstrably improved reconstruction quality, achieving a 9x reduction in validation MSE.
I Compressed Bad Apple into a 3MB Neural Network [P]

The recent demonstration of compressing the iconic "Bad Apple" animation into a mere 3MB neural network is a fascinating illustration of the evolving capabilities of AI-driven data representation. It’s a compelling, albeit early, step towards a future where complex media isn't stored as vast files but as relatively compact models capable of generating it on demand. This feat, achieved by training a small MLP to essentially memorize the animation’s pixel data, highlights the potential of neural networks to move beyond traditional compression techniques. The exploration of implicit representations, as seen here with the use of SIREN activations, mirrors trends we’ve observed in other areas of AI research, particularly in generative modeling. This aligns with discussions surrounding the potential vulnerabilities of large language models, as explored in [OpenAI's AI broke loose in Hugging Face. Their defense? A Chinese model.], demonstrating a broader concern with the control and understanding of complex AI systems and their underlying data. Furthermore, the focus on efficient memory usage and computation parallels the challenges addressed in optimizing AI models for deployment on resource-constrained devices, a topic relevant to the ongoing advancements in edge computing and embedded AI, as discussed in [OpenAI's AI broke loose in Hugging Face. Their defense? A Chinese model.].

The technical details of this project – the time-stretch and motion-focused sampling techniques – are particularly noteworthy. These adjustments, made to address the limitations of initial models, underscore the iterative nature of AI research and the importance of fine-tuning training pipelines to achieve optimal results. The author’s deliberate subsampling of the original video, while reducing the compression ratio, allowed for a more manageable training process and provided valuable insights into the network's ability to learn and reconstruct complex patterns. The clear articulation of the trade-offs involved—the vertical stretching of the output video due to the square frame size, for instance—demonstrates a commitment to transparency and reproducibility, qualities that are increasingly crucial in the machine learning community. It’s important to acknowledge, as the author does, that the compression achieved isn’t revolutionary in terms of raw file size reduction. However, the value lies in the *method* – showcasing the potential for implicit representation and the intriguing possibilities for future development.

Beyond the technical accomplishment, this project sparks a broader conversation about the future of media storage and distribution. Imagine a world where libraries of movies, games, or even entire virtual environments are stored not as massive files, but as relatively small neural networks. The implications for bandwidth consumption, storage capacity, and the accessibility of digital content are significant. While challenges remain—including the computational cost of generating content from these models and ensuring fidelity and quality—this work represents a tangible step towards that future. The ongoing experimentation with smaller models and full-resolution video suggests a trajectory toward even more efficient and capable implicit representations. The fact that the author is openly sharing the code and checkpoints on GitHub is a testament to the collaborative spirit that drives innovation in the AI field and facilitates further exploration by others.

Ultimately, this "Bad Apple" demonstration isn't about achieving the ultimate compression ratio; it’s about exploring a new paradigm for representing and interacting with digital information. It’s a compelling example of how AI can be used to fundamentally rethink our approach to data management. The question now is: what other complex datasets – images, audio, video – can be effectively compressed and reconstructed using similar techniques, and what new applications will emerge as these implicit representations become more sophisticated and accessible?

I Compressed Bad Apple into a 3MB Neural Network [P]

I trained a small MLP to memorize the classic Bad Apple animation, ~2.7 billion pixels of video compressed into 790k parameters (3.2 MB float32, 1.6 MB float16).

The network takes a 3D coordinate (t, y, x)- frame index and pixel position- and outputs a grayscale value between 0 and 1. To "play" the video, you can evaluate the function over the full grid. The "video" is stored implicitly in 5 linear layers of sine activations (Sitzmann et al.'s SIREN) with 512 hidden units, ω₀ = 30, and sigmoid output.

The source bad_apple.mp4 is 6524 frames at 854×480; I subsampled to 1620 frames × 384×384, about 1/10 of the original pixels (2.8x spatial + 4x temporal reduction).

At first, I used a ReLU MLP with low-frequency Fourier features, which plateaued around MSE 0.12. SIREN's sine activations add higher frequency for free, so the network was capable of outputting fine details. Unfortunately, that model had an issue, which was that it could only shift the information slowly, so quick motion came out blurry.

To fix this, I made two changes:

  1. Time-stretch: I scaled the time coordinate by 4x relative to the space before the first layer, giving it 4x more temporal capacity.
  2. Motion-focused sampling: Bad Apple is ~90% static black, so uniform pixel sampling starved the moving edges of the gradient. Now half of each training batch is drawn from pixels that changed between neighboring frames.

For the training pipeline, I had a single shared network on the whole volume (no per-frame latents; initially, I used per-frame finetuning, but that caused catastrophic forgetting) with a cosine-scheduled Adam + weight EMA, then a low-LR "polish" pass over the whole video.

The new model had these improvements:

Validation MSE dropped from 0.0795 to 0.0090 (~9x better).
Compared to the old model, high-motion frames were 3.6x closer to ground truth, and static frames were almost 15x closer.
398/400 sampled frames improved.

Edit: Some people are a little confused about the compressed part. The subsampled video is 700KB, and the network that creates a reconstruction of it is ~3MB. It hasn't been compressed very much, but the goal was seeing if I could (and learning) rather than super compression.

I'll try to see if an even smaller model can learn it. Additionally, I'm training a model on the full non-subsampled video.

Notes

384×384 is square (the original is 16:9, so playback is vertically stretched. At 8fps playback, the 1620 frames run near the original's 3:37 duration; at 12fps it's \1.6× fast-forward. The 12.6MB checkpoint includes the weights + Adam moments + EMA copy; the network itself is 3.2MB.))

The full resolution videos, checkpoints, and code can be found in this Github Link

submitted by /u/Which_Lie_8932
[link] [comments]

Read on the original site

Open the publisher's page for the full experience

View original article