MogensR commited on
Commit
5695312
·
1 Parent(s): 038f648

Update config/app_config.py

Browse files
Files changed (1) hide show
  1. config/app_config.py +100 -0
config/app_config.py CHANGED
@@ -107,6 +107,60 @@ class ProcessingConfig:
107
  edge_threshold: float = float(os.getenv('EDGE_THRESHOLD', '0.5'))
108
  edge_detect_method: str = os.getenv('EDGE_DETECT_METHOD', 'canny')
109
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  # Output settings
111
  output_dir: str = os.getenv('OUTPUT_DIR', 'outputs')
112
  output_format: str = os.getenv('OUTPUT_FORMAT', 'mp4')
@@ -243,6 +297,52 @@ def _validate_config(self):
243
  if self.edge_detect_method not in valid_edge_methods:
244
  self.edge_detect_method = 'canny'
245
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
246
  # Validate output settings
247
  valid_formats = ['mp4', 'avi', 'mov', 'webm', 'mkv']
248
  if self.output_format not in valid_formats:
 
107
  edge_threshold: float = float(os.getenv('EDGE_THRESHOLD', '0.5'))
108
  edge_detect_method: str = os.getenv('EDGE_DETECT_METHOD', 'canny')
109
 
110
+ # Tracking and temporal consistency attributes (ADDED)
111
+ min_iou_to_accept: float = float(os.getenv('MIN_IOU_TO_ACCEPT', '0.3'))
112
+ max_iou_distance: float = float(os.getenv('MAX_IOU_DISTANCE', '0.7'))
113
+ min_track_length: int = int(os.getenv('MIN_TRACK_LENGTH', '3'))
114
+ track_buffer_size: int = int(os.getenv('TRACK_BUFFER_SIZE', '30'))
115
+ temporal_smoothing: float = float(os.getenv('TEMPORAL_SMOOTHING', '0.7'))
116
+ motion_threshold: float = float(os.getenv('MOTION_THRESHOLD', '0.1'))
117
+
118
+ # Segmentation refinement attributes (ADDED)
119
+ refine_iterations: int = int(os.getenv('REFINE_ITERATIONS', '1'))
120
+ refine_threshold: float = float(os.getenv('REFINE_THRESHOLD', '0.5'))
121
+ use_crf: bool = os.getenv('USE_CRF', 'false').lower() == 'true'
122
+ crf_iterations: int = int(os.getenv('CRF_ITERATIONS', '5'))
123
+ bilateral_sigma_color: float = float(os.getenv('BILATERAL_SIGMA_COLOR', '80.0'))
124
+ bilateral_sigma_space: float = float(os.getenv('BILATERAL_SIGMA_SPACE', '10.0'))
125
+
126
+ # Feathering and blending attributes (ADDED)
127
+ feather_amount: int = int(os.getenv('FEATHER_AMOUNT', '5'))
128
+ blend_mode: str = os.getenv('BLEND_MODE', 'normal')
129
+ alpha_matting: bool = os.getenv('ALPHA_MATTING', 'false').lower() == 'true'
130
+ alpha_threshold: float = float(os.getenv('ALPHA_THRESHOLD', '0.5'))
131
+ composite_mode: str = os.getenv('COMPOSITE_MODE', 'over')
132
+
133
+ # Color correction attributes (ADDED)
134
+ color_correct: bool = os.getenv('COLOR_CORRECT', 'false').lower() == 'true'
135
+ brightness_adjust: float = float(os.getenv('BRIGHTNESS_ADJUST', '1.0'))
136
+ contrast_adjust: float = float(os.getenv('CONTRAST_ADJUST', '1.0'))
137
+ saturation_adjust: float = float(os.getenv('SATURATION_ADJUST', '1.0'))
138
+ hue_shift: float = float(os.getenv('HUE_SHIFT', '0.0'))
139
+
140
+ # Noise reduction attributes (ADDED)
141
+ denoise: bool = os.getenv('DENOISE', 'false').lower() == 'true'
142
+ denoise_strength: float = float(os.getenv('DENOISE_STRENGTH', '10.0'))
143
+ median_filter_size: int = int(os.getenv('MEDIAN_FILTER_SIZE', '0'))
144
+ gaussian_sigma: float = float(os.getenv('GAUSSIAN_SIGMA', '1.0'))
145
+
146
+ # Performance optimization attributes (ADDED)
147
+ use_gpu: bool = os.getenv('USE_GPU', 'true').lower() == 'true'
148
+ gpu_device_id: int = int(os.getenv('GPU_DEVICE_ID', '0'))
149
+ use_fp16: bool = os.getenv('USE_FP16', 'false').lower() == 'true'
150
+ use_tensorrt: bool = os.getenv('USE_TENSORRT', 'false').lower() == 'true'
151
+ use_quantization: bool = os.getenv('USE_QUANTIZATION', 'false').lower() == 'true'
152
+
153
+ # Video codec attributes (ADDED)
154
+ use_nvenc: bool = os.getenv('USE_NVENC', 'false').lower() == 'true'
155
+ prefer_mp4: bool = os.getenv('PREFER_MP4', 'true').lower() == 'true'
156
+ video_codec: str = os.getenv('VIDEO_CODEC', 'mp4v')
157
+ audio_copy: bool = os.getenv('AUDIO_COPY', 'true').lower() == 'true'
158
+ ffmpeg_path: str = os.getenv('FFMPEG_PATH', 'ffmpeg')
159
+
160
+ # Model size constraints (ADDED)
161
+ max_model_size: int = int(os.getenv('MAX_MODEL_SIZE', '0'))
162
+ max_model_size_bytes: int = int(os.getenv('MAX_MODEL_SIZE_BYTES', '0'))
163
+
164
  # Output settings
165
  output_dir: str = os.getenv('OUTPUT_DIR', 'outputs')
166
  output_format: str = os.getenv('OUTPUT_FORMAT', 'mp4')
 
297
  if self.edge_detect_method not in valid_edge_methods:
298
  self.edge_detect_method = 'canny'
299
 
300
+ # Validate tracking and temporal consistency (ADDED)
301
+ self.min_iou_to_accept = max(0.0, min(1.0, self.min_iou_to_accept))
302
+ self.max_iou_distance = max(0.0, min(1.0, self.max_iou_distance))
303
+ self.min_track_length = max(1, min(100, self.min_track_length))
304
+ self.track_buffer_size = max(1, min(300, self.track_buffer_size))
305
+ self.temporal_smoothing = max(0.0, min(1.0, self.temporal_smoothing))
306
+ self.motion_threshold = max(0.0, min(1.0, self.motion_threshold))
307
+
308
+ # Validate segmentation refinement (ADDED)
309
+ self.refine_iterations = max(0, min(10, self.refine_iterations))
310
+ self.refine_threshold = max(0.0, min(1.0, self.refine_threshold))
311
+ self.crf_iterations = max(1, min(20, self.crf_iterations))
312
+ self.bilateral_sigma_color = max(1.0, min(200.0, self.bilateral_sigma_color))
313
+ self.bilateral_sigma_space = max(1.0, min(50.0, self.bilateral_sigma_space))
314
+
315
+ # Validate feathering and blending (ADDED)
316
+ self.feather_amount = max(0, min(50, self.feather_amount))
317
+ valid_blend_modes = ['normal', 'multiply', 'screen', 'overlay', 'soft_light', 'hard_light']
318
+ if self.blend_mode not in valid_blend_modes:
319
+ self.blend_mode = 'normal'
320
+ self.alpha_threshold = max(0.0, min(1.0, self.alpha_threshold))
321
+ valid_composite_modes = ['over', 'under', 'atop', 'xor', 'plus']
322
+ if self.composite_mode not in valid_composite_modes:
323
+ self.composite_mode = 'over'
324
+
325
+ # Validate color correction (ADDED)
326
+ self.brightness_adjust = max(0.0, min(2.0, self.brightness_adjust))
327
+ self.contrast_adjust = max(0.0, min(2.0, self.contrast_adjust))
328
+ self.saturation_adjust = max(0.0, min(2.0, self.saturation_adjust))
329
+ self.hue_shift = max(-180.0, min(180.0, self.hue_shift))
330
+
331
+ # Validate noise reduction (ADDED)
332
+ self.denoise_strength = max(0.0, min(100.0, self.denoise_strength))
333
+ self.median_filter_size = max(0, min(15, self.median_filter_size))
334
+ if self.median_filter_size % 2 == 0 and self.median_filter_size > 0:
335
+ self.median_filter_size += 1 # Must be odd
336
+ self.gaussian_sigma = max(0.0, min(10.0, self.gaussian_sigma))
337
+
338
+ # Validate performance optimization (ADDED)
339
+ self.gpu_device_id = max(0, self.gpu_device_id)
340
+
341
+ # Validate video codec (ADDED)
342
+ valid_codecs = ['mp4v', 'h264', 'h265', 'xvid', 'mjpeg']
343
+ if self.video_codec not in valid_codecs:
344
+ self.video_codec = 'mp4v'
345
+
346
  # Validate output settings
347
  valid_formats = ['mp4', 'avi', 'mov', 'webm', 'mkv']
348
  if self.output_format not in valid_formats: