Bug fixes.
This commit is contained in:
83
config_custom.py
Normal file
83
config_custom.py
Normal file
@@ -0,0 +1,83 @@
|
||||
import os
|
||||
|
||||
# Configuration constants for the SWIPER application
|
||||
# --------------------------------------------------
|
||||
# Centralising these values avoids circular imports
|
||||
# and makes it easy to update paths / ports later
|
||||
|
||||
# Base directory of the repo (this file lives in the project root)
|
||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
# Paths to the folders that contain source images. Can be overridden at runtime
|
||||
# via the IMAGE_DIRS environment variable (colon-separated paths).
|
||||
_IMAGE_DIRS_DEFAULT = [
|
||||
"/media/Portrait",
|
||||
"/media/Landscape",
|
||||
]
|
||||
|
||||
_IMAGE_DIRS_ENV = os.getenv("IMAGE_DIRS")
|
||||
if _IMAGE_DIRS_ENV:
|
||||
IMAGE_DIRS = _IMAGE_DIRS_ENV.split(":")
|
||||
else:
|
||||
IMAGE_DIRS = _IMAGE_DIRS_DEFAULT
|
||||
|
||||
# Backwards-compatibility: first directory
|
||||
IMAGE_DIR = IMAGE_DIRS[0] if IMAGE_DIRS else ""
|
||||
from typing import Optional
|
||||
|
||||
# Data directory (override with DATA_DIR env var)
|
||||
DATA_DIR = os.getenv("DATA_DIR", BASE_DIR)
|
||||
|
||||
# SQLite database file that stores selections & metadata
|
||||
DB_PATH = os.path.join(DATA_DIR, "image_selections.db")
|
||||
|
||||
# Default port for the HTTP server (override with PORT env var)
|
||||
PORT = int(os.getenv("PORT", 8888))
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# NSFW detection configuration
|
||||
# ---------------------------------------------------------------------------
|
||||
# List of keywords that, if present in an image's prompt data, should mark the
|
||||
# image as NSFW. Feel free to customise this list as appropriate for your own
|
||||
# needs.
|
||||
NSFW_KEYWORDS = [
|
||||
"nude",
|
||||
"nudity",
|
||||
"porn",
|
||||
"explicit",
|
||||
"sexual",
|
||||
"sex",
|
||||
"boobs",
|
||||
"nipples",
|
||||
"penis",
|
||||
"vagina",
|
||||
"pussy",
|
||||
"cum",
|
||||
"fellatio",
|
||||
"blowjob",
|
||||
"cunnilingus",
|
||||
"paizuri",
|
||||
"rape",
|
||||
"handjob",
|
||||
"lingerie",
|
||||
"bikini",
|
||||
"latex",
|
||||
"saliva",
|
||||
"ass",
|
||||
"condom",
|
||||
]
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Utility helpers
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def find_image_file(rel_path: str) -> Optional[str]:
|
||||
"""Return absolute path to `rel_path` by searching all IMAGE_DIRS.
|
||||
|
||||
Returns None if file is not found in any configured directory.
|
||||
"""
|
||||
for base in IMAGE_DIRS:
|
||||
abs_path = os.path.join(base, rel_path)
|
||||
if os.path.exists(abs_path):
|
||||
return abs_path
|
||||
return None
|
||||
Reference in New Issue
Block a user