John Doe commited on
Commit
6c83666
·
1 Parent(s): 3ab5798
Files changed (1) hide show
  1. image_moderator.py +3 -3
image_moderator.py CHANGED
@@ -4,7 +4,7 @@ from transformers import CLIPProcessor, CLIPModel, ViTForImageClassification, Vi
4
  from PIL import Image, ImageFilter
5
  import torch
6
  import cv2
7
-
8
  class ImageContentModerator:
9
  def __init__(self, nsfw_threshold=0.85, blur_radius=99):
10
  # NSFW Setup
@@ -66,9 +66,9 @@ class ImageContentModerator:
66
  return output_path
67
  from transformers import pipeline
68
  from better_profanity import profanity
69
-
70
  # Load profanity model
71
- toxic_classifier = pipeline("text-classification", model="unitary/toxic-bert", cache_dir="./")
72
  profanity.load_censor_words()
73
  custom_words = [
74
  "idiot", "moron", "dumb", "stupid", "loser", "bastard", "retard", "scumbag",
 
4
  from PIL import Image, ImageFilter
5
  import torch
6
  import cv2
7
+ import os
8
  class ImageContentModerator:
9
  def __init__(self, nsfw_threshold=0.85, blur_radius=99):
10
  # NSFW Setup
 
66
  return output_path
67
  from transformers import pipeline
68
  from better_profanity import profanity
69
+ os.makedirs("./cache_dir", exist_ok=True)
70
  # Load profanity model
71
+ toxic_classifier = pipeline("text-classification", model="unitary/toxic-bert", cache_dir="./cache_dir")
72
  profanity.load_censor_words()
73
  custom_words = [
74
  "idiot", "moron", "dumb", "stupid", "loser", "bastard", "retard", "scumbag",