Skip to content

ojuicen/SimCLR-Animation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

SimCLR-Animation

This is my repo containing the code for my SimCLR animation. SimCLR is a contrastive learning framework, originally designed for images (you can learn about SimCLR here). I've created this animation to visually demonstrate how SimCLR works and make the process more intuitive.

To create this animation, I used manim.

Imports/Running

Run the following code to get the nessecary imports:

!sudo apt update
!sudo apt install libcairo2-dev ffmpeg texlive texlive-latex-extra texlive-fonts-extra texlive-latex-recommended texlive-science tipa libpango1.0-dev
!pip install manim
!pip install IPython --upgrade

To run the animation, use the following code:

%%manim -ql -p SimCLR2D
%%manim -ql -p SimCLR3D

2D Scene

To show what images correspond to what vectors, I start off with a 2D scene at first. Here, I show the vector-image pairs, showing the anchor (white cat), positive example (black cat), and negative example (puppy). Here's the code for the 2D scene. And, here's how the 2D Scene looks:

2D scene

3D Scene

To show the latent space, I used a 3D scene. Here, I demonstrate how the vectors are manipulated, using NT-Xent loss, to push the similar vectors together and push away the negativ example. Here's the code for the 3D scene. And, here's how the 3D Scene looks:

3D scene

Full Animation

I combine both scenes to get an overall animation:

Full Animation

About

A manim animation that visually shows how SimCLR (a contrastive learning framework) works.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages