Git Product home page Git Product logo

Comments (12)

xcbtrader avatar xcbtrader commented on May 22, 2024 1

What I do is take an image every n frames, see if it is nsfw and if positive I keep it in a directory

from nsfw_model.

bedapudi6788 avatar bedapudi6788 commented on May 22, 2024 1

@xcbtrader Yeah, saving frames to disk and then calling the predict function is very time taking. I will ad a function to process a video directly. I will also add a paramter in that function so that you can select how many frames you want to analyze. eg: n=1 will analyze all frames and n=0.5 will analyze only half of randomly selected frames each second. Would this work for you?

from nsfw_model.

GantMan avatar GantMan commented on May 22, 2024

We have a ticket to do it in JavaScript that might be applied soon. But I'm actually not that great at Python. I imagine if you could grab all the keyframes down to a folder, then run all those images in the folder in a single batch, that would be pretty fast.

from nsfw_model.

jiangyurong609 avatar jiangyurong609 commented on May 22, 2024

@GantMan I think it'd be inaccurate by simply grabbing all keyframes, since keyframes can be defined by producer during transcoding. Therefore, it's possible that we get mislead by producer. On the other hand, given we have so many frames, in case of false positive, we will have a hard time to decide whether it's bad or not. I think we need a model dedicated for video handling

from nsfw_model.

jiangyurong609 avatar jiangyurong609 commented on May 22, 2024

@xcbtrader what if there are false positives?

from nsfw_model.

xcbtrader avatar xcbtrader commented on May 22, 2024

I keep them as well, and then I look at the directory to check what was analyzed.
In the tests I have done, I have found quite a few false positives.

This is the code to decide if is or not nsfw:
` result = detector.predict('temp.jpg')
datos = result['temp.jpg']

		nsfw = False
		
		if float(datos['porn']) > float(datos['drawings']) and float(datos['porn']) > float(datos['hentai']) and float(datos['porn']) > float(datos['neutral']) and float(datos['porn']) > float(datos['sexy']) and float(datos['porn']) > 0.93:
			nsfw = True
		else:
			if float(datos['sexy']) > float(datos['drawings']) and float(datos['sexy']) > float(datos['hentai']) and float(datos['sexy']) > float(datos['neutral']) and float(datos['sexy']) > float(datos['porn']) and float(datos['sexy']) > 0.93:
				nsfw = True
		
		if nsfw:

			name = './' 'nude_' + info_video[0] + '/' + info_video[0] + '_' + str(currentframe) + '.jpg'
			print ('Creating...' + name + ' --- ' + str(float(datos['porn'])) + ';' + str(float(datos['sexy']))+ ';' + str(float(datos['neutral']))) 
			cv2.imwrite(name, frame)
			frames_nude += 1

	currentframe += 1`

from nsfw_model.

jiangyurong609 avatar jiangyurong609 commented on May 22, 2024

@xcbtrader based on your condition, you will have false negatives. Moreover, you will treat hentai as good content for work.

from nsfw_model.

xcbtrader avatar xcbtrader commented on May 22, 2024

Hentai doesn't worry me.
What conditions do you recommend?

from nsfw_model.

xcbtrader avatar xcbtrader commented on May 22, 2024

I do it differently.
I put a variable called n_frames that indicates how many frames it analyzes.
For example:
If n_frames = 10, it reads frame by frame, and every 10 frames it analyzes.
Analyze frame 10, 20, 30, 40 ....

from nsfw_model.

jiangyurong609 avatar jiangyurong609 commented on May 22, 2024

@xcbtrader I think you need to define a model to decide whether the video is nsfw based on discrete frame detection output. Moreover, your fixed frames can be cracked if someone intends.

from nsfw_model.

remusnegrota avatar remusnegrota commented on May 22, 2024

@xcbtrader Yeah, saving frames to disk and then calling the predict function is very time taking. I will ad a function to process a video directly. I will also add a paramter in that function so that you can select how many frames you want to analyze. eg: n=1 will analyze all frames and n=0.5 will analyze only half of randomly selected frames each second. Would this work for you?

Has this been implemented yet? I haven't found any reference to this function.

Right now I'm extracting frames from a video with ffmpeg, and sending them in batch to the predict method. I've found that doing this with up to 5 videos at once really kills the CPU. I'm using a 4 core CPU with 8 gigs of RAM. Any recommendation on the hardware requirements part for such a task for analyzing multiple videos at once

from nsfw_model.

GantMan avatar GantMan commented on May 22, 2024

Nothing in place yet. I'd love to see your solution.
This is something we might come back to as more advancements show up in TFJS

from nsfw_model.

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.