• Stars
    star
    141
  • Rank 258,755 (Top 6 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Synthesize photos from PhotoDNA using machine learning ๐ŸŒฑ

Ribosome Build Status

Synthesize photos from PhotoDNA.

Ribosome demo

See the blog post for more information.

Installation

Dependencies

You can install Python dependencies using pip install -r requirements.txt. If you want to install the packages manually, here is a list:

Pre-trained models

Ribosome is released with 4 pre-trained models:

Use the models trained on NSFW data at your own risk.

Usage

Inference

Use the infer.py script to produce images from hashes:

python infer.py [--model MODEL] [--output OUTPUT] hash

The hash is a base64-encoded string, e.g. cVwhQ58OSCEOIwF+AigAkT0GAWdwAQs8o04KGYMfHBUANRUOAycUEFABCh6PABIghDBzCa4RTysQYVcvMDdkMypBPSyNAgRCcTf2AC9PfiYSWDw3KTcxPxM2HSqTDSIsgxJFFA+iihERcU4fHEY4Lj0xhw3QJN4OXQwbIzJjVTsUodIVVy3/FY8I/wcui11O.

Training

Datasets

Datasets consist of images paired with hashes, in the format of a CSV file with paths/hashes, and image files in a directory. The CSV file has two colums, path and hash (no header row). The hash is base64-encoded. Images are 100x100 in size. After producing such a CSV, it may be convenient to shuffle it and split it into a training set and validation set.

Example dataset

Ribosome includes an example dataset in this format, produced from COCO:

Preparing a dataset

To produce 100x100 images from an existing dataset, it may be convenient to use ImageMagick.

To resize image.jpg to 100x100 ignoring the original aspect ratio:

mogrify -resize '100x100!' image.jpg

To resize image.jpg to 100x100 by taking a center crop:

mogrify -resize '100x100^' -gravity Center -extent '100x100' image.jpg

You can process files in parallel using find / xargs, e.g. to convert all .jpg images using 24 threads:

find . -name '*.jpg' | xargs -n 1 -P 24 mogrify -resize '100x100!'

Ribosome does not provide code to compute PhotoDNA hashes, but such code is available in pyPhotoDNA.

Train a model

Use the train.py script to train a model on a dataset:

python train.py --train-data TRAIN_DATA ...
  • --train-data is the path to the train data CSV
  • Paths in the CSV are interpreted relative to --data-dir (or . if not supplied)
  • --val-data is the path to the validation data CSV; if provided, the script will report the validation loss after every epoch

See python train.py --help for all the options.

Citation

If you use this implementation in your work, please cite the following:

@misc{athalye2021ribosome,
  author = {Anish Athalye},
  title = {Inverting {PhotoDNA}},
  month = dec,
  year = 2021,
  howpublished = {\url{https://www.anishathalye.com/2021/12/20/inverting-photodna/}},
}

License

Copyright (c) Anish Athalye. Released under the MIT License. See LICENSE.md for details.

More Repositories

1

dotbot

A tool that bootstraps your dotfiles โšก๏ธ
Python
6,896
star
2

neural-style

Neural style in TensorFlow! ๐ŸŽจ
Python
5,542
star
3

git-remote-dropbox

A transparent bridge between Git and Dropbox - use a Dropbox (shared) folder as a Git remote! ๐ŸŽ
Python
3,041
star
4

lumen

Magic auto brightness based on screen contents ๐Ÿ’ก
Objective-C
2,284
star
5

gemini

Gemini is a modern LaTex beamerposter theme ๐Ÿ–ผ
TeX
946
star
6

obfuscated-gradients

Obfuscated Gradients Give a False Sense of Security: Circumventing Defenses to Adversarial Examples
Jupyter Notebook
876
star
7

porcupine

A fast linearizability checker written in Go ๐Ÿ”Ž
Go
856
star
8

seashells

The official client for seashells.io ๐Ÿš
Python
706
star
9

dotfiles

~anish โ€ข powered by https://github.com/anishathalye/dotbot ๐Ÿ’พ
Shell
691
star
10

neural-hash-collider

Preimage attack against NeuralHash ๐Ÿ’ฃ
Python
663
star
11

gavel

A project expo judging system ๐Ÿ“Š
Python
430
star
12

periscope

Periscope gives you "duplicate vision" to help you organize and de-duplicate your files without losing data ๐Ÿ”ญ
Go
372
star
13

auriga

Auriga is a minimalist LaTeX beamer presentation theme ๐Ÿ“ฝ
TeX
322
star
14

offix

"Who is in the office?" ๐Ÿ‘€
JavaScript
181
star
15

dotfiles_template

A template for structuring dotfiles (using Dotbot as an installer) ๐Ÿ“œ
PowerShell
181
star
16

imagenet-simple-labels

Simpler human-readable labels for ImageNet ๐Ÿท
117
star
17

dotfiles-local

~anish [local config] โ€ขย powered by https://github.com/anishathalye/dotbot ๐Ÿ 
Shell
74
star
18

mathematics-of-deep-learning

The Mathematics of Deep Learning, SIPB IAP 2018
Jupyter Notebook
74
star
19

proof-html

A GitHub Action to validate HTML, check links, and more โœ…
Ruby
53
star
20

seashells-server

The seashells.io server ๐Ÿš
Go
52
star
21

knox

A framework for formally verifying hardware security modules to be free of hardware, software, and timing side-channel vulnerabilities ๐Ÿ”
Racket
29
star
22

notary

Notary: A Device for Secure Transaction Approval ๐Ÿ“Ÿ
Verilog
28
star
23

hubot-group

A hubot script that expands mentions of groups ๐Ÿ‘ซ
CoffeeScript
26
star
24

synox

Rust library for program synthesis of string transformations from input-output examples ๐Ÿ”ฎ
Rust
24
star
25

disposable

Create a Reddit throwaway account with the click of a button! ๐Ÿšฎ
JavaScript
23
star
26

knox-hsm

Circuits and hardware security modules formally verified with Knox ๐Ÿ”
Verilog
22
star
27

skipchat

SkipChat - MHacks V
C
20
star
28

rtlv

Tools for reasoning about circuits in Rosette/Racket ๐Ÿ”Œ
Racket
18
star
29

micro-wwvb

A tiny WWVB station ๐Ÿ“ก
C
17
star
30

linux-bootstrap

get a debian-based system set up the way I like it, with minimal effort on my part
17
star
31

hubot-shortcut

A macro system for hubot ๐Ÿ’จ
JavaScript
16
star
32

bin2coe

A tool to convert binary files to COE files ๐Ÿ’ซ
Python
14
star
33

hubot-conf

A simple configuration management system for hubot ๐Ÿ”ง
JavaScript
11
star
34

anishathalye

A self-updating GitHub profile ๐Ÿฏ
Python
11
star
35

gitlive

the source code that powered gitlive.net
Java
11
star
36

chroniton

A tool for formally verifying constant-time software against hardware ๐Ÿ•ฐ๏ธ
Racket
9
star
37

unblock

A tiny utility to make shell pipes behave as if they have unlimited buffering โ™พ
Go
7
star
38

countdown

A simple countdown timer you can set as your homepage โฐ
HTML
5
star
39

coqioa

A formalization of IO automata in the Coq proof assistant
Coq
5
star
40

x

playground for testing stuff on github
4
star
41

assets

README assets for my GitHub projects ๐ŸŽญ
4
star
42

easy-security

Slides from the SIPB Cluedump on Low Effort High Impact Security
HTML
3
star
43

learn-pgp

Slides from the SIPB Cluedump on PGP
HTML
3
star
44

learn-git

An introduction to using Git - prepared for HackMIT / Hack Week 2015
HTML
2
star
45

deterministic-start-benchmark

Verilog
2
star
46

ipr

A formalization of information-preserving refinement (IPR) in the Coq Proof Assistant ๐Ÿงฉ
Coq
2
star
47

xclips

Rust
1
star
48

scripts

Python
1
star
49

formal-methods-tutorial-2022-10-11

Racket
1
star