Update app.py
Browse files
app.py
CHANGED
@@ -17,14 +17,9 @@ client = InferenceClient(token=HF_TOKEN)
|
|
17 |
def home():
|
18 |
return "Welcome to the Image Background Remover!"
|
19 |
|
20 |
-
# Function to generate a black image
|
21 |
-
def generate_black_image(height, width):
|
22 |
-
black_image = Image.new("RGB", (width, height), color="black")
|
23 |
-
return black_image
|
24 |
-
|
25 |
# Simple content moderation function
|
26 |
def is_prompt_explicit(prompt):
|
27 |
-
explicit_keywords = ["sexual", "nudity", "erotic", "explicit", "porn", "pornographic", "xxx", "hentai", "fetish", "sex", "sensual", "nude", "strip", "stripping", "adult", "lewd", "provocative", "obscene", "vulgar", "intimacy", "intimate", "
|
28 |
for keyword in explicit_keywords:
|
29 |
if keyword.lower() in prompt.lower():
|
30 |
return True
|
@@ -70,14 +65,9 @@ def generate_api():
|
|
70 |
try:
|
71 |
# Check for explicit content
|
72 |
if is_prompt_explicit(prompt):
|
73 |
-
#
|
74 |
-
black_image = generate_black_image(height, width)
|
75 |
-
img_byte_arr = BytesIO()
|
76 |
-
black_image.save(img_byte_arr, format='PNG') # Save as PNG
|
77 |
-
img_byte_arr.seek(0) # Reset byte stream
|
78 |
-
|
79 |
return send_file(
|
80 |
-
|
81 |
mimetype='image/png',
|
82 |
as_attachment=False,
|
83 |
download_name='thinkgood.png'
|
|
|
17 |
def home():
|
18 |
return "Welcome to the Image Background Remover!"
|
19 |
|
|
|
|
|
|
|
|
|
|
|
20 |
# Simple content moderation function
|
21 |
def is_prompt_explicit(prompt):
|
22 |
+
explicit_keywords = ["sexual", "nudity", "erotic", "explicit", "porn", "pornographic", "xxx", "hentai", "fetish", "sex", "sensual", "nude", "strip", "stripping", "adult", "lewd", "provocative", "obscene", "vulgar", "intimacy", "intimate", "lust", "arouse", "seductive", "seduction", "kinky", "bdsm", "dominatrix", "bondage", "hardcore", "softcore", "topless", "bottomless", "threesome", "orgy", "incest", "taboo", "masturbation", "genital", "penis", "vagina", "breast", "boob", "nipple", "butt", "anal", "oral", "ejaculation", "climax", "moan", "foreplay", "intercourse", "naked", "exposed", "suicide", "self-harm", "overdose", "poison", "hang", "end life", "kill myself", "noose", "depression", "hopeless", "worthless", "die", "death", "harm myself"] # Add more keywords as needed
|
23 |
for keyword in explicit_keywords:
|
24 |
if keyword.lower() in prompt.lower():
|
25 |
return True
|
|
|
65 |
try:
|
66 |
# Check for explicit content
|
67 |
if is_prompt_explicit(prompt):
|
68 |
+
# Return the pre-defined "thinkgood.png" image
|
|
|
|
|
|
|
|
|
|
|
69 |
return send_file(
|
70 |
+
"thinkgood.png",
|
71 |
mimetype='image/png',
|
72 |
as_attachment=False,
|
73 |
download_name='thinkgood.png'
|