Skip to content

Instantly share code, notes, and snippets.

@bhautikj
Created October 1, 2016 14:25
Show Gist options
  • Save bhautikj/3546c7ea86cc1e9d268f807df50739c6 to your computer and use it in GitHub Desktop.
Save bhautikj/3546c7ea86cc1e9d268f807df50739c6 to your computer and use it in GitHub Desktop.
deep dreaming + open nsfw
# git clone https://github.com/jrosebr1/bat-country.git
# git clone https://github.com/yahoo/open_nsfw
# cd bat-country
from batcountry import BatCountry
import numpy as np
from PIL import Image
import caffe
import sys
bc = BatCountry("../open_nsfw/nsfw_model", model_path="../open_nsfw/nsfw_model/resnet_50_1by2_nsfw.caffemodel", mean=(104.0, 117.0, 123.0))
image = bc.dream(np.float32(Image.open(sys.argv[1])),end="eltwise_stage3_block0",iter_n=12)
bc.cleanup()
result = Image.fromarray(np.uint8(image))
result.save(sys.argv[2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment