Basically wrote the whole thing.
This commit is contained in:
74
config.py
Normal file
74
config.py
Normal file
@@ -0,0 +1,74 @@
|
||||
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. Add as many as you like.
|
||||
IMAGE_DIRS = [
|
||||
"/mnt/secret-items/sd-outputs/Sorted/Images/Portrait",
|
||||
"/mnt/secret-items/sd-outputs/Sorted/Images/Landscape",
|
||||
]
|
||||
|
||||
# Backwards-compatibility: first directory
|
||||
IMAGE_DIR = IMAGE_DIRS[0]
|
||||
|
||||
from typing import Optional
|
||||
|
||||
# SQLite database file that stores selections & metadata
|
||||
DB_PATH = os.path.join(BASE_DIR, "image_selections.db")
|
||||
|
||||
# Default port for the HTTP server
|
||||
PORT = 8000
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 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