Code Monkey home page Code Monkey logo

Comments (10)

mdietrichstein avatar mdietrichstein commented on May 24, 2024 2

I know I'm a bit late, but I've managed to convert the model to tensorflow ;) Hope it's useful for the one's having problems with the conversion process.

Check out the code and documentation at tensorflow-open_nsfw if you're interested.

from open_nsfw.

XuefeiW avatar XuefeiW commented on May 24, 2024 1

The Scale layer in Caffe is implemented in Batch Normalization layer in Torch. BN layer in Torch nn library has four parameters: weight, bias, running_mean and running_var, the weight and bias here are the factor and bias in Caffe Scale layer. So you could convert this model to Torch. Probably other platforms as well.

If you plan to convert this from Caffe to Torch, here are two things you might want to know:

In Caffe BN layer, there's a scale factor stored in eg. nsfw_net.params['bn_1'][2].data. You need to divide this factor from all mean and var before you copy these parameters to Torch BN layer.

The pooling layer default setting in Torch is different to Caffe. Mainly about padding, when the padding is not set up, the default value is 0 in both Torch and Caffe, but if the ( inputSize - kernelSize + 2 * padding) / stride is not an integer, in Torch the default setting is floor()(means no padding) while in Caffe it's ceil()(add one side padding each rather than two). A simple way to replicate this layer in Torch is nn.SpatialMaxPooling(kernelSize, kernelSize, stride, stride):ceil()
ref: https://netaz.blogspot.co.uk/2016/08/confused-about-caffes-pooling-layer.html?

Hope this is helpful.

from open_nsfw.

nemosail avatar nemosail commented on May 24, 2024

WoW.......

from open_nsfw.

ProGamerGov avatar ProGamerGov commented on May 24, 2024

Why did they only release the ResNet model and not the Googlenet model?

from open_nsfw.

jarutis avatar jarutis commented on May 24, 2024

It works in TensorFlow converted with this tool.

from open_nsfw.

zzzcpan avatar zzzcpan commented on May 24, 2024

No, the tool cannot convert it, exits with ValueError.

from open_nsfw.

logic1988 avatar logic1988 commented on May 24, 2024

I used pycaffe to run the model successfully. However, used the cv::dnn (DNN module of opencv for loading caffe model) was failed. Is it because of the ResNet structure?

from open_nsfw.

jarutis avatar jarutis commented on May 24, 2024

@zzzcpan install pycaffe first, ValueError is gone afterwards.

from open_nsfw.

ProGamerGov avatar ProGamerGov commented on May 24, 2024

@mdietrichstein Using this Tensorflowcode here: https://github.com/ProGamerGov/Protobuf-Dreamer, I was able to find DeepDream layer and channel combinations which produced hallucinations entirely comprised of specific categories: https://github.com/ProGamerGov/Protobuf-Dreamer/wiki/Interesting-Layers-And-Channels

It would be interesting to use the DeepDream "layer + channel" technique to see what exactly each category of the open_nsfw was. My experience with Tensorflow is very limited, as I mostly use Caffe and Torch7 at the moment.


I have previously experimented using the open_nsfw model and DeepDream without specifying specific channels, and found the results to create vague hallucinations of which the content was difficult to discern:
https://imgur.com/a/NtFyx, https://imgur.com/a/h3Lgn. The DeepDream images were made with this modified prototxt, and this style transfer/DeepDream project: https://github.com/crowsonkb/style_transfer

from open_nsfw.

TechnikEmpire avatar TechnikEmpire commented on May 24, 2024

@logic1988 I'm not sure what version of OpenCV you used but I'm using this model successfully with OpenCV DNN 3.3.1. You can see the use here.

from open_nsfw.

Related Issues (20)

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.