Giter Club home page Giter Club logo

open_nsfw's Introduction

Open nsfw model

This repo contains code for running Not Suitable for Work (NSFW) classification deep neural network Caffe models. Please refer our blog post which describes this work and experiments in more detail.

Not suitable for work classifier

Detecting offensive / adult images is an important problem which researchers have tackled for decades. With the evolution of computer vision and deep learning the algorithms have matured and we are now able to classify an image as not suitable for work with greater precision.

Defining NSFW material is subjective and the task of identifying these images is non-trivial. Moreover, what may be objectionable in one context can be suitable in another. For this reason, the model we describe below focuses only on one type of NSFW content: pornographic images. The identification of NSFW sketches, cartoons, text, images of graphic violence, or other types of unsuitable content is not addressed with this model.

Since images and user generated content dominate the internet today, filtering nudity and other not suitable for work images becomes an important problem. In this repository we opensource a Caffe deep neural network for preliminary filtering of NSFW images.

Demo Image

Usage

  • The network takes in an image and gives output a probability (score between 0-1) which can be used to filter not suitable for work images. Scores < 0.2 indicate that the image is likely to be safe with high probability. Scores > 0.8 indicate that the image is highly probable to be NSFW. Scores in middle range may be binned for different NSFW levels.
  • Depending on the dataset, usecase and types of images, we advise developers to choose suitable thresholds. Due to difficult nature of problem, there will be errors, which depend on use-cases / definition / tolerance of NSFW. Ideally developers should create an evaluation set according to the definition of what is safe for their application, then fit a ROC curve to choose a suitable threshold if they are using the model as it is.
  • Results can be improved by fine-tuning the model for your dataset/ use case / definition of NSFW. We do not provide any guarantees of accuracy of results. Please read the disclaimer below.
  • Using human moderation for edge cases in combination with the machine learned solution will help improve performance.

Description of model

We trained the model on the dataset with NSFW images as positive and SFW(suitable for work) images as negative. These images were editorially labelled. We cannot release the dataset or other details due to the nature of the data.

We use CaffeOnSpark which is a wonderful framework for distributed learning that brings deep learning to Hadoop and Spark clusters for training models for our experiments. Big thanks to the CaffeOnSpark team!

The deep model was first pretrained on ImageNet 1000 class dataset. Then we finetuned the weights on the NSFW dataset. We used the thin resnet 50 1by2 architecture as the pretrained network. The model was generated using pynetbuilder tool and replicates the residual network paper's 50 layer network (with half number of filters in each layer). You can find more details on how the model was generated and trained here

Please note that deeper networks, or networks with more filters can improve accuracy. We train the model using a thin residual network architecture, since it provides good tradeoff in terms of accuracy, and the model is light-weight in terms of runtime (or flops) and memory (or number of parameters).

Docker Quickstart

This Docker quickstart guide can be used for evaluating the model quickly with minimal dependency installation.

Install Docker Engine

Build a caffe docker image (CPU)

docker build -t caffe:cpu https://raw.githubusercontent.com/BVLC/caffe/master/docker/cpu/Dockerfile

Check the caffe installation

docker run caffe:cpu caffe --version
caffe version 1.0.0-rc3

Run the docker image with a volume mapped to your open_nsfw repository. Your test_image.jpg should be located in this same directory.

cd open_nsfw
docker run --volume=$(pwd):/workspace caffe:cpu \
python ./classify_nsfw.py \
--model_def nsfw_model/deploy.prototxt \
--pretrained_model nsfw_model/resnet_50_1by2_nsfw.caffemodel \
test_image.jpg

We will get the NSFW score returned:

NSFW score:   0.14057905972

Running the model

To run this model, please install Caffe and its python extension and make sure pycaffe is available in your PYTHONPATH.

We can use the classify.py script to run the NSFW model. For convenience, we have provided the script in this repo as well, and it prints the NSFW score.

python ./classify_nsfw.py \
--model_def nsfw_model/deploy.prototxt \
--pretrained_model nsfw_model/resnet_50_1by2_nsfw.caffemodel \
INPUT_IMAGE_PATH 

Disclaimer

The definition of NSFW is subjective and contextual. This model is a general purpose reference model, which can be used for the preliminary filtering of pornographic images. We do not provide guarantees of accuracy of output, rather we make this available for developers to explore and enhance as an open source project. Results can be improved by fine-tuning the model for your dataset.

License

Code licensed under the [BSD 2 clause license] (https://github.com/BVLC/caffe/blob/master/LICENSE). See LICENSE file for terms.

Contact

The model was trained by Jay Mahadeokar, in collaboration with Sachin Farfade , Amar Ramesh Kamat, Armin Kappeler and others. Special thanks to Gerry Pesavento for taking the initiative for open-sourcing this model. If you have any queries, please raise an issue and we will get back ASAP.

open_nsfw's People

Contributors

jay-mahadeokar avatar mattlawer avatar neufeldtech avatar schmich avatar spartanhaden avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

open_nsfw's Issues

Releasing Other Models?

First of all, thanks for the release! Second: its a pity that the released model (Resnet) has a highly non-standard layer ("Scale", which has a learnable bias parameter). That means that this model cannot be converted to other frameworks (Torch, MXNet, etc).

Would it be possible to release one of your other models as well, such as the Googlenet model?

Thanks!

Disable warning/error messages

Is there a way to disable them? Currently analyzing a single image with the provided classify_nsfw.py outputs around 3700 rows of messages.

A few example lines

I1103 16:15:50.618033  4604 net.cpp:165] Memory required for data: 119619584
I1103 16:15:50.618046  4604 layer_factory.hpp:77] Creating layer scale_stage3_block0_branch2c
I1103 16:15:50.618054  4604 net.cpp:100] Creating Layer scale_stage3_block0_branch2c
I1103 16:15:50.618062  4604 net.cpp:434] scale_stage3_block0_branch2c <- conv_stage3_block0_branch2c
I1103 16:15:50.618069  4604 net.cpp:395] scale_stage3_block0_branch2c -> conv_stage3_block0_branch2c (in-place)
I1103 16:15:50.618088  4604 layer_factory.hpp:77] Creating layer scale_stage3_block0_branch2c
I1103 16:15:50.618109  4604 net.cpp:150] Setting up scale_stage3_block0_branch2c
I1103 16:15:50.618119  4604 net.cpp:157] Top shape: 1 1024 7 7 (50176)
I1103 16:15:50.618125  4604 net.cpp:165] Memory required for data: 119820288
I1103 16:15:50.618134  4604 layer_factory.hpp:77] Creating layer eltwise_stage3_block0
I1103 16:15:50.618150  4604 net.cpp:100] Creating Layer eltwise_stage3_block0
I1103 16:15:50.618157  4604 net.cpp:434] eltwise_stage3_block0 <- conv_stage3_block0_proj_shortcut
I1103 16:15:50.618165  4604 net.cpp:434] eltwise_stage3_block0 <- conv_stage3_block0_branch2c
I1103 16:15:50.618176  4604 net.cpp:408] eltwise_stage3_block0 -> eltwise_stage3_block0
I1103 16:15:50.618190  4604 net.cpp:150] Setting up eltwise_stage3_block0
I1103 16:15:50.618198  4604 net.cpp:157] Top shape: 1 1024 7 7 (50176)
I1103 16:15:50.618204  4604 net.cpp:165] Memory required for data: 120020992
I1103 16:15:50.618211  4604 layer_factory.hpp:77] Creating layer relu_stage3_block0
I1103 16:15:50.618219  4604 net.cpp:100] Creating Layer relu_stage3_block0
I1103 16:15:50.618226  4604 net.cpp:434] relu_stage3_block0 <- eltwise_stage3_block0
I1103 16:15:50.618233  4604 net.cpp:395] relu_stage3_block0 -> eltwise_stage3_block0 (in-place)
I1103 16:15:50.618242  4604 net.cpp:150] Setting up relu_stage3_block0
I1103 16:15:50.618250  4604 net.cpp:157] Top shape: 1 1024 7 7 (50176)
I1103 16:15:50.618255  4604 net.cpp:165] Memory required for data: 120221696
I1103 16:15:50.618263  4604 layer_factory.hpp:77] Creating layer eltwise_stage3_block0_relu_stage3_block0_0_split
I1103 16:15:50.618271  4604 net.cpp:100] Creating Layer eltwise_stage3_block0_relu_stage3_block0_0_split
I1103 16:15:50.618278  4604 net.cpp:434] eltwise_stage3_block0_relu_stage3_block0_0_split <- eltwise_stage3_block0
I1103 16:15:50.618288  4604 net.cpp:408] eltwise_stage3_block0_relu_stage3_block0_0_split -> eltwise_stage3_block0_relu_stage3_block0_0_split_0
I1103 16:15:50.618299  4604 net.cpp:408] eltwise_stage3_block0_relu_stage3_block0_0_split -> eltwise_stage3_block0_relu_stage3_block0_0_split_1
I1103 16:15:50.618309  4604 net.cpp:150] Setting up eltwise_stage3_block0_relu_stage3_block0_0_split
I1103 16:15:50.618319  4604 net.cpp:157] Top shape: 1 1024 7 7 (50176)
I1103 16:15:50.618325  4604 net.cpp:157] Top shape: 1 1024 7 7 (50176)
I1103 16:15:50.618330  4604 net.cpp:165] Memory required for data: 120623104
I1103 16:15:50.618336  4604 layer_factory.hpp:77] Creating layer conv_stage3_block1_branch2a
I1103 16:15:50.618351  4604 net.cpp:100] Creating Layer conv_stage3_block1_branch2a
I1103 16:15:50.618358  4604 net.cpp:434] conv_stage3_block1_branch2a <- eltwise_stage3_block0_relu_stage3_block0_0_split_0
I1103 16:15:50.618372  4604 net.cpp:408] conv_stage3_block1_branch2a -> conv_stage3_block1_branch2a
I1103 16:15:50.621122  4604 net.cpp:150] Setting up conv_stage3_block1_branch2a
I1103 16:15:50.621167  4604 net.cpp:157] Top shape: 1 256 7 7 (12544)
I1103 16:15:50.621173  4604 net.cpp:165] Memory required for data: 120673280
I1103 16:15:50.621199  4604 layer_factory.hpp:77] Creating layer bn_stage3_block1_branch2a
I1103 16:15:50.621217  4604 net.cpp:100] Creating Layer bn_stage3_block1_branch2a
I1103 16:15:50.621227  4604 net.cpp:434] bn_stage3_block1_branch2a <- conv_stage3_block1_branch2a
I1103 16:15:50.621237  4604 net.cpp:395] bn_stage3_block1_branch2a -> conv_stage3_block1_branch2a (in-place)
I1103 16:15:50.621269  4604 net.cpp:150] Setting up bn_stage3_block1_branch2a
I1103 16:15:50.621279  4604 net.cpp:157] Top shape: 1 256 7 7 (12544)
I1103 16:15:50.621285  4604 net.cpp:165] Memory required for data: 120723456
I1103 16:15:50.621299  4604 layer_factory.hpp:77] Creating layer scale_stage3_block1_branch2a
I1103 16:15:50.621312  4604 net.cpp:100] Creating Layer scale_stage3_block1_branch2a
I1103 16:15:50.621318  4604 net.cpp:434] scale_stage3_block1_branch2a <- conv_stage3_block1_branch2a
I1103 16:15:50.621330  4604 net.cpp:395] scale_stage3_block1_branch2a -> conv_stage3_block1_branch2a (in-place)
I1103 16:15:50.621347  4604 layer_factory.hpp:77] Creating layer scale_stage3_block1_branch2a
I1103 16:15:50.621371  4604 net.cpp:150] Setting up scale_stage3_block1_branch2a
I1103 16:15:50.621381  4604 net.cpp:157] Top shape: 1 256 7 7 (12544)
I1103 16:15:50.621387  4604 net.cpp:165] Memory required for data: 120773632
I1103 16:15:50.621397  4604 layer_factory.hpp:77] Creating layer relu_stage3_block1_branch2a
I1103 16:15:50.621408  4604 net.cpp:100] Creating Layer relu_stage3_block1_branch2a
I1103 16:15:50.621415  4604 net.cpp:434] relu_stage3_block1_branch2a <- conv_stage3_block1_branch2a
I1103 16:15:50.621423  4604 net.cpp:395] relu_stage3_block1_branch2a -> conv_stage3_block1_branch2a (in-place)
I1103 16:15:50.621433  4604 net.cpp:150] Setting up relu_stage3_block1_branch2a
I1103 16:15:50.621441  4604 net.cpp:157] Top shape: 1 256 7 7 (12544)
I1103 16:15:50.621448  4604 net.cpp:165] Memory required for data: 120823808
I1103 16:15:50.621454  4604 layer_factory.hpp:77] Creating layer conv_stage3_block1_branch2b
I1103 16:15:50.621469  4604 net.cpp:100] Creating Layer conv_stage3_block1_branch2b
I1103 16:15:50.621474  4604 net.cpp:434] conv_stage3_block1_branch2b <- conv_stage3_block1_branch2a
I1103 16:15:50.621490  4604 net.cpp:408] conv_stage3_block1_branch2b -> conv_stage3_block1_branch2b
I1103 16:15:50.627259  4604 net.cpp:150] Setting up conv_stage3_block1_branch2b
I1103 16:15:50.627300  4604 net.cpp:157] Top shape: 1 256 7 7 (12544)
I1103 16:15:50.627306  4604 net.cpp:165] Memory required for data: 120873984
I1103 16:15:50.627321  4604 layer_factory.hpp:77] Creating layer bn_stage3_block1_branch2b
I1103 16:15:50.627337  4604 net.cpp:100] Creating Layer bn_stage3_block1_branch2b
I1103 16:15:50.627347  4604 net.cpp:434] bn_stage3_block1_branch2b <- conv_stage3_block1_branch2b
I1103 16:15:50.627358  4604 net.cpp:395] bn_stage3_block1_branch2b -> conv_stage3_block1_branch2b (in-place)
I1103 16:15:50.627384  4604 net.cpp:150] Setting up bn_stage3_block1_branch2b
I1103 16:15:50.627393  4604 net.cpp:157] Top shape: 1 256 7 7 (12544)
I1103 16:15:50.627399  4604 net.cpp:165] Memory required for data: 120924160
I1103 16:15:50.627411  4604 layer_factory.hpp:77] Creating layer scale_stage3_block1_branch2b
I1103 16:15:50.627423  4604 net.cpp:100] Creating Layer scale_stage3_block1_branch2b
I1103 16:15:50.627429  4604 net.cpp:434] scale_stage3_block1_branch2b <- conv_stage3_block1_branch2b
I1103 16:15:50.627437  4604 net.cpp:395] scale_stage3_block1_branch2b -> conv_stage3_block1_branch2b (in-place)
I1103 16:15:50.627454  4604 layer_factory.hpp:77] Creating layer scale_stage3_block1_branch2b
I1103 16:15:50.627478  4604 net.cpp:150] Setting up scale_stage3_block1_branch2b
I1103 16:15:50.627488  4604 net.cpp:157] Top shape: 1 256 7 7 (12544)
I1103 16:15:50.627493  4604 net.cpp:165] Memory required for data: 120974336
I1103 16:15:50.627503  4604 layer_factory.hpp:77] Creating layer relu_stage3_block1_branch2b
I1103 16:15:50.627513  4604 net.cpp:100] Creating Layer relu_stage3_block1_branch2b
I1103 16:15:50.627521  4604 net.cpp:434] relu_stage3_block1_branch2b <- conv_stage3_block1_branch2b
I1103 16:15:50.627539  4604 net.cpp:395] relu_stage3_block1_branch2b -> conv_stage3_block1_branch2b (in-place)
I1103 16:15:50.627550  4604 net.cpp:150] Setting up relu_stage3_block1_branch2b
I1103 16:15:50.627558  4604 net.cpp:157] Top shape: 1 256 7 7 (12544)
I1103 16:15:50.627564  4604 net.cpp:165] Memory required for data: 121024512
I1103 16:15:50.627570  4604 layer_factory.hpp:77] Creating layer conv_stage3_block1_branch2c
I1103 16:15:50.627585  4604 net.cpp:100] Creating Layer conv_stage3_block1_branch2c
I1103 16:15:50.627593  4604 net.cpp:434] conv_stage3_block1_branch2c <- conv_stage3_block1_branch2b
I1103 16:15:50.627604  4604 net.cpp:408] conv_stage3_block1_branch2c -> conv_stage3_block1_branch2c
I1103 16:15:50.630198  4604 net.cpp:150] Setting up conv_stage3_block1_branch2c
I1103 16:15:50.630218  4604 net.cpp:157] Top shape: 1 1024 7 7 (50176)
I1103 16:15:50.630224  4604 net.cpp:165] Memory required for data: 121225216
I1103 16:15:50.630235  4604 layer_factory.hpp:77] Creating layer bn_stage3_block1_branch2c
I1103 16:15:50.630247  4604 net.cpp:100] Creating Layer bn_stage3_block1_branch2c
I1103 16:15:50.630255  4604 net.cpp:434] bn_stage3_block1_branch2c <- conv_stage3_block1_branch2c
I1103 16:15:50.630264  4604 net.cpp:395] bn_stage3_block1_branch2c -> conv_stage3_block1_branch2c (in-place)
I1103 16:15:50.630286  4604 net.cpp:150] Setting up bn_stage3_block1_branch2c
I1103 16:15:50.630295  4604 net.cpp:157] Top shape: 1 1024 7 7 (50176)
I1103 16:15:50.630301  4604 net.cpp:165] Memory required for data: 121425920
I1103 16:15:50.630313  4604 layer_factory.hpp:77] Creating layer scale_stage3_block1_branch2c
I1103 16:15:50.630323  4604 net.cpp:100] Creating Layer scale_stage3_block1_branch2c
I1103 16:15:50.630331  4604 net.cpp:434] scale_stage3_block1_branch2c <- conv_stage3_block1_branch2c
I1103 16:15:50.630340  4604 net.cpp:395] scale_stage3_block1_branch2c -> conv_stage3_block1_branch2c (in-place)
I1103 16:15:50.630359  4604 layer_factory.hpp:77] Creating layer scale_stage3_block1_branch2c
I1103 16:15:50.630383  4604 net.cpp:150] Setting up scale_stage3_block1_branch2c
I1103 16:15:50.630393  4604 net.cpp:157] Top shape: 1 1024 7 7 (50176)
I1103 16:15:50.630399  4604 net.cpp:165] Memory required for data: 121626624
I1103 16:15:50.630409  4604 layer_factory.hpp:77] Creating layer eltwise_stage3_block1
I1103 16:15:50.630421  4604 net.cpp:100] Creating Layer eltwise_stage3_block1
I1103 16:15:50.630430  4604 net.cpp:434] eltwise_stage3_block1 <- eltwise_stage3_block0_relu_stage3_block0_0_split_1
I1103 16:15:50.630439  4604 net.cpp:434] eltwise_stage3_block1 <- conv_stage3_block1_branch2c
I1103 16:15:50.630446  4604 net.cpp:408] eltwise_stage3_block1 -> eltwise_stage3_block1
I1103 16:15:50.630460  4604 net.cpp:150] Setting up eltwise_stage3_block1
I1103 16:15:50.630468  4604 net.cpp:157] Top shape: 1 1024 7 7 (50176)
I1103 16:15:50.630475  4604 net.cpp:165] Memory required for data: 121827328
I1103 16:15:50.630481  4604 layer_factory.hpp:77] Creating layer relu_stage3_block1
I1103 16:15:50.630488  4604 net.cpp:100] Creating Layer relu_stage3_block1
I1103 16:15:50.630496  4604 net.cpp:434] relu_stage3_block1 <- eltwise_stage3_block1
I1103 16:15:50.630502  4604 net.cpp:395] relu_stage3_block1 -> eltwise_stage3_block1 (in-place)
I1103 16:15:50.630511  4604 net.cpp:150] Setting up relu_stage3_block1
I1103 16:15:50.630519  4604 net.cpp:157] Top shape: 1 1024 7 7 (50176)
I1103 16:15:50.630525  4604 net.cpp:165] Memory required for data: 122028032
I1103 16:15:50.630532  4604 layer_factory.hpp:77] Creating layer eltwise_stage3_block1_relu_stage3_block1_0_split
I1103 16:15:50.630542  4604 net.cpp:100] Creating Layer eltwise_stage3_block1_relu_stage3_block1_0_split
I1103 16:15:50.630548  4604 net.cpp:434] eltwise_stage3_block1_relu_stage3_block1_0_split <- eltwise_stage3_block1
I1103 16:15:50.630558  4604 net.cpp:408] eltwise_stage3_block1_relu_stage3_block1_0_split -> eltwise_stage3_block1_relu_stage3_block1_0_split_0
I1103 16:15:50.630569  4604 net.cpp:408] eltwise_stage3_block1_relu_stage3_block1_0_split -> eltwise_stage3_block1_relu_stage3_block1_0_split_1
I1103 16:15:50.630589  4604 net.cpp:150] Setting up eltwise_stage3_block1_relu_stage3_block1_0_split
I1103 16:15:50.630599  4604 net.cpp:157] Top shape: 1 1024 7 7 (50176)
I1103 16:15:50.630606  4604 net.cpp:157] Top shape: 1 1024 7 7 (50176)
I1103 16:15:50.630612  4604 net.cpp:165] Memory required for data: 122429440
I1103 16:15:50.630619  4604 layer_factory.hpp:77] Creating layer conv_stage3_block2_branch2a
I1103 16:15:50.630635  4604 net.cpp:100] Creating Layer conv_stage3_block2_branch2a
I1103 16:15:50.630642  4604 net.cpp:434] conv_stage3_block2_branch2a <- eltwise_stage3_block1_relu_stage3_block1_0_split_0
I1103 16:15:50.630655  4604 net.cpp:408] conv_stage3_block2_branch2a -> conv_stage3_block2_branch2a
I1103 16:15:50.633221  4604 net.cpp:150] Setting up conv_stage3_block2_branch2a
I1103 16:15:50.633241  4604 net.cpp:157] Top shape: 1 256 7 7 (12544)
I1103 16:15:50.633247  4604 net.cpp:165] Memory required for data: 122479616
I1103 16:15:50.633258  4604 layer_factory.hpp:77] Creating layer bn_stage3_block2_branch2a
I1103 16:15:50.633271  4604 net.cpp:100] Creating Layer bn_stage3_block2_branch2a
I1103 16:15:50.633280  4604 net.cpp:434] bn_stage3_block2_branch2a <- conv_stage3_block2_branch2a
I1103 16:15:50.633288  4604 net.cpp:395] bn_stage3_block2_branch2a -> conv_stage3_block2_branch2a (in-place)
I1103 16:15:50.633311  4604 net.cpp:150] Setting up bn_stage3_block2_branch2a
I1103 16:15:50.633321  4604 net.cpp:157] Top shape: 1 256 7 7 (12544)
I1103 16:15:50.633327  4604 net.cpp:165] Memory required for data: 122529792
I1103 16:15:50.633338  4604 layer_factory.hpp:77] Creating layer scale_stage3_block2_branch2a
I1103 16:15:50.633348  4604 net.cpp:100] Creating Layer scale_stage3_block2_branch2a
I1103 16:15:50.633355  4604 net.cpp:434] scale_stage3_block2_branch2a <- conv_stage3_block2_branch2a
I1103 16:15:50.633363  4604 net.cpp:395] scale_stage3_block2_branch2a -> conv_stage3_block2_branch2a (in-place)
I1103 16:15:50.633378  4604 layer_factory.hpp:77] Creating layer scale_stage3_block2_branch2a
I1103 16:15:50.633401  4604 net.cpp:150] Setting up scale_stage3_block2_branch2a
I1103 16:15:50.633411  4604 net.cpp:157] Top shape: 1 256 7 7 (12544)
I1103 16:15:50.633417  4604 net.cpp:165] Memory required for data: 122579968
I1103 16:15:50.633426  4604 layer_factory.hpp:77] Creating layer relu_stage3_block2_branch2a
I1103 16:15:50.633436  4604 net.cpp:100] Creating Layer relu_stage3_block2_branch2a
I1103 16:15:50.633442  4604 net.cpp:434] relu_stage3_block2_branch2a <- conv_stage3_block2_branch2a
I1103 16:15:50.633450  4604 net.cpp:395] relu_stage3_block2_branch2a -> conv_stage3_block2_branch2a (in-place)
I1103 16:15:50.633460  4604 net.cpp:150] Setting up relu_stage3_block2_branch2a
I1103 16:15:50.633467  4604 net.cpp:157] Top shape: 1 256 7 7 (12544)
I1103 16:15:50.633473  4604 net.cpp:165] Memory required for data: 122630144
I1103 16:15:50.633479  4604 layer_factory.hpp:77] Creating layer conv_stage3_block2_branch2b
I1103 16:15:50.633492  4604 net.cpp:100] Creating Layer conv_stage3_block2_branch2b
I1103 16:15:50.633499  4604 net.cpp:434] conv_stage3_block2_branch2b <- conv_stage3_block2_branch2a
I1103 16:15:50.633512  4604 net.cpp:408] conv_stage3_block2_branch2b -> conv_stage3_block2_branch2b
I1103 16:15:50.638936  4604 net.cpp:150] Setting up conv_stage3_block2_branch2b
I1103 16:15:50.638988  4604 net.cpp:157] Top shape: 1 256 7 7 (12544)
I1103 16:15:50.638993  4604 net.cpp:165] Memory required for data: 122680320
I1103 16:15:50.639009  4604 layer_factory.hpp:77] Creating layer bn_stage3_block2_branch2b
I1103 16:15:50.639027  4604 net.cpp:100] Creating Layer bn_stage3_block2_branch2b
I1103 16:15:50.639037  4604 net.cpp:434] bn_stage3_block2_branch2b <- conv_stage3_block2_branch2b
I1103 16:15:50.639050  4604 net.cpp:395] bn_stage3_block2_branch2b -> conv_stage3_block2_branch2b (in-place)
I1103 16:15:50.639078  4604 net.cpp:150] Setting up bn_stage3_block2_branch2b
I1103 16:15:50.639087  4604 net.cpp:157] Top shape: 1 256 7 7 (12544)
I1103 16:15:50.639108  4604 net.cpp:165] Memory required for data: 122730496
I1103 16:15:50.639120  4604 layer_factory.hpp:77] Creating layer scale_stage3_block2_branch2b
I1103 16:15:50.639133  4604 net.cpp:100] Creating Layer scale_stage3_block2_branch2b
I1103 16:15:50.639139  4604 net.cpp:434] scale_stage3_block2_branch2b <- conv_stage3_block2_branch2b
I1103 16:15:50.639148  4604 net.cpp:395] scale_stage3_block2_branch2b -> conv_stage3_block2_branch2b (in-place)
I1103 16:15:50.639169  4604 layer_factory.hpp:77] Creating layer scale_stage3_block2_branch2b
I1103 16:15:50.639194  4604 net.cpp:150] Setting up scale_stage3_block2_branch2b
I1103 16:15:50.639204  4604 net.cpp:157] Top shape: 1 256 7 7 (12544)
I1103 16:15:50.639209  4604 net.cpp:165] Memory required for data: 122780672
I1103 16:15:50.639219  4604 layer_factory.hpp:77] Creating layer relu_stage3_block2_branch2b
I1103 16:15:50.639230  4604 net.cpp:100] Creating Layer relu_stage3_block2_branch2b
I1103 16:15:50.639236  4604 net.cpp:434] relu_stage3_block2_branch2b <- conv_stage3_block2_branch2b
I1103 16:15:50.639243  4604 net.cpp:395] relu_stage3_block2_branch2b -> conv_stage3_block2_branch2b (in-place)
I1103 16:15:50.639253  4604 net.cpp:150] Setting up relu_stage3_block2_branch2b
I1103 16:15:50.639261  4604 net.cpp:157] Top shape: 1 256 7 7 (12544)
I1103 16:15:50.639267  4604 net.cpp:165] Memory required for data: 122830848
I1103 16:15:50.639273  4604 layer_factory.hpp:77] Creating layer conv_stage3_block2_branch2c
I1103 16:15:50.639299  4604 net.cpp:100] Creating Layer conv_stage3_block2_branch2c
I1103 16:15:50.639307  4604 net.cpp:434] conv_stage3_block2_branch2c <- conv_stage3_block2_branch2b
I1103 16:15:50.639318  4604 net.cpp:408] conv_stage3_block2_branch2c -> conv_stage3_block2_branch2c
I1103 16:15:50.641909  4604 net.cpp:150] Setting up conv_stage3_block2_branch2c
I1103 16:15:50.641929  4604 net.cpp:157] Top shape: 1 1024 7 7 (50176)
I1103 16:15:50.641935  4604 net.cpp:165] Memory required for data: 123031552
I1103 16:15:50.641945  4604 layer_factory.hpp:77] Creating layer bn_stage3_block2_branch2c
I1103 16:15:50.641957  4604 net.cpp:100] Creating Layer bn_stage3_block2_branch2c
I1103 16:15:50.641964  4604 net.cpp:434] bn_stage3_block2_branch2c <- conv_stage3_block2_branch2c
I1103 16:15:50.641973  4604 net.cpp:395] bn_stage3_block2_branch2c -> conv_stage3_block2_branch2c (in-place)
I1103 16:15:50.641996  4604 net.cpp:150] Setting up bn_stage3_block2_branch2c
I1103 16:15:50.642005  4604 net.cpp:157] Top shape: 1 1024 7 7 (50176)
I1103 16:15:50.642011  4604 net.cpp:165] Memory required for data: 123232256
I1103 16:15:50.642035  4604 layer_factory.hpp:77] Creating layer scale_stage3_block2_branch2c
I1103 16:15:50.642045  4604 net.cpp:100] Creating Layer scale_stage3_block2_branch2c
I1103 16:15:50.642052  4604 net.cpp:434] scale_stage3_block2_branch2c <- conv_stage3_block2_branch2c
I1103 16:15:50.642063  4604 net.cpp:395] scale_stage3_block2_branch2c -> conv_stage3_block2_branch2c (in-place)
I1103 16:15:50.642086  4604 layer_factory.hpp:77] Creating layer scale_stage3_block2_branch2c
I1103 16:15:50.642108  4604 net.cpp:150] Setting up scale_stage3_block2_branch2c
I1103 16:15:50.642118  4604 net.cpp:157] Top shape: 1 1024 7 7 (50176)
I1103 16:15:50.642124  4604 net.cpp:165] Memory required for data: 123432960
I1103 16:15:50.642134  4604 layer_factory.hpp:77] Creating layer eltwise_stage3_block2
I1103 16:15:50.642144  4604 net.cpp:100] Creating Layer eltwise_stage3_block2
I1103 16:15:50.642153  4604 net.cpp:434] eltwise_stage3_block2 <- eltwise_stage3_block1_relu_stage3_block1_0_split_1
I1103 16:15:50.642161  4604 net.cpp:434] eltwise_stage3_block2 <- conv_stage3_block2_branch2c
I1103 16:15:50.642169  4604 net.cpp:408] eltwise_stage3_block2 -> eltwise_stage3_block2
I1103 16:15:50.642181  4604 net.cpp:150] Setting up eltwise_stage3_block2
I1103 16:15:50.642190  4604 net.cpp:157] Top shape: 1 1024 7 7 (50176)
I1103 16:15:50.642196  4604 net.cpp:165] Memory required for data: 123633664
I1103 16:15:50.642202  4604 layer_factory.hpp:77] Creating layer relu_stage3_block2
I1103 16:15:50.642218  4604 net.cpp:100] Creating Layer relu_stage3_block2
I1103 16:15:50.642225  4604 net.cpp:434] relu_stage3_block2 <- eltwise_stage3_block2
I1103 16:15:50.642233  4604 net.cpp:395] relu_stage3_block2 -> eltwise_stage3_block2 (in-place)
I1103 16:15:50.642242  4604 net.cpp:150] Setting up relu_stage3_block2
I1103 16:15:50.642251  4604 net.cpp:157] Top shape: 1 1024 7 7 (50176)
I1103 16:15:50.642256  4604 net.cpp:165] Memory required for data: 123834368
I1103 16:15:50.642262  4604 layer_factory.hpp:77] Creating layer pool
I1103 16:15:50.642276  4604 net.cpp:100] Creating Layer pool
I1103 16:15:50.642282  4604 net.cpp:434] pool <- eltwise_stage3_block2
I1103 16:15:50.642290  4604 net.cpp:408] pool -> pool
I1103 16:15:50.642304  4604 net.cpp:150] Setting up pool
I1103 16:15:50.642318  4604 net.cpp:157] Top shape: 1 1024 1 1 (1024)
I1103 16:15:50.642323  4604 net.cpp:165] Memory required for data: 123838464
I1103 16:15:50.642329  4604 layer_factory.hpp:77] Creating layer fc_nsfw
I1103 16:15:50.642345  4604 net.cpp:100] Creating Layer fc_nsfw
I1103 16:15:50.642352  4604 net.cpp:434] fc_nsfw <- pool
I1103 16:15:50.642361  4604 net.cpp:408] fc_nsfw -> fc_nsfw
I1103 16:15:50.642405  4604 net.cpp:150] Setting up fc_nsfw
I1103 16:15:50.642415  4604 net.cpp:157] Top shape: 1 2 (2)
I1103 16:15:50.642421  4604 net.cpp:165] Memory required for data: 123838472
I1103 16:15:50.642431  4604 layer_factory.hpp:77] Creating layer prob
I1103 16:15:50.642441  4604 net.cpp:100] Creating Layer prob
I1103 16:15:50.642447  4604 net.cpp:434] prob <- fc_nsfw
I1103 16:15:50.642455  4604 net.cpp:408] prob -> prob
I1103 16:15:50.642470  4604 net.cpp:150] Setting up prob
I1103 16:15:50.642479  4604 net.cpp:157] Top shape: 1 2 (2)
I1103 16:15:50.642485  4604 net.cpp:165] Memory required for data: 123838480
I1103 16:15:50.642491  4604 net.cpp:228] prob does not need backward computation.
I1103 16:15:50.642498  4604 net.cpp:228] fc_nsfw does not need backward computation.
I1103 16:15:50.642503  4604 net.cpp:228] pool does not need backward computation.
I1103 16:15:50.642509  4604 net.cpp:228] relu_stage3_block2 does not need backward computation.
I1103 16:15:50.642515  4604 net.cpp:228] eltwise_stage3_block2 does not need backward computation.
I1103 16:15:50.642521  4604 net.cpp:228] scale_stage3_block2_branch2c does not need backward computation.
I1103 16:15:50.642526  4604 net.cpp:228] bn_stage3_block2_branch2c does not need backward computation.
I1103 16:15:50.642532  4604 net.cpp:228] conv_stage3_block2_branch2c does not need backward computation.
I1103 16:15:50.642539  4604 net.cpp:228] relu_stage3_block2_branch2b does not need backward computation.
I1103 16:15:50.642544  4604 net.cpp:228] scale_stage3_block2_branch2b does not need backward computation.
I1103 16:15:50.642549  4604 net.cpp:228] bn_stage3_block2_branch2b does not need backward computation.
I1103 16:15:50.642555  4604 net.cpp:228] conv_stage3_block2_branch2b does not need backward computation.
I1103 16:15:50.642561  4604 net.cpp:228] relu_stage3_block2_branch2a does not need backward computation.
I1103 16:15:50.642567  4604 net.cpp:228] scale_stage3_block2_branch2a does not need backward computation.
I1103 16:15:50.642573  4604 net.cpp:228] bn_stage3_block2_branch2a does not need backward computation.
I1103 16:15:50.642580  4604 net.cpp:228] conv_stage3_block2_branch2a does not need backward computation.
I1103 16:15:50.642586  4604 net.cpp:228] eltwise_stage3_block1_relu_stage3_block1_0_split does not need backward computation.
I1103 16:15:50.642593  4604 net.cpp:228] relu_stage3_block1 does not need backward computation.
I1103 16:15:50.642599  4604 net.cpp:228] eltwise_stage3_block1 does not need backward computation.
I1103 16:15:50.642606  4604 net.cpp:228] scale_stage3_block1_branch2c does not need backward computation.
I1103 16:15:50.642612  4604 net.cpp:228] bn_stage3_block1_branch2c does not need backward computation.
I1103 16:15:50.642618  4604 net.cpp:228] conv_stage3_block1_branch2c does not need backward computation.
I1103 16:15:50.642626  4604 net.cpp:228] relu_stage3_block1_branch2b does not need backward computation.
I1103 16:15:50.642637  4604 net.cpp:228] scale_stage3_block1_branch2b does not need backward computation.
I1103 16:15:50.642643  4604 net.cpp:228] bn_stage3_block1_branch2b does not need backward computation.
I1103 16:15:50.642649  4604 net.cpp:228] conv_stage3_block1_branch2b does not need backward computation.
I1103 16:15:50.642657  4604 net.cpp:228] relu_stage3_block1_branch2a does not need backward computation.
I1103 16:15:50.642663  4604 net.cpp:228] scale_stage3_block1_branch2a does not need backward computation.
I1103 16:15:50.642668  4604 net.cpp:228] bn_stage3_block1_branch2a does not need backward computation.
I1103 16:15:50.642674  4604 net.cpp:228] conv_stage3_block1_branch2a does not need backward computation.
I1103 16:15:50.642681  4604 net.cpp:228] eltwise_stage3_block0_relu_stage3_block0_0_split does not need backward computation.
I1103 16:15:50.642688  4604 net.cpp:228] relu_stage3_block0 does not need backward computation.
I1103 16:15:50.642694  4604 net.cpp:228] eltwise_stage3_block0 does not need backward computation.
I1103 16:15:50.642704  4604 net.cpp:228] scale_stage3_block0_branch2c does not need backward computation.
I1103 16:15:50.642710  4604 net.cpp:228] bn_stage3_block0_branch2c does not need backward computation.
I1103 16:15:50.642716  4604 net.cpp:228] conv_stage3_block0_branch2c does not need backward computation.
I1103 16:15:50.642724  4604 net.cpp:228] relu_stage3_block0_branch2b does not need backward computation.
I1103 16:15:50.642729  4604 net.cpp:228] scale_stage3_block0_branch2b does not need backward computation.
I1103 16:15:50.642735  4604 net.cpp:228] bn_stage3_block0_branch2b does not need backward computation.
I1103 16:15:50.642741  4604 net.cpp:228] conv_stage3_block0_branch2b does not need backward computation.
I1103 16:15:50.642748  4604 net.cpp:228] relu_stage3_block0_branch2a does not need backward computation.
I1103 16:15:50.642755  4604 net.cpp:228] scale_stage3_block0_branch2a does not need backward computation.
I1103 16:15:50.642760  4604 net.cpp:228] bn_stage3_block0_branch2a does not need backward computation.
I1103 16:15:50.642766  4604 net.cpp:228] conv_stage3_block0_branch2a does not need backward computation.
I1103 16:15:50.642772  4604 net.cpp:228] scale_stage3_block0_proj_shortcut does not need backward computation.
I1103 16:15:50.642779  4604 net.cpp:228] bn_stage3_block0_proj_shortcut does not need backward computation.
I1103 16:15:50.642786  4604 net.cpp:228] conv_stage3_block0_proj_shortcut does not need backward computation.
I1103 16:15:50.642792  4604 net.cpp:228] eltwise_stage2_block5_relu_stage2_block5_0_split does not need backward computation.
I1103 16:15:50.642799  4604 net.cpp:228] relu_stage2_block5 does not need backward computation.
I1103 16:15:50.642805  4604 net.cpp:228] eltwise_stage2_block5 does not need backward computation.
I1103 16:15:50.642812  4604 net.cpp:228] scale_stage2_block5_branch2c does not need backward computation.
I1103 16:15:50.642819  4604 net.cpp:228] bn_stage2_block5_branch2c does not need backward computation.
I1103 16:15:50.642825  4604 net.cpp:228] conv_stage2_block5_branch2c does not need backward computation.
I1103 16:15:50.642832  4604 net.cpp:228] relu_stage2_block5_branch2b does not need backward computation.
I1103 16:15:50.642838  4604 net.cpp:228] scale_stage2_block5_branch2b does not need backward computation.
I1103 16:15:50.642843  4604 net.cpp:228] bn_stage2_block5_branch2b does not need backward computation.
I1103 16:15:50.642850  4604 net.cpp:228] conv_stage2_block5_branch2b does not need backward computation.
I1103 16:15:50.642856  4604 net.cpp:228] relu_stage2_block5_branch2a does not need backward computation.
I1103 16:15:50.642863  4604 net.cpp:228] scale_stage2_block5_branch2a does not need backward computation.
I1103 16:15:50.642868  4604 net.cpp:228] bn_stage2_block5_branch2a does not need backward computation.
I1103 16:15:50.642874  4604 net.cpp:228] conv_stage2_block5_branch2a does not need backward computation.
I1103 16:15:50.642886  4604 net.cpp:228] eltwise_stage2_block4_relu_stage2_block4_0_split does not need backward computation.
I1103 16:15:50.642894  4604 net.cpp:228] relu_stage2_block4 does not need backward computation.
I1103 16:15:50.642899  4604 net.cpp:228] eltwise_stage2_block4 does not need backward computation.
I1103 16:15:50.642906  4604 net.cpp:228] scale_stage2_block4_branch2c does not need backward computation.
I1103 16:15:50.642913  4604 net.cpp:228] bn_stage2_block4_branch2c does not need backward computation.
I1103 16:15:50.642920  4604 net.cpp:228] conv_stage2_block4_branch2c does not need backward computation.
I1103 16:15:50.642925  4604 net.cpp:228] relu_stage2_block4_branch2b does not need backward computation.
I1103 16:15:50.642931  4604 net.cpp:228] scale_stage2_block4_branch2b does not need backward computation.
I1103 16:15:50.642937  4604 net.cpp:228] bn_stage2_block4_branch2b does not need backward computation.
I1103 16:15:50.642945  4604 net.cpp:228] conv_stage2_block4_branch2b does not need backward computation.
I1103 16:15:50.642951  4604 net.cpp:228] relu_stage2_block4_branch2a does not need backward computation.
I1103 16:15:50.642956  4604 net.cpp:228] scale_stage2_block4_branch2a does not need backward computation.
I1103 16:15:50.642962  4604 net.cpp:228] bn_stage2_block4_branch2a does not need backward computation.
I1103 16:15:50.642968  4604 net.cpp:228] conv_stage2_block4_branch2a does not need backward computation.
I1103 16:15:50.642976  4604 net.cpp:228] eltwise_stage2_block3_relu_stage2_block3_0_split does not need backward computation.
I1103 16:15:50.642982  4604 net.cpp:228] relu_stage2_block3 does not need backward computation.
I1103 16:15:50.642988  4604 net.cpp:228] eltwise_stage2_block3 does not need backward computation.
I1103 16:15:50.642995  4604 net.cpp:228] scale_stage2_block3_branch2c does not need backward computation.
I1103 16:15:50.643002  4604 net.cpp:228] bn_stage2_block3_branch2c does not need backward computation.
I1103 16:15:50.643008  4604 net.cpp:228] conv_stage2_block3_branch2c does not need backward computation.
I1103 16:15:50.643015  4604 net.cpp:228] relu_stage2_block3_branch2b does not need backward computation.
I1103 16:15:50.643021  4604 net.cpp:228] scale_stage2_block3_branch2b does not need backward computation.
I1103 16:15:50.643028  4604 net.cpp:228] bn_stage2_block3_branch2b does not need backward computation.
I1103 16:15:50.643033  4604 net.cpp:228] conv_stage2_block3_branch2b does not need backward computation.
I1103 16:15:50.643039  4604 net.cpp:228] relu_stage2_block3_branch2a does not need backward computation.
I1103 16:15:50.643045  4604 net.cpp:228] scale_stage2_block3_branch2a does not need backward computation.
I1103 16:15:50.643051  4604 net.cpp:228] bn_stage2_block3_branch2a does not need backward computation.
I1103 16:15:50.643059  4604 net.cpp:228] conv_stage2_block3_branch2a does not need backward computation.
I1103 16:15:50.643065  4604 net.cpp:228] eltwise_stage2_block2_relu_stage2_block2_0_split does not need backward computation.
I1103 16:15:50.643072  4604 net.cpp:228] relu_stage2_block2 does not need backward computation.
I1103 16:15:50.643079  4604 net.cpp:228] eltwise_stage2_block2 does not need backward computation.
I1103 16:15:50.643085  4604 net.cpp:228] scale_stage2_block2_branch2c does not need backward computation.
I1103 16:15:50.643091  4604 net.cpp:228] bn_stage2_block2_branch2c does not need backward computation.
I1103 16:15:50.643098  4604 net.cpp:228] conv_stage2_block2_branch2c does not need backward computation.
I1103 16:15:50.643105  4604 net.cpp:228] relu_stage2_block2_branch2b does not need backward computation.
I1103 16:15:50.643111  4604 net.cpp:228] scale_stage2_block2_branch2b does not need backward computation.
I1103 16:15:50.643117  4604 net.cpp:228] bn_stage2_block2_branch2b does not need backward computation.
I1103 16:15:50.643123  4604 net.cpp:228] conv_stage2_block2_branch2b does not need backward computation.
I1103 16:15:50.643131  4604 net.cpp:228] relu_stage2_block2_branch2a does not need backward computation.
I1103 16:15:50.643141  4604 net.cpp:228] scale_stage2_block2_branch2a does not need backward computation.
I1103 16:15:50.643147  4604 net.cpp:228] bn_stage2_block2_branch2a does not need backward computation.
I1103 16:15:50.643153  4604 net.cpp:228] conv_stage2_block2_branch2a does not need backward computation.
I1103 16:15:50.643160  4604 net.cpp:228] eltwise_stage2_block1_relu_stage2_block1_0_split does not need backward computation.
I1103 16:15:50.643168  4604 net.cpp:228] relu_stage2_block1 does not need backward computation.
I1103 16:15:50.643174  4604 net.cpp:228] eltwise_stage2_block1 does not need backward computation.
I1103 16:15:50.643182  4604 net.cpp:228] scale_stage2_block1_branch2c does not need backward computation.
I1103 16:15:50.643188  4604 net.cpp:228] bn_stage2_block1_branch2c does not need backward computation.
I1103 16:15:50.643194  4604 net.cpp:228] conv_stage2_block1_branch2c does not need backward computation.
I1103 16:15:50.643201  4604 net.cpp:228] relu_stage2_block1_branch2b does not need backward computation.
I1103 16:15:50.643208  4604 net.cpp:228] scale_stage2_block1_branch2b does not need backward computation.
I1103 16:15:50.643214  4604 net.cpp:228] bn_stage2_block1_branch2b does not need backward computation.
I1103 16:15:50.643221  4604 net.cpp:228] conv_stage2_block1_branch2b does not need backward computation.
I1103 16:15:50.643227  4604 net.cpp:228] relu_stage2_block1_branch2a does not need backward computation.
I1103 16:15:50.643234  4604 net.cpp:228] scale_stage2_block1_branch2a does not need backward computation.
I1103 16:15:50.643240  4604 net.cpp:228] bn_stage2_block1_branch2a does not need backward computation.
I1103 16:15:50.643246  4604 net.cpp:228] conv_stage2_block1_branch2a does not need backward computation.
I1103 16:15:50.643254  4604 net.cpp:228] eltwise_stage2_block0_relu_stage2_block0_0_split does not need backward computation.
I1103 16:15:50.643260  4604 net.cpp:228] relu_stage2_block0 does not need backward computation.
I1103 16:15:50.643266  4604 net.cpp:228] eltwise_stage2_block0 does not need backward computation.
I1103 16:15:50.643275  4604 net.cpp:228] scale_stage2_block0_branch2c does not need backward computation.
I1103 16:15:50.643280  4604 net.cpp:228] bn_stage2_block0_branch2c does not need backward computation.
I1103 16:15:50.643287  4604 net.cpp:228] conv_stage2_block0_branch2c does not need backward computation.
I1103 16:15:50.643293  4604 net.cpp:228] relu_stage2_block0_branch2b does not need backward computation.
I1103 16:15:50.643301  4604 net.cpp:228] scale_stage2_block0_branch2b does not need backward computation.
I1103 16:15:50.643306  4604 net.cpp:228] bn_stage2_block0_branch2b does not need backward computation.
I1103 16:15:50.643312  4604 net.cpp:228] conv_stage2_block0_branch2b does not need backward computation.
I1103 16:15:50.643319  4604 net.cpp:228] relu_stage2_block0_branch2a does not need backward computation.
I1103 16:15:50.643326  4604 net.cpp:228] scale_stage2_block0_branch2a does not need backward computation.
I1103 16:15:50.643332  4604 net.cpp:228] bn_stage2_block0_branch2a does not need backward computation.
I1103 16:15:50.643338  4604 net.cpp:228] conv_stage2_block0_branch2a does not need backward computation.
I1103 16:15:50.643345  4604 net.cpp:228] scale_stage2_block0_proj_shortcut does not need backward computation.
I1103 16:15:50.643352  4604 net.cpp:228] bn_stage2_block0_proj_shortcut does not need backward computation.
I1103 16:15:50.643357  4604 net.cpp:228] conv_stage2_block0_proj_shortcut does not need backward computation.
I1103 16:15:50.643365  4604 net.cpp:228] eltwise_stage1_block3_relu_stage1_block3_0_split does not need backward computation.
I1103 16:15:50.643373  4604 net.cpp:228] relu_stage1_block3 does not need backward computation.
I1103 16:15:50.643378  4604 net.cpp:228] eltwise_stage1_block3 does not need backward computation.
I1103 16:15:50.643385  4604 net.cpp:228] scale_stage1_block3_branch2c does not need backward computation.
I1103 16:15:50.643393  4604 net.cpp:228] bn_stage1_block3_branch2c does not need backward computation.
I1103 16:15:50.643402  4604 net.cpp:228] conv_stage1_block3_branch2c does not need backward computation.
I1103 16:15:50.643409  4604 net.cpp:228] relu_stage1_block3_branch2b does not need backward computation.
I1103 16:15:50.643416  4604 net.cpp:228] scale_stage1_block3_branch2b does not need backward computation.
I1103 16:15:50.643422  4604 net.cpp:228] bn_stage1_block3_branch2b does not need backward computation.
I1103 16:15:50.643429  4604 net.cpp:228] conv_stage1_block3_branch2b does not need backward computation.
I1103 16:15:50.643435  4604 net.cpp:228] relu_stage1_block3_branch2a does not need backward computation.
I1103 16:15:50.643441  4604 net.cpp:228] scale_stage1_block3_branch2a does not need backward computation.
I1103 16:15:50.643448  4604 net.cpp:228] bn_stage1_block3_branch2a does not need backward computation.
I1103 16:15:50.643455  4604 net.cpp:228] conv_stage1_block3_branch2a does not need backward computation.
I1103 16:15:50.643461  4604 net.cpp:228] eltwise_stage1_block2_relu_stage1_block2_0_split does not need backward computation.
I1103 16:15:50.643468  4604 net.cpp:228] relu_stage1_block2 does not need backward computation.
I1103 16:15:50.643474  4604 net.cpp:228] eltwise_stage1_block2 does not need backward computation.
I1103 16:15:50.643481  4604 net.cpp:228] scale_stage1_block2_branch2c does not need backward computation.
I1103 16:15:50.643488  4604 net.cpp:228] bn_stage1_block2_branch2c does not need backward computation.
I1103 16:15:50.643494  4604 net.cpp:228] conv_stage1_block2_branch2c does not need backward computation.
I1103 16:15:50.643501  4604 net.cpp:228] relu_stage1_block2_branch2b does not need backward computation.
I1103 16:15:50.643507  4604 net.cpp:228] scale_stage1_block2_branch2b does not need backward computation.
I1103 16:15:50.643513  4604 net.cpp:228] bn_stage1_block2_branch2b does not need backward computation.
I1103 16:15:50.643520  4604 net.cpp:228] conv_stage1_block2_branch2b does not need backward computation.
I1103 16:15:50.643527  4604 net.cpp:228] relu_stage1_block2_branch2a does not need backward computation.
I1103 16:15:50.643533  4604 net.cpp:228] scale_stage1_block2_branch2a does not need backward computation.
I1103 16:15:50.643539  4604 net.cpp:228] bn_stage1_block2_branch2a does not need backward computation.
I1103 16:15:50.643545  4604 net.cpp:228] conv_stage1_block2_branch2a does not need backward computation.
I1103 16:15:50.643553  4604 net.cpp:228] eltwise_stage1_block1_relu_stage1_block1_0_split does not need backward computation.
I1103 16:15:50.643559  4604 net.cpp:228] relu_stage1_block1 does not need backward computation.
I1103 16:15:50.643565  4604 net.cpp:228] eltwise_stage1_block1 does not need backward computation.
I1103 16:15:50.643573  4604 net.cpp:228] scale_stage1_block1_branch2c does not need backward computation.
I1103 16:15:50.643580  4604 net.cpp:228] bn_stage1_block1_branch2c does not need backward computation.
I1103 16:15:50.643586  4604 net.cpp:228] conv_stage1_block1_branch2c does not need backward computation.
I1103 16:15:50.643594  4604 net.cpp:228] relu_stage1_block1_branch2b does not need backward computation.
I1103 16:15:50.643599  4604 net.cpp:228] scale_stage1_block1_branch2b does not need backward computation.
I1103 16:15:50.643605  4604 net.cpp:228] bn_stage1_block1_branch2b does not need backward computation.
I1103 16:15:50.643612  4604 net.cpp:228] conv_stage1_block1_branch2b does not need backward computation.
I1103 16:15:50.643618  4604 net.cpp:228] relu_stage1_block1_branch2a does not need backward computation.
I1103 16:15:50.643625  4604 net.cpp:228] scale_stage1_block1_branch2a does not need backward computation.
I1103 16:15:50.643630  4604 net.cpp:228] bn_stage1_block1_branch2a does not need backward computation.
I1103 16:15:50.643636  4604 net.cpp:228] conv_stage1_block1_branch2a does not need backward computation.
I1103 16:15:50.643645  4604 net.cpp:228] eltwise_stage1_block0_relu_stage1_block0_0_split does not need backward computation.
I1103 16:15:50.643651  4604 net.cpp:228] relu_stage1_block0 does not need backward computation.
I1103 16:15:50.643661  4604 net.cpp:228] eltwise_stage1_block0 does not need backward computation.
I1103 16:15:50.643669  4604 net.cpp:228] scale_stage1_block0_branch2c does not need backward computation.
I1103 16:15:50.643676  4604 net.cpp:228] bn_stage1_block0_branch2c does not need backward computation.
I1103 16:15:50.643682  4604 net.cpp:228] conv_stage1_block0_branch2c does not need backward computation.
I1103 16:15:50.643689  4604 net.cpp:228] relu_stage1_block0_branch2b does not need backward computation.
I1103 16:15:50.643695  4604 net.cpp:228] scale_stage1_block0_branch2b does not need backward computation.
I1103 16:15:50.643702  4604 net.cpp:228] bn_stage1_block0_branch2b does not need backward computation.
I1103 16:15:50.643708  4604 net.cpp:228] conv_stage1_block0_branch2b does not need backward computation.
I1103 16:15:50.643715  4604 net.cpp:228] relu_stage1_block0_branch2a does not need backward computation.
I1103 16:15:50.643721  4604 net.cpp:228] scale_stage1_block0_branch2a does not need backward computation.
I1103 16:15:50.643728  4604 net.cpp:228] bn_stage1_block0_branch2a does not need backward computation.
I1103 16:15:50.643734  4604 net.cpp:228] conv_stage1_block0_branch2a does not need backward computation.
I1103 16:15:50.643741  4604 net.cpp:228] scale_stage1_block0_proj_shortcut does not need backward computation.
I1103 16:15:50.643748  4604 net.cpp:228] bn_stage1_block0_proj_shortcut does not need backward computation.
I1103 16:15:50.643754  4604 net.cpp:228] conv_stage1_block0_proj_shortcut does not need backward computation.
I1103 16:15:50.643761  4604 net.cpp:228] eltwise_stage0_block2_relu_stage0_block2_0_split does not need backward computation.
I1103 16:15:50.643769  4604 net.cpp:228] relu_stage0_block2 does not need backward computation.
I1103 16:15:50.643774  4604 net.cpp:228] eltwise_stage0_block2 does not need backward computation.
I1103 16:15:50.643782  4604 net.cpp:228] scale_stage0_block2_branch2c does not need backward computation.
I1103 16:15:50.643788  4604 net.cpp:228] bn_stage0_block2_branch2c does not need backward computation.
I1103 16:15:50.643795  4604 net.cpp:228] conv_stage0_block2_branch2c does not need backward computation.
I1103 16:15:50.643801  4604 net.cpp:228] relu_stage0_block2_branch2b does not need backward computation.
I1103 16:15:50.643807  4604 net.cpp:228] scale_stage0_block2_branch2b does not need backward computation.
I1103 16:15:50.643815  4604 net.cpp:228] bn_stage0_block2_branch2b does not need backward computation.
I1103 16:15:50.643821  4604 net.cpp:228] conv_stage0_block2_branch2b does not need backward computation.
I1103 16:15:50.643826  4604 net.cpp:228] relu_stage0_block2_branch2a does not need backward computation.
I1103 16:15:50.643832  4604 net.cpp:228] scale_stage0_block2_branch2a does not need backward computation.
I1103 16:15:50.643838  4604 net.cpp:228] bn_stage0_block2_branch2a does not need backward computation.
I1103 16:15:50.643846  4604 net.cpp:228] conv_stage0_block2_branch2a does not need backward computation.
I1103 16:15:50.643852  4604 net.cpp:228] eltwise_stage0_block1_relu_stage0_block1_0_split does not need backward computation.
I1103 16:15:50.643859  4604 net.cpp:228] relu_stage0_block1 does not need backward computation.
I1103 16:15:50.643865  4604 net.cpp:228] eltwise_stage0_block1 does not need backward computation.
I1103 16:15:50.643873  4604 net.cpp:228] scale_stage0_block1_branch2c does not need backward computation.
I1103 16:15:50.643879  4604 net.cpp:228] bn_stage0_block1_branch2c does not need backward computation.
I1103 16:15:50.643885  4604 net.cpp:228] conv_stage0_block1_branch2c does not need backward computation.
I1103 16:15:50.643893  4604 net.cpp:228] relu_stage0_block1_branch2b does not need backward computation.
I1103 16:15:50.643899  4604 net.cpp:228] scale_stage0_block1_branch2b does not need backward computation.
I1103 16:15:50.643905  4604 net.cpp:228] bn_stage0_block1_branch2b does not need backward computation.
I1103 16:15:50.643913  4604 net.cpp:228] conv_stage0_block1_branch2b does not need backward computation.
I1103 16:15:50.643923  4604 net.cpp:228] relu_stage0_block1_branch2a does not need backward computation.
I1103 16:15:50.643929  4604 net.cpp:228] scale_stage0_block1_branch2a does not need backward computation.
I1103 16:15:50.643935  4604 net.cpp:228] bn_stage0_block1_branch2a does not need backward computation.
I1103 16:15:50.643942  4604 net.cpp:228] conv_stage0_block1_branch2a does not need backward computation.
I1103 16:15:50.643949  4604 net.cpp:228] eltwise_stage0_block0_relu_stage0_block0_0_split does not need backward computation.
I1103 16:15:50.643956  4604 net.cpp:228] relu_stage0_block0 does not need backward computation.
I1103 16:15:50.643962  4604 net.cpp:228] eltwise_stage0_block0 does not need backward computation.
I1103 16:15:50.643970  4604 net.cpp:228] scale_stage0_block0_branch2c does not need backward computation.
I1103 16:15:50.643976  4604 net.cpp:228] bn_stage0_block0_branch2c does not need backward computation.
I1103 16:15:50.643982  4604 net.cpp:228] conv_stage0_block0_branch2c does not need backward computation.
I1103 16:15:50.643990  4604 net.cpp:228] relu_stage0_block0_branch2b does not need backward computation.
I1103 16:15:50.643996  4604 net.cpp:228] scale_stage0_block0_branch2b does not need backward computation.
I1103 16:15:50.644002  4604 net.cpp:228] bn_stage0_block0_branch2b does not need backward computation.
I1103 16:15:50.644008  4604 net.cpp:228] conv_stage0_block0_branch2b does not need backward computation.
I1103 16:15:50.644016  4604 net.cpp:228] relu_stage0_block0_branch2a does not need backward computation.
I1103 16:15:50.644021  4604 net.cpp:228] scale_stage0_block0_branch2a does not need backward computation.
I1103 16:15:50.644027  4604 net.cpp:228] bn_stage0_block0_branch2a does not need backward computation.
I1103 16:15:50.644033  4604 net.cpp:228] conv_stage0_block0_branch2a does not need backward computation.
I1103 16:15:50.644040  4604 net.cpp:228] scale_stage0_block0_proj_shortcut does not need backward computation.
I1103 16:15:50.644047  4604 net.cpp:228] bn_stage0_block0_proj_shortcut does not need backward computation.
I1103 16:15:50.644053  4604 net.cpp:228] conv_stage0_block0_proj_shortcut does not need backward computation.
I1103 16:15:50.644062  4604 net.cpp:228] pool1_pool1_0_split does not need backward computation.
I1103 16:15:50.644069  4604 net.cpp:228] pool1 does not need backward computation.
I1103 16:15:50.644078  4604 net.cpp:228] relu_1 does not need backward computation.
I1103 16:15:50.644083  4604 net.cpp:228] scale_1 does not need backward computation.
I1103 16:15:50.644089  4604 net.cpp:228] bn_1 does not need backward computation.
I1103 16:15:50.644095  4604 net.cpp:228] conv_1 does not need backward computation.
I1103 16:15:50.644103  4604 net.cpp:228] data does not need backward computation.
I1103 16:15:50.644107  4604 net.cpp:270] This network produces output prob
I1103 16:15:50.644248  4604 net.cpp:283] Network initialization done.
I1103 16:15:50.711375  4604 upgrade_proto.cpp:77] Attempting to upgrade batch norm layers using deprecated params: nsfw_model/resnet_50_1by2_nsfw.caffemodel
I1103 16:15:50.711498  4604 upgrade_proto.cpp:80] Successfully upgraded batch norm layers using deprecated params.

About the input size of the Image

This is a very stupid question.

I saw you resize the image to 256*256 in python script

but in line 6 of deploy.prototxt, input_param { shape: { dim: 1 dim: 3 dim: 224 dim: 224 } },
which means the input images should be 3 channels with size 224*224

so, what's the exactly right input size of the image?? 256 or 224??
Or I just misunderstood the python script and caffe structure??

fine-tune this model in tensorflow with 'nan' problem

I've converted this model to tensorflow framework, and lauch the graph with .npy data file, the data file upload without any problem since I printed all value in tf.all_variables() for debug . But I found it cann't backprop properly,the trainable variables became nan at the first bp process. I'm not very skillful at CNN tricks since my physics background. Do I need adjust some special layers of this net? and what's the proper
method of optimization?
Thanks for any insightful and helpful analysis and advice!

python can't open classify_nsfw.py

Hi.
Below is my docker setup with snippet Please find highlighted section in below screenshots !
1

and my script snippets

2

and below is my folder structure

3

Since classify_nsfw.py file exists in required directory !
Could you please provide pointers on same !

ImportError: No module named google.protobuf.internal

run 'sudo docker run --volume=$(pwd):/workspace caffe:cpu python classify_nsfw.py --model_def nsfw_model/deploy.prototxt --pretrained_model nsfw_model/resnet_50_1by2_nsfw.caffemodel 1.png
'
and it returns me:
libdc1394 error: Failed to initialize libdc1394
/usr/local/lib/python2.7/dist-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
Traceback (most recent call last):
File "classify_nsfw.py", line 16, in
import caffe
File "/opt/caffe/python/caffe/init.py", line 1, in
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver
File "/opt/caffe/python/caffe/pycaffe.py", line 15, in
import caffe.io
File "/opt/caffe/python/caffe/io.py", line 8, in
from caffe.proto import caffe_pb2
File "/opt/caffe/python/caffe/proto/caffe_pb2.py", line 4, in
from google.protobuf.internal import enum_type_wrapper
ImportError: No module named google.protobuf.internal

OpenNSFW with Docker

I would like to share how to run NSFT with docker

  1. Build a caffe docker image (GPU)
$ cd open_nsfw
$ wget https://raw.githubusercontent.com/BVLC/caffe/master/docker/standalone/gpu/Dockerfile
$ docker build -t caffe:cpu ./

To build for cpu only get the Dockerfile for cpu from Caffe repo

$ wget https://raw.githubusercontent.com/BVLC/caffe/master/docker/standalone/cpu/Dockerfile
  1. When the image it's ready, we check caffe installation
$ docker run -ti caffe:cpu caffe --version
caffe version 1.0.0-rc3
  1. We run bash in this folder as mapped volume with the option --volume in order to run the training manually
docker run -ti --volume=$(pwd):/workspace caffe:cpu bash

so we are in the docker caffe image

root@8855e6188183:/workspace#
  1. Run nsfw in the current container volume
root@8855e6188183:/workspace#python ./classify_nsfw.py --model_def nsfw_model/deploy.prototxt --pretrained_model nsfw_model/resnet_50_1by2_nsfw.caffemodel anderson_210.jpg

and we are done

NSFW score:   0.14057905972

python:can't open file './calssify_nsfw.py':[Errno 2]No such file or directory

I use the windows system, based on the docker installed caffe, I switch to the "open_nsfw-master" folder, when I execute the following statement, the error is "python:can't open file './classify_nsfw.py':[Errno 2]No such file or directory",but the file is real in my folder,why?
'docker run --volume=$(pwd):/workspace caffe:cpu python ./classify_nsfw.py --model_def nsfw_model /deploy.prototxt --pretrained_model nsfw_model/resnet_50_1by2_nsfw.caffemodel test.jpg ',

Segmentation fault when running classify_nsfw.py

My machine is Macbook Pro with Mac OS X (High Sierra, 10.13.3). I installed caffe and pycaffe. When I ran the following at command line, I got "Segmentation fault: 11". Python version is 2.7.15.

LD_LIBRARY_PATH=/temp/caffe/distribute/lib python ./classify_nsfw.py --model_def nsfw_model/deploy.prototxt --pretrained_model nsfw_model/resnet_50_1by2_nsfw.caffemodel /temp/image.jpg

Could you help to see what's going wrong? Thanks.

Return NSFW score: 0.0

Hi, Thanks for opensoucing(openmodeling!) this model.
I'm trying to test it for classify images but always, I got NSFW=0. It's seems somethings is wrong with my try.

here you can see trace and it's same for any type of images

Some images marked as nsfw are wrong

Hi guys,
I am using open_nsfw to classify images, but some images like the attachment(a avatar's wall, open_nsfw score:0.993217) is marked as nsfw.
Anyone knows how to solve this? Thank you very much!
1523765279290

Why resize to (256, 256) ?

In deploy.prototxt, the input_param is { shape: { dim: 1 dim: 3 dim: 224 dim: 224 } } but in classify_nsfw.py, images are resized to (256, 256).

'Incompatible number of blobs for layer bn_1' - Help please!

When running nsfw_classify.py as per the example code I get the following error:

Check failed: target_blobs.size() == source_layer.blobs_size() (5 vs. 3) Incompatible number of blobs for layer bn_1
*** Check failure stack trace: ***

Does the deploy.prototxt and weights not line up properly? I've downloaded the files several times (to check it didn't corrupt) - and not modified anything.

Any tips?

System reboot when calling 'caffe_preprocess_and_compute'

My PC gets rebooted automatically.

I notice that caffe model was loaded well, but it crashed at scores = caffe_preprocess_and_compute(image_data, caffe_transformer=caffe_transformer, caffe_net=nsfw_net, output_layers=['prob']).

It still reboots when I switch to caffe.set_mode_cpu().

Is there anything that I can do? Thank you.

Model license not specified

According to the README, the code for evaluating the open_nsfw model is licensed under BSD 2 license. The README does not specify the license of the trained model. Is it considered code and also covered by BSD 2 license?

performances issues

the classify script does take 1 sec. on avg. to classify one picture.

any ideas to tuning performance? moving model + caffe into ram drive?

train_val.prototxt file for fine-tuning

Hello. Thank you for sharing this project. The readme suggests fine-tuning for improved performance, and I'm writing to request direction on how to convert the deploy.prototxt file into a train_val.prototxt file for fine-tuning. Or, more simply, to request a sample train_val.prototxt file.

Thank you.

how to label the fine-tune data

i collect some violent images and normal images, and want to use them for fine-tune to detect violent image.
i label them like this:

label violent images as 1
label normal images as 0

do i label them right ?
or i need to label normal images as -1 ?

No module named skimage.io

I got ImportError error when run "sudo docker run --volume=$(pwd):/workspace caffe:cpu python ./classify_nsfw.py --model_def nsfw_model/deploy.prototxt --pretrained_model nsfw_model/resnet_50_1by2_nsfw.caffemodel test_image.png", the detail message:

sudo docker run --volume=$(pwd):/workspace caffe:cpu python ./classify_nsfw.py --model_def nsfw_model/deploy.prototxt --pretrained_model nsfw_model/resnet_50_1by2_nsfw.caffemodel test_image.png
libdc1394 error: Failed to initialize libdc1394
Traceback (most recent call last):
File "./classify_nsfw.py", line 16, in
import caffe
File "/opt/caffe/python/caffe/init.py", line 1, in
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver
File "/opt/caffe/python/caffe/pycaffe.py", line 15, in
import caffe.io
File "/opt/caffe/python/caffe/io.py", line 2, in
import skimage.io
ImportError: No module named skimage.io

And I tired to import caffe from python console(I have installed caffe separately), the error is different :
python
Python 2.7.12 (default, Jul 1 2016, 15:12:24)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import caffe
Traceback (most recent call last):
File "", line 1, in
File "/home/wills/caffe/python/caffe/init.py", line 1, in
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver
File "/home/wills/caffe/python/caffe/pycaffe.py", line 11, in
import numpy as np
File "/usr/lib/python2.7/dist-packages/numpy/init.py", line 180, in
from . import add_newdocs
File "/usr/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 13, in
from numpy.lib import add_newdoc
File "/usr/lib/python2.7/dist-packages/numpy/lib/init.py", line 8, in
from .type_check import *
File "/usr/lib/python2.7/dist-packages/numpy/lib/type_check.py", line 11, in
import numpy.core.numeric as _nx
File "/usr/lib/python2.7/dist-packages/numpy/core/init.py", line 58, in
from numpy.testing.nosetester import numpy_tester
File "/usr/lib/python2.7/dist-packages/numpy/testing/init.py", line 12, in
from . import decorators as dec
File "/usr/lib/python2.7/dist-packages/numpy/testing/decorators.py", line 21, in
from .utils import SkipTest
File "/usr/lib/python2.7/dist-packages/numpy/testing/utils.py", line 15, in
from tempfile import mkdtemp, mkstemp
File "/usr/lib/python2.7/tempfile.py", line 32, in
import io as io
File "io.py", line 2, in
import skimage.io
File "/usr/lib/python2.7/dist-packages/skimage/init.py", line 171, in
from .util.dtype import *
File "/usr/lib/python2.7/dist-packages/skimage/util/init.py", line 1, in
from .dtype import (img_as_float, img_as_int, img_as_uint, img_as_ubyte,
File "/usr/lib/python2.7/dist-packages/skimage/util/dtype.py", line 8, in
dtype_range = {np.bool
: (False, True),
AttributeError: 'module' object has no attribute 'bool
'

I'm trying "Anaconda Python distribution" recommented by caffe now, but my questions is : does the NFSW really depend on caffe installed separately? Seems it's already included in the docker, and seems some dependencies missed in the docker file?

Build error

I got a build error (using the new URL from #51)

docker build -t caffe:cpu https://raw.githubusercontent.com/BVLC/caffe/master/docker/cpu/Dockerfile

Downloading build context from remote url: https://raw.githubusercontent.com/BVLC/caffe/master/docker/cpu/Dockerfile  1.349kB
Sending build context to Docker daemon  3.072kB
Step 1/12 : FROM ubuntu:16.04
 ---> 0b1edfbffd27
Step 2/12 : LABEL maintainer [email protected]
 ---> Using cache
 ---> d8b42b3a353c
Step 3/12 : RUN apt-get update && apt-get install -y --no-install-recommends         build-essential         cmake         git         wget         libatlas-base-dev         libboost-all-dev         libgflags-dev         libgoogle-glog-dev         libhdf5-serial-dev         libleveldb-dev         liblmdb-dev         libopencv-dev         libprotobuf-dev         libsnappy-dev         protobuf-compiler         python-dev         python-numpy         python-pip         python-setuptools         python-scipy &&     rm -rf /var/lib/apt/lists/*
 ---> Using cache
 ---> 2fb926bad41f
Step 4/12 : ENV CAFFE_ROOT=/opt/caffe
 ---> Using cache
 ---> 7538610c87fa
Step 5/12 : WORKDIR $CAFFE_ROOT
 ---> Using cache
 ---> 46d10669c5cf
Step 6/12 : ENV CLONE_TAG=1.0
 ---> Using cache
 ---> 302ad52eb00c
Step 7/12 : RUN git clone -b ${CLONE_TAG} --depth 1 https://github.com/BVLC/caffe.git . &&     pip install --upgrade pip &&     cd python && for req in $(cat requirements.txt) pydot; do pip install $req; done && cd .. &&     mkdir build && cd build &&     cmake -DCPU_ONLY=1 .. &&     make -j"$(nproc)"
 ---> Running in 4ed26361a7c6
Cloning into '.'...
Note: checking out 'eeebdab16155d34ff8f5f42137da7df4d1c7eab0'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

Collecting pip
  Downloading https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl (1.3MB)
Installing collected packages: pip
  Found existing installation: pip 8.1.1
    Not uninstalling pip at /usr/lib/python2.7/dist-packages, outside environment /usr
Successfully installed pip-10.0.1
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main
The command '/bin/sh -c git clone -b ${CLONE_TAG} --depth 1 https://github.com/BVLC/caffe.git . &&     pip install --upgrade pip &&     cd python && for req in $(cat requirements.txt) pydot; do pip install $req; done && cd .. &&     mkdir build && cd build &&     cmake -DCPU_ONLY=1 .. &&     make -j"$(nproc)"' returned a non-zero code: 1

ImportError: No module named skimage.io

hi, I install docker and Build a caffe docker image sucessfully,
but is run the programm, it report the error.
please help me.

root@iZ25q8sqgi7Z:~/open_nsfw# docker run caffe:cpu caffe --version
libdc1394 error: Failed to initialize libdc1394
caffe version 1.0.0-rc3

root@iZ25q8sqgi7Z:~/open_nsfw# docker run --volume=$(pwd):/workspace caffe:cpu \

python ./classify_nsfw.py
--model_def nsfw_model/deploy.prototxt
--pretrained_model nsfw_model/resnet_50_1by2_nsfw.caffemodel
test_image.jpg
libdc1394 error: Failed to initialize libdc1394
Traceback (most recent call last):
File "./classify_nsfw.py", line 16, in
import caffe
File "/opt/caffe/python/caffe/init.py", line 1, in
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver
File "/opt/caffe/python/caffe/pycaffe.py", line 15, in
import caffe.io
File "/opt/caffe/python/caffe/io.py", line 2, in
import skimage.io
ImportError: No module named skimage.io

Cannot find appropriate database

Hi, I'm working on my final year project which is detecting nsfw content in images and further for videos (if possible). My problem is that i cannot find any dataset for working so if you could please help me out with this problem by giving me access to some amount of your data will really help me in my project . I really need data of about (150-200 gb) to make my algorithm more precise.

allow topless girls model

I would like to know if someone can make a model which does not marks topless girls as nsfw.
#freethenipples kind of thing thanks

Image formats

Besides jpg, what other image formats does it support?

How to label image for fine-tuning the model

I want to fine-tuning the model, then I have 200 images, half are NSFW, half are safe for work. How to label the image .how to label the image ?
Are the NSFW labeled for 1, and safe image labeled -1?
I want to use the digits tool to create lmdb for fine-tuning, Is that ok?
Thanks!

cannot upload docker file

Command:
docker build -t caffe:cpu https://raw.githubusercontent.com/BVLC/caffe/master/docker/standalone/cpu/Dockerfile

Result:
unable to prepare context: unable to download remote context https://raw.githubusercontent.com/BVLC/caffe/master/docker/standalone/cpu/Dockerfile: failed to GET https://raw.githubusercontent.com/BVLC/caffe/master/docker/standalone/cpu/Dockerfile with status 404 Not Found: 404: Not Found

there is a RuntimeError: Pickling of "caffe._caffe.Net" instances is not enabled (http://www.boost.org/libs/python/doc/v2/pickle.html) when I try run open_nsfw in multi-process

when I try run open_nsfw in multi-process , a runtimeError raised:
Traceback (most recent call last):
File "./verify_concurrency.py", line 152, in
main(sys.argv)
File "./verify_concurrency.py", line 149, in main
print res.get()
File "/usr/lib/python2.7/multiprocessing/pool.py", line 567, in get
raise self._value
RuntimeError: Pickling of "caffe._caffe.Net" instances is not enabled (http://www.boost.org/libs/python/doc/v2/pickle.html)

could some expert help check where is wrong as i'm rookie
my command is :
./verify_concurrency.py --model_def ./nsfw_model/deploy.prototxt --pretrained_model ./nsfw_model/resnet_50_1by2_nsfw.caffemodel /home/harold/nsfw/pic/1

below is my script verify_concurrency.py :
#!/usr/bin/env python
"""
Copyright 2016 Yahoo Inc.
Licensed under the terms of the 2 clause BSD license.
Please see LICENSE file in the project root for terms.
"""

import numpy as np
import os
import sys
import argparse
import glob
import time
from PIL import Image
from StringIO import StringIO
import caffe
from multiprocessing import Pool

def resize_image(data, sz=(256, 256)):
"""
Resize image. Please use this resize logic for best results instead of the
caffe, since it was used to generate training dataset
:param str data:
The image data
:param sz tuple:
The resized image dimensions
:returns bytearray:
A byte array with the resized image
"""
img_data = str(data)
im = Image.open(StringIO(img_data))
if im.mode != "RGB":
im = im.convert('RGB')
imr = im.resize(sz, resample=Image.BILINEAR)
fh_im = StringIO()
imr.save(fh_im, format='JPEG')
fh_im.seek(0)
return bytearray(fh_im.read())

def caffe_preprocess_and_compute(file_name, caffe_transformer=None, caffe_net=None,
output_layers=None):
"""
Run a Caffe network on an input image after preprocessing it to prepare
it for Caffe.
:param file name file_name:
PIL image to be input into Caffe.
:param caffe.Net caffe_net:
A Caffe network with which to process pimg afrer preprocessing.
:param list output_layers:
A list of the names of the layers from caffe_net whose outputs are to
to be returned. If this is None, the default outputs for the network
are returned.
:return:
Returns the requested outputs from the Caffe net.
"""
if caffe_net is not None:

    # Grab the default output names if none were requested specifically.
    if output_layers is None:
        output_layers = caffe_net.outputs
    pimg = open(file_name).read()
    start_time = time.time()
    img_data_rs = resize_image(pimg, sz=(256, 256))
    image = caffe.io.load_image(StringIO(img_data_rs))

    H, W, _ = image.shape
    _, _, h, w = caffe_net.blobs['data'].data.shape
    h_off = max((H - h) / 2, 0)
    w_off = max((W - w) / 2, 0)
    crop = image[h_off:h_off + h, w_off:w_off + w, :]
    transformed_image = caffe_transformer.preprocess('data', crop)
    transformed_image.shape = (1,) + transformed_image.shape

    input_name = caffe_net.inputs[0]
    all_outputs = caffe_net.forward_all(blobs=output_layers,
                **{input_name: transformed_image})

    outputs = all_outputs[output_layers[0]][0].astype(float)
    
    return outputs
else:
    return []

end_time = time.time()
print("deal image:%s;start time:%.3f;end time:%.3f;score:%.3f;cost time:%.3f" % (file_name,start_time, end_time , outputs[1] , (end_time - start_time)) )

def main(argv):
pycaffe_dir = os.path.dirname(file)

parser = argparse.ArgumentParser()
# Required arguments: input file.
parser.add_argument(
    "input_dir",
    help="Directory of the input image file"
)

# Optional arguments.
parser.add_argument(
    "--model_def",
    help="Model definition file."
)
parser.add_argument(
    "--pretrained_model",
    help="Trained model weights file."
)

args = parser.parse_args()
# Pre-load caffe model.
nsfw_net = caffe.Net(args.model_def,  # pylint: disable=invalid-name
    args.pretrained_model, caffe.TEST)

# Load transformer
# Note that the parameters are hard-coded for best results
caffe_transformer = caffe.io.Transformer({'data': nsfw_net.blobs['data'].data.shape})
caffe_transformer.set_transpose('data', (2, 0, 1))  # move image channels to outermost
caffe_transformer.set_mean('data', np.array([104, 117, 123]))  # subtract the dataset-mean value in each channel
caffe_transformer.set_raw_scale('data', 255)  # rescale from [0, 1] to [0, 255]
caffe_transformer.set_channel_swap('data', (2, 1, 0))  # swap channels from RGB to BGR

start_time  = time.time()
print("The process starttime: %.3f" % start_time) 
file_list = os.listdir(args.input_dir)
multiprocess_pool = Pool(10)
result = []
for file in file_list:

    # Classify.

    p = args.input_dir + '/' + file
    #print("The image %s deal startat %.3f" % (p, time.time()) )
    result.append(multiprocess_pool.apply_async(caffe_preprocess_and_compute, args=(p, caffe_transformer, nsfw_net, ['prob'] ,)))
    #scores = caffe_preprocess_and_compute(p, caffe_transformer=caffe_transformer, caffe_net=nsfw_net, output_layers=['prob'])

    # Scores is the array containing SFW / NSFW image probabilities
    # scores[1] indicates the NSFW probability
    #print "NSFW score:  " , scores[1]
    
    #print("The image %s got score: %.3f at %.3f" % (p, scores[1] ,time.time()) )

print 'Waiting for all subprocesses done...'
multiprocess_pool.close()
multiprocess_pool.join()
print 'All subprocesses done.'
end_time  = time.time()  
print("The process endtime: %.3f" % end_time) 

print("The process cost time is %.3f for %d images" % ( (end_time - start_time), len(file_list)) )
for res in result:
    print res.get()    

if name == 'main':
main(sys.argv)

Not really an issue but a thank you

Hello, we are running a demo TOMORROW for our institute's open day and we had the issue of too many NSFW pictures in the Twitter live stream. I was looking everywhere for a solution and just in time found this model released today. I am so incredibly thankful to you right now, the model is integrated and seems to work great! Thanks again for making this available TODAY. Hannes

Msra vs Xavier

I've noticed the only difference between the default resnet50_1by2 and your implementation (besides the number of classes) is the change from weight_filler mrsa to xavier, and bias filler from constant to xavier in the InnerProduct layer.

Was there a reason for that change? Maybe the small number of classes? Did it make a big difference?

The python script does not run on Python 3 - Probably an issue related to StringIO and PIL

After changing some lines, it is still not working (however the includes and the syntax seem to be ok):

  File "classify_nsfw.py", line 128, in <module>
    main(sys.argv)
  File "classify_nsfw.py", line 104, in main
    image_data = open(args.input_file).read()
  File "/usr/lib/python3.5/codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

Changed

from StringIO import StringIO

to

from io import StringIO

and

print "NSFW score:  " , scores[1]

to

print("NSFW score:  %f" %  float(scores[1]))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.