Opus/2024.12.07-TheThreeCalamities/image/old/z.sh
2026-07-04 09:09:13 -07:00

34 lines
820 B
Bash
Executable File

#!/bin/bash
# Variables
API_KEY="36d8624a99dd4ff2b9bddb7f52c48a15"
INPUT_FILE="./blah.png"
OUTPUT_FILE="blaho.png"
response=$(curl \
-F "image=@${INPUT_FILE}" \
-H "api-key: eca50643-c007-462a-ab9c-a635a9c335e6" \
https://api.deepai.org/api/torch-srgan)
# Step 2: Parse the output URL from the response
output_url=$(echo "$response" | grep -oP '(?<="output_url": ")[^"]*')
# Step 3: Check if the URL was retrieved
if [ -z "$output_url" ]; then
echo "Error: Unable to retrieve the output URL."
echo "Response: $response"
exit 1
fi
echo "Upscaled image URL: $output_url"
# Step 4: Download the upscaled image
curl -s -o "${OUTPUT_FILE}" "${output_url}"
if [ $? -eq 0 ]; then
echo "Upscaled image saved as ${OUTPUT_FILE}"
else
echo "Error: Failed to download the upscaled image."
fi