-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfig.py
More file actions
43 lines (34 loc) · 1.54 KB
/
Copy pathconfig.py
File metadata and controls
43 lines (34 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import os
import logging
logger = logging.getLogger(__name__)
class Config:
# Base directory - one level up from config.py
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
LOCAL_FOLDER = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'local_images')
# Make sure the folder exists
os.makedirs(LOCAL_FOLDER, exist_ok=True)
# Storage paths
STORAGE_DIR = os.path.join(BASE_DIR, 'storage')
UPLOAD_FOLDER = os.path.join(STORAGE_DIR, 'uploads')
PROCESSED_FOLDER = os.path.join(STORAGE_DIR, 'processed')
MODEL_FOLDER = os.path.join(STORAGE_DIR, 'models')
# Allowed file extensions
ALLOWED_EXTENSIONS = {'txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif', 'mp4', 'avi', 'mov', 'mkv', 'docx', 'doc'}
MAX_CONTENT_LENGTH = 200 * 1024 * 1024 # 200MB max file size
# Model settings
MODEL_CONFIDENCE_THRESHOLD = 0.4
# Processing settings
MAX_KERNEL_SIZE = 51 # Maximum Gaussian blur kernel size
MIN_KERNEL_SIZE = 15 # Minimum Gaussian blur kernel size
# Create necessary directories
@classmethod
def init_directories(cls):
"""Initialize required directories for the application"""
try:
os.makedirs(cls.UPLOAD_FOLDER, exist_ok=True)
os.makedirs(cls.PROCESSED_FOLDER, exist_ok=True)
os.makedirs(cls.MODEL_FOLDER, exist_ok=True)
logger.info("Application directories initialized")
except Exception as e:
logger.error(f"Error creating directories: {e}")
raise