Compare commits
2 Commits
0d31a6fee8
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 83a09d054e | |||
| 4de55a9f41 |
@@ -40,6 +40,7 @@ DIM='\033[2m'
|
|||||||
|
|
||||||
CHECK_MARK="✓"
|
CHECK_MARK="✓"
|
||||||
CROSS_MARK="✗"
|
CROSS_MARK="✗"
|
||||||
|
QUESTION_MARK="?"
|
||||||
PALETTE="🎨"
|
PALETTE="🎨"
|
||||||
SPARKLES="✨"
|
SPARKLES="✨"
|
||||||
CAMERA="📸"
|
CAMERA="📸"
|
||||||
@@ -76,6 +77,7 @@ ASYNC_MODE=false
|
|||||||
DRY_RUN=false
|
DRY_RUN=false
|
||||||
VERBOSE=false
|
VERBOSE=false
|
||||||
UPSCALE=false
|
UPSCALE=false
|
||||||
|
INTERACTIVE=false
|
||||||
|
|
||||||
# Temp files for cleanup
|
# Temp files for cleanup
|
||||||
_TMP_FILES=()
|
_TMP_FILES=()
|
||||||
@@ -136,6 +138,22 @@ print_verbose() {
|
|||||||
fi
|
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
|
# SPINNER
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
@@ -286,12 +304,15 @@ validate_inputs() {
|
|||||||
# OUTPUT FILENAME GENERATION
|
# OUTPUT FILENAME GENERATION
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
|
_GENERATED_TIMESTAMP=""
|
||||||
|
|
||||||
generate_output_filename() {
|
generate_output_filename() {
|
||||||
local suffix="${1:-}"
|
local suffix="${1:-}"
|
||||||
local timestamp
|
if [[ -z "$_GENERATED_TIMESTAMP" ]]; then
|
||||||
timestamp=$(date +%Y%m%d_%H%M%S)
|
_GENERATED_TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
||||||
|
fi
|
||||||
local seed_part="${SEED:-0}"
|
local seed_part="${SEED:-0}"
|
||||||
local base="img_${MODEL}_${timestamp}_${seed_part}"
|
local base="img_${MODEL}_${_GENERATED_TIMESTAMP}_${seed_part}"
|
||||||
|
|
||||||
if [[ -n "$suffix" ]]; then
|
if [[ -n "$suffix" ]]; then
|
||||||
echo "${base}_${suffix}.png"
|
echo "${base}_${suffix}.png"
|
||||||
@@ -548,6 +569,8 @@ generate_image() {
|
|||||||
[[ -n "$INPUT_IMAGE" ]] && print_field " " "Input Image" "$INPUT_IMAGE"
|
[[ -n "$INPUT_IMAGE" ]] && print_field " " "Input Image" "$INPUT_IMAGE"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
prompt_confirm "Proceed with image generation?" || return 1
|
||||||
|
|
||||||
local response
|
local response
|
||||||
if [[ "$ASYNC_MODE" == false ]]; then
|
if [[ "$ASYNC_MODE" == false ]]; then
|
||||||
# Synchronous mode - wait with spinner
|
# Synchronous mode - wait with spinner
|
||||||
@@ -684,6 +707,8 @@ download_result() {
|
|||||||
|
|
||||||
print_detail "Downloading result..."
|
print_detail "Downloading result..."
|
||||||
|
|
||||||
|
prompt_confirm "Download generated image?" || return 1
|
||||||
|
|
||||||
api_curl_binary GET "$url" "$_dl_output_path" || return 1
|
api_curl_binary GET "$url" "$_dl_output_path" || return 1
|
||||||
|
|
||||||
if [[ -f "$_dl_output_path" && -s "$_dl_output_path" ]]; then
|
if [[ -f "$_dl_output_path" && -s "$_dl_output_path" ]]; then
|
||||||
@@ -727,6 +752,8 @@ swap_face() {
|
|||||||
print_field "$CAMERA" "Target" "$target_image"
|
print_field "$CAMERA" "Target" "$target_image"
|
||||||
echo ""
|
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 options='{"processors":["face_swapper","face_enhancer"],"face_swapper":{"model":"hyperswap_1a_256"},"face_enhancer":{"model":"gfpgan_1.4","blend":80}}'
|
||||||
|
|
||||||
local tmp_resp
|
local tmp_resp
|
||||||
@@ -783,6 +810,8 @@ realesrgan_upscale() {
|
|||||||
print_field "$CAMERA" "Input" "$input_image"
|
print_field "$CAMERA" "Input" "$input_image"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
prompt_confirm "Proceed with image upscaling?" || return 1
|
||||||
|
|
||||||
local tmp_resp
|
local tmp_resp
|
||||||
tmp_resp=$(mktemp)
|
tmp_resp=$(mktemp)
|
||||||
_TMP_FILES+=("$tmp_resp")
|
_TMP_FILES+=("$tmp_resp")
|
||||||
@@ -848,6 +877,7 @@ OUTPUT:
|
|||||||
MODES:
|
MODES:
|
||||||
--async Use async mode with polling instead of sync
|
--async Use async mode with polling instead of sync
|
||||||
--dry-run Show curl commands without executing
|
--dry-run Show curl commands without executing
|
||||||
|
-i, --interactive Prompt before each API call
|
||||||
--verbose Verbose output
|
--verbose Verbose output
|
||||||
-h, --help Show this help message
|
-h, --help Show this help message
|
||||||
|
|
||||||
@@ -918,6 +948,10 @@ parse_args() {
|
|||||||
ASYNC_MODE=true
|
ASYNC_MODE=true
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
-i|--interactive)
|
||||||
|
INTERACTIVE=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
--dry-run)
|
--dry-run)
|
||||||
DRY_RUN=true
|
DRY_RUN=true
|
||||||
shift
|
shift
|
||||||
@@ -970,6 +1004,9 @@ main() {
|
|||||||
# Validate inputs
|
# Validate inputs
|
||||||
validate_inputs
|
validate_inputs
|
||||||
|
|
||||||
|
# Initialize timestamp for consistent naming across subshells
|
||||||
|
_GENERATED_TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
||||||
|
|
||||||
# Banner
|
# Banner
|
||||||
print_banner "${PALETTE} Pivoine Image Generator ${SPARKLES}"
|
print_banner "${PALETTE} Pivoine Image Generator ${SPARKLES}"
|
||||||
|
|
||||||
@@ -1044,13 +1081,20 @@ main() {
|
|||||||
local base="${OUTPUT_FILE%.*}"
|
local base="${OUTPUT_FILE%.*}"
|
||||||
upscale_path="${base}_upscaled.${ext}"
|
upscale_path="${base}_upscaled.${ext}"
|
||||||
else
|
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
|
fi
|
||||||
|
|
||||||
realesrgan_upscale "$final_input" upscale_path || exit 1
|
realesrgan_upscale "$final_input" upscale_path || true
|
||||||
|
|
||||||
# Use the upscaled image for summary/output
|
# Use the upscaled image for summary/output if it was created
|
||||||
output_path="$upscale_path"
|
if [[ -f "${upscale_path:-}" ]]; then
|
||||||
|
output_path="$upscale_path"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Summary
|
# Summary
|
||||||
|
|||||||
Reference in New Issue
Block a user