diff --git a/img_api_generate.sh b/img_api_generate.sh index 23fcd79..ba0eff0 100755 --- a/img_api_generate.sh +++ b/img_api_generate.sh @@ -286,12 +286,15 @@ validate_inputs() { # OUTPUT FILENAME GENERATION # ============================================================================ +_GENERATED_TIMESTAMP="" + generate_output_filename() { local suffix="${1:-}" - local timestamp - timestamp=$(date +%Y%m%d_%H%M%S) + if [[ -z "$_GENERATED_TIMESTAMP" ]]; then + _GENERATED_TIMESTAMP=$(date +%Y%m%d_%H%M%S) + fi local seed_part="${SEED:-0}" - local base="img_${MODEL}_${timestamp}_${seed_part}" + local base="img_${MODEL}_${_GENERATED_TIMESTAMP}_${seed_part}" if [[ -n "$suffix" ]]; then echo "${base}_${suffix}.png" @@ -970,6 +973,9 @@ main() { # Validate inputs validate_inputs + # Initialize timestamp for consistent naming across subshells + _GENERATED_TIMESTAMP=$(date +%Y%m%d_%H%M%S) + # Banner print_banner "${PALETTE} Pivoine Image Generator ${SPARKLES}" @@ -1044,7 +1050,12 @@ main() { local base="${OUTPUT_FILE%.*}" upscale_path="${base}_upscaled.${ext}" else - upscale_path="$(generate_output_filename "upscaled")" + # Include faceswap in name if it was performed + if [[ -n "${faceswap_path:-}" && -f "${faceswap_path}" ]]; then + upscale_path="$(generate_output_filename "faceswap_upscaled")" + else + upscale_path="$(generate_output_filename "upscaled")" + fi fi realesrgan_upscale "$final_input" upscale_path || exit 1