yahoo / open_nsfw

Not Suitable for Work (NSFW) classification using deep neural network Caffe models.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

not preloading model when started from node with child process

lxknvlk opened this issue · comments

commented

The script stops at this line

# Pre-load caffe model.
nsfw_net = caffe.Net(model_def, pretrained_model, caffe.TEST)

Everything else in python works fine. And the script run directly works fine too. Why it is not working when called from child-process?

When i run it from a node app like this

        const cp = require("child_process")
        const spawn = cp.spawn;
	const pythonProcess = spawn('python',['/home/ubuntu/classify.py']);

	pythonProcess.stdin.write(req.body.image, function(err){
		pythonProcess.stdin.end();
	});

	pythonProcess.stdout.on('data', (data) => {
	    	console.log("message from python:" + data)
		});

	pythonProcess.stdout.on("end", (data) => {
		console.log("end received data: " + data);
		res.status(200);
	    res.end(); 
	});
commented

I have added pythonProcess.stderr.pipe(process.stderr); to my nodejs app and then i was able to see errors from python script, and fix it.