diff --git a/img_api_generate.sh b/img_api_generate.sh index ba0eff0..87990c2 100755 --- a/img_api_generate.sh +++ b/img_api_generate.sh @@ -40,6 +40,7 @@ DIM='\033[2m' CHECK_MARK="✓" CROSS_MARK="✗" +QUESTION_MARK="?" PALETTE="🎨" SPARKLES="✨" CAMERA="📸" @@ -76,6 +77,7 @@ ASYNC_MODE=false DRY_RUN=false VERBOSE=false UPSCALE=false +INTERACTIVE=false # Temp files for cleanup _TMP_FILES=() @@ -136,6 +138,22 @@ print_verbose() { fi } +prompt_confirm() { + local message="$1" + if [[ "$INTERACTIVE" == false ]]; then + return 0 + fi + + echo -en "${BOLD_YELLOW}${QUESTION_MARK} ${message} [y/N] ${RESET}" + read -n 1 -r + echo "" + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + print_info "Operation cancelled by user." + return 1 + fi + return 0 +} + # ============================================================================ # SPINNER # ============================================================================ @@ -551,6 +569,8 @@ generate_image() { [[ -n "$INPUT_IMAGE" ]] && print_field " " "Input Image" "$INPUT_IMAGE" echo "" + prompt_confirm "Proceed with image generation?" || return 1 + local response if [[ "$ASYNC_MODE" == false ]]; then # Synchronous mode - wait with spinner @@ -687,6 +707,8 @@ download_result() { print_detail "Downloading result..." + prompt_confirm "Download generated image?" || return 1 + api_curl_binary GET "$url" "$_dl_output_path" || return 1 if [[ -f "$_dl_output_path" && -s "$_dl_output_path" ]]; then @@ -730,6 +752,8 @@ swap_face() { print_field "$CAMERA" "Target" "$target_image" echo "" + prompt_confirm "Proceed with face swap?" || return 1 + local options='{"processors":["face_swapper","face_enhancer"],"face_swapper":{"model":"hyperswap_1a_256"},"face_enhancer":{"model":"gfpgan_1.4","blend":80}}' local tmp_resp @@ -786,6 +810,8 @@ realesrgan_upscale() { print_field "$CAMERA" "Input" "$input_image" echo "" + prompt_confirm "Proceed with image upscaling?" || return 1 + local tmp_resp tmp_resp=$(mktemp) _TMP_FILES+=("$tmp_resp") @@ -851,6 +877,7 @@ OUTPUT: MODES: --async Use async mode with polling instead of sync --dry-run Show curl commands without executing + -i, --interactive Prompt before each API call --verbose Verbose output -h, --help Show this help message @@ -921,6 +948,10 @@ parse_args() { ASYNC_MODE=true shift ;; + -i|--interactive) + INTERACTIVE=true + shift + ;; --dry-run) DRY_RUN=true shift @@ -1058,10 +1089,12 @@ main() { fi fi - realesrgan_upscale "$final_input" upscale_path || exit 1 + realesrgan_upscale "$final_input" upscale_path || true - # Use the upscaled image for summary/output - output_path="$upscale_path" + # Use the upscaled image for summary/output if it was created + if [[ -f "${upscale_path:-}" ]]; then + output_path="$upscale_path" + fi fi # Summary