DEV Community

Jastria Rahmat
Jastria Rahmat

Posted on • Edited on

How to Disable NSFW Filter in FaceFusion 3.2.0

FaceFusion 3.2.0 — How to Disable NSFW Filter

So, the old method using PROBABILITY_LIMIT doesn't work anymore in FaceFusion 3.2.0 (based on this update 28-04-2025).

But here's a new way that worked for me — no coding skills needed, just follow these steps:


🚧 Steps:

Open this file:

  • Go into the facefusion folder
  • Then open the file facefusion/content_analyser.py like in this github using notepad or any text editor.
  • In pinokio: pinokio/api/facefusion-pinokio.git/facefusion/facefusion/content_analyser.py or just click the View Folder: pinokio view file face fusion

Find this part in the file:

  • Look for the line that starts with:

     def detect_nsfw
    
  • This section is where FaceFusion checks if content is NSFW (Not Safe for Work).

  • You'll see several lines below it that are indented (moved slightly to the right). That's normal.

Find this line:

   keep_indices = numpy.where(nsfw_scores_raw > 0.2)[0]
Enter fullscreen mode Exit fullscreen mode

Change it to:

   keep_indices = numpy.where(nsfw_scores_raw < 0.0)[0]
Enter fullscreen mode Exit fullscreen mode
  • Mind the < Symbol. so, the changes are from > 0.2 to < 0.0.

✅ That's the only change.

⚠️ Important:

  • Don't change the spacing in front of the line.
  • Python uses indentation (spaces at the beginning of lines) to group code.
  • If you break the spacing, the app might crash with a "IndentationError".
  • Make sure you use < 0.0, not just < 0, or it might not work right.

Save and Restart

  • Save the file after editing.
  • Restart FaceFusion if it's already running.

⚠️ Reminder

This disables the NSFW filter — so be responsible with what you use. (I'll be damned, really? I'm too much of a hypocrite for this..)
This is just from trial and error — no guarantee it'll always work.

Top comments (24)

Collapse
 
_trismgiste_fbcda79 profile image
Ἑρμῆς Trismégiste

keep_indices = numpy.where(nsfw_scores_raw < 0.0)[0] ==>>> No works for me, but....

keep_indices = numpy.where(nsfw_scores_raw > 0.0)[0]==>>> Works very well , Thanks from France ;)

Collapse
 
alves_franclim_1e322508fa profile image
Alves Franclim

muito obrigado, e muito sucesso!!!

Collapse
 
ijash profile image
Jastria Rahmat

Agradeço! E para você também!

Collapse
 
mp3pintyo profile image
Zsolt Pinter

solution:
def detect_nsfw(vision_frame : VisionFrame) -> List[Score]:
return [] # Disabled NSFW check

Collapse
 
obb133 profile image
Obb

still have error

Analysing: 100%|================================================================ | 4524/4537 [00:15<00:00, 283.78frame/s, rate=0]
Traceback (most recent call last):
File "D:\AISoftware\pinokio\api\facefusion-pinokio.git.env\lib\site-packages\gradio\queueing.py", line 625, in process_events
response = await route_utils.call_process_api(
File "D:\AISoftware\pinokio\api\facefusion-pinokio.git.env\lib\site-packages\gradio\route_utils.py", line 322, in call_process_api
output = await app.get_blocks().process_api(
File "D:\AISoftware\pinokio\api\facefusion-pinokio.git.env\lib\site-packages\gradio\blocks.py", line 2146, in process_api
result = await self.call_function(
File "D:\AISoftware\pinokio\api\facefusion-pinokio.git.env\lib\site-packages\gradio\blocks.py", line 1664, in call_function
prediction = await anyio.to_thread.run_sync( # type: ignore
File "D:\AISoftware\pinokio\api\facefusion-pinokio.git.env\lib\site-packages\anyio\to_thread.py", line 56, in run_sync
return await get_async_backend().run_sync_in_worker_thread(
File "D:\AISoftware\pinokio\api\facefusion-pinokio.git.env\lib\site-packages\anyio_backends_asyncio.py", line 2470, in run_sync_in_worker_thread
return await future
File "D:\AISoftware\pinokio\api\facefusion-pinokio.git.env\lib\site-packages\anyio_backends_asyncio.py", line 967, in run
result = context.run(func, *args)
File "D:\AISoftware\pinokio\api\facefusion-pinokio.git.env\lib\site-packages\gradio\utils.py", line 884, in wrapper
response = f(*args, **kwargs)
File "D:\AISoftware\pinokio\api\facefusion-pinokio.git\facefusion\facefusion\uis\components\instant_runner.py", line 82, in run
create_and_run_job(step_args)
File "D:\AISoftware\pinokio\api\facefusion-pinokio.git\facefusion\facefusion\uis\components\instant_runner.py", line 97, in create_and_run_job
return job_manager.create_job(job_id) and job_manager.add_step(job_id, step_args) and job_manager.submit_job(job_id) and job_runner.run_job(job_id, process_step)
File "D:\AISoftware\pinokio\api\facefusion-pinokio.git\facefusion\facefusion\jobs\job_runner.py", line 11, in run_job
if run_steps(job_id, process_step) and finalize_steps(job_id):
File "D:\AISoftware\pinokio\api\facefusion-pinokio.git\facefusion\facefusion\jobs\job_runner.py", line 72, in run_steps
if not run_step(job_id, index, step, process_step):
File "D:\AISoftware\pinokio\api\facefusion-pinokio.git\facefusion\facefusion\jobs\job_runner.py", line 58, in run_step
if job_manager.set_step_status(job_id, step_index, 'started') and process_step(job_id, step_index, step_args):
File "D:\AISoftware\pinokio\api\facefusion-pinokio.git\facefusion\facefusion\core.py", line 323, in process_step
error_code = conditional_process()
File "D:\AISoftware\pinokio\api\facefusion-pinokio.git\facefusion\facefusion\core.py", line 340, in conditional_process
return process_video(start_time)
File "D:\AISoftware\pinokio\api\facefusion-pinokio.git\facefusion\facefusion\core.py", line 418, in process_video
if analyse_video(state_manager.get_item('target_path'), trim_frame_start, trim_frame_end):
File "D:\AISoftware\pinokio\api\facefusion-pinokio.git\facefusion\facefusion\content_analyser.py", line 102, in analyse_video
if analyse_frame(vision_frame):
File "D:\AISoftware\pinokio\api\facefusion-pinokio.git\facefusion\facefusion\content_analyser.py", line 77, in analyse_frame

nsfw_scores = detect_nsfw(vision_frame)
File "D:\AISoftware\pinokio\api\facefusion-pinokio.git\facefusion\facefusion\content_analyser.py", line 115, in detect_nsfw

temp_vision_frame = fit_frame(vision_frame, model_size)
File "D:\AISoftware\pinokio\api\facefusion-pinokio.git\facefusion\facefusion\vision.py", line 243, in fit_frame
height, width = vision_frame.shape[:2]
AttributeError: 'NoneType' object has no attribute 'shape'
Image description

Collapse
 
ijash profile image
Jastria Rahmat • Edited

The error occurs before the nsfw detection at temp_vision_frame = fit_frame(vision_frame, model_size). it's not even invoking the keep_indices = numpy.where(nsfw_scores_raw < 0.0)[0] yet.

It's irrelevant to my topic.
you can contact the developer. because, AFAIK, in this 3.2.0, they use new method of nsfw detection that I believe raise this error.

  • Enhance NSFW validation using a YOLO powered detector

full changelogs

you should report the bug to them.

Collapse
 
codefx profile image
codeFX

Load up the content_analyser.py file as above, search for 'def analyse_frame' and edit the one found on line 70 with the following;

def analyse_frame(vision_frame : VisionFrame) -> bool:
return False

Save and reload FF

Collapse
 
frank_702a6743dfd profile image
Frank

It doesn't seem to work, even using 3.2.0.
Not even trying to do NSFW.
Just messing around with family photos and videos right now, and even someone on a rollercoaster can't be swapped.

Collapse
 
kenny_9999995 profile image
Kenny • Edited

You might not be following his instructions properly. Perhaps you could send him a message and ask for personal guidance. Don't forget to buy him a coffee.

anyway, thanks @ijash !

Collapse
 
frank_702a6743dfd profile image
Frank

Don't see how I'm not following the instructions. While I'm not the smartest person in the room, they seem simple enough for someone who was able to install FaceFusion in the first place.
Perhaps I'm wrong, but here are screenshots. (I purposely blurred the faces in the original photo, but you can see that the whole picture is blurred in the preview. This happens even if I put in a new subject for input)

Image description

Image description

Thread Thread
 
nanonick profile image
Nack

You need to change the ">" to a "<" as well; it looks like you forgot to change it.

Thread Thread
 
frank_702a6743dfd profile image
Frank

Fudge...
I feel SUPER stupid right now.
Thanks for that, I DID totally miss that and just looked at the numbers.
Ugh...

Thread Thread
 
ijash profile image
Jastria Rahmat

So... how is it now?

btw, thank you @kenny_9999995 & @nanonick . appreciate it.

Collapse
 
jonathan_adlas_f4c73739cf profile image
Jonathan Adlas

we need a video tuto, iam to stupid for that, everytime when i change the two to a Zero , the complete text disappears

Collapse
 
ijash profile image
Jastria Rahmat

you use windows?

Collapse
 
jonathan_adlas_f4c73739cf profile image
Jonathan Adlas

yes windows 11

Thread Thread
 
ijash profile image
Jastria Rahmat • Edited

Sorry, I use linux. even if i did make it, there'll be some visual difference. but the underlying concept is the same. I'll see what I can do, meanwhile, please wait. Because I'm not too keen in video editing.

Collapse
 
poptarttommy profile image
Tom

Can you just comment out the whole function and return a safe score value? The NSFW analyzing function still runs, which slows the overall process down, why not just avoid it altogether?

Collapse
 
ijash profile image
Jastria Rahmat

i am aware of that. but i'm no python expert, in my best guess, every time this function called, it expect a certain type of value. that's why I don't really avoid it.

may be it can be substituted with empty array.. maybe..

Collapse
 
alpa_patel_d2e9e735efe624 profile image
Alpa Patel

not working

Collapse
 
ijash profile image
Jastria Rahmat

give me your code screenshot.

Collapse
 
ahmed_abdelazeem_42e0fae profile image
ahmed abd elazeem

Is there a way to run it on colab without errors? Thx in advance 🙏

Collapse
 
ijash profile image
Jastria Rahmat

have you tried?