add nsfw image censoring

activatable via config, uses CompVis/stable-diffusion-safety-checker
This commit is contained in:
Manuel Schmid
2023-11-15 22:00:45 +01:00
parent 943098f8da
commit 52ae346c9d
3 changed files with 66 additions and 2 deletions
+7 -2
View File
@@ -30,6 +30,7 @@ def worker():
import fooocus_extras.ip_adapter as ip_adapter
import fooocus_extras.face_crop
from modules.censor import censor_batch
from modules.sdxl_styles import apply_style, apply_wildcards, fooocus_expansion
from modules.private_logger import log
from modules.expansion import safe_str
@@ -50,12 +51,16 @@ def worker():
print(f'[Fooocus] {text}')
outputs.append(['preview', (number, text, None)])
def yield_result(imgs, do_not_show_finished_images=False):
def yield_result(imgs, do_not_show_finished_images=False, progressbar_index=13):
global global_results
if not isinstance(imgs, list):
imgs = [imgs]
if modules.config.default_black_out_nsfw:
progressbar(progressbar_index, 'Checking for NSFW content ...')
imgs = censor_batch(imgs)
global_results = global_results + imgs
if do_not_show_finished_images:
@@ -711,7 +716,7 @@ def worker():
d.append((f'LoRA [{n}] weight', w))
log(x, d, single_line_number=3)
yield_result(imgs, do_not_show_finished_images=len(tasks) == 1)
yield_result(imgs, do_not_show_finished_images=len(tasks) == 1, progressbar_index=int(15.0 + 85.0 * float((current_task_id + 1) * steps) / float(all_steps))))
except fcbh.model_management.InterruptProcessingException as e:
if shared.last_stop == 'skip':
print('User skipped')