upscayl / upscayl

🆙 Upscayl - #1 Free and Open Source AI Image Upscaler for Linux, MacOS and Windows.
https://upscayl.org
GNU Affero General Public License v3.0
31.32k stars 1.45k forks source link

Upscayl retaining cached input image #944

Closed silicongarage closed 3 months ago

silicongarage commented 3 months ago

Checklist

Describe the Bug

Upscayl is retaining the previous cached version of an input image. When the input image has been edited after an upscale, trying to load the new version (same file name) retains the older image. Same behavior if I reset image or not.

To Reproduce

  1. Create an image

    triangle
  2. Select image

    select
  3. Upscayl

    upscayl
  4. Edit the original image

    rectangle
  5. Reset Upscayl

    reset_image
  6. Select edited image

    select
  7. Previous image retained

    wrong input

Upscayl Version (or commit hash)

2.11.5

Platform

Mac DMG / Homebrew

OS Version

macOS 14.6.1

GPU Name

macbook M2 pro

Expected Behavior

Correct version of input file should be loaded.

Screenshots

No response

Logs

⚙️ Getting saveImageAs from localStorage:  png
⚙️ Getting model from localStorage:  {"label":"Digital Art","value":"realesrgan-x4plus-anime"}
⚙️ Setting gpuId to empty string
🔀 Setting model to 
🔀 Setting model to realesrgan-x4plus-anime
🔄 Resetting image paths
🎒 BACKEND REPORTED:  🖼️ Updating Image Path:  /Users/buster/Diffusion/upt-test/upt-test.png
🖼 Selected Image Path:  /Users/buster/Diffusion/upt-test/upt-test.png
📁 Selected Image Directory:  /Users/buster/Diffusion/upt-test
🖼 imagePath:  /Users/buster/Diffusion/upt-test/upt-test.png
🔤 Extension:  png
🎒 BACKEND REPORTED:  📄 Selected File Path:  /Users/buster/Diffusion/upt-test/upt-test.png
🔄 Resetting Upscaled Image Path
🏁 UPSCAYL
🎒 BACKEND REPORTED:  ✅ Upscayl Variables:  {"model":"realesrgan-x4plus-anime","gpuId":null,"saveImageAs":"png","inputDir":"/Users/buster/Diffusion/upt-test","fileNameWithExt":"upt-test.png","outputDir":"/Users/buster/Diffusion/upt-test","outFile":"/Users/buster/Diffusion/upt-test/upt-test_upscayl_2x_realesrgan-x4plus-anime.png","fileName":"upt-test","scale":"2","compression":"0","customWidth":"","useCustomWidth":false,"tileSize":null}
🎒 BACKEND REPORTED:  📢 Upscayl Command:  -i,/Users/buster/Diffusion/upt-test/upt-test.png,-o,/Users/buster/Diffusion/upt-test/upt-test_upscayl_2x_realesrgan-x4plus-anime.png,-s,2,-m,/Applications/Upscayl.app/Contents/Resources/models,-n,realesrgan-x4plus-anime,-f,png,-c,0
🎒 BACKEND REPORTED:  👶 Updating Child Processes:  {"binary":"/Applications/Upscayl.app/Contents/Resources/bin/upscayl-bin","args":["/Applications/Upscayl.app/Contents/Resources/bin/upscayl-bin","-i","/Users/buster/Diffusion/upt-test/upt-test.png","-o","/Users/buster/Diffusion/upt-test/upt-test_upscayl_2x_realesrgan-x4plus-anime.png","-s","2","-m","/Applications/Upscayl.app/Contents/Resources/models","-n","realesrgan-x4plus-anime","-f","png","-c","0"]}
🎒 BACKEND REPORTED:  🛑 Updating Stopped:  false
🎒 BACKEND REPORTED:  🚀 Starting Upscayl - Copyright © 2024
✨ Detected scale x4
✨ Using the default scale x4

🚧 UPSCAYL_PROGRESS:  🚀 Starting Upscayl - Copyright © 2024
✨ Detected scale x4
✨ Using the default scale x4

🎒 BACKEND REPORTED:  [0 Apple M2 Max]  queueC=0[1]  queueG=0[1]  queueT=0[1]
[0 Apple M2 Max]  bugsbn1=0  bugbilz=242  bugcopc=0  bugihfa=0
[0 Apple M2 Max]  fp16-p/s/a=1/1/1  int8-p/s/a=1/1/1
[0 Apple M2 Max]  subgroup=32  basic=1  vote=1  ballot=1  shuffle=1

🚧 UPSCAYL_PROGRESS:  [0 Apple M2 Max]  queueC=0[1]  queueG=0[1]  queueT=0[1]
[0 Apple M2 Max]  bugsbn1=0  bugbilz=242  bugcopc=0  bugihfa=0
[0 Apple M2 Max]  fp16-p/s/a=1/1/1  int8-p/s/a=1/1/1
[0 Apple M2 Max]  subgroup=32  basic=1  vote=1  ballot=1  shuffle=1

🎒 BACKEND REPORTED:  0.00%

🚧 UPSCAYL_PROGRESS:  0.00%

🎒 BACKEND REPORTED:  1.14%

🚧 UPSCAYL_PROGRESS:  1.14%

🎒 BACKEND REPORTED:  2.27%

🚧 UPSCAYL_PROGRESS:  2.27%

🎒 BACKEND REPORTED:  3.41%

🚧 UPSCAYL_PROGRESS:  3.41%

🎒 BACKEND REPORTED:  4.55%

🚧 UPSCAYL_PROGRESS:  4.55%

🎒 BACKEND REPORTED:  5.68%

🚧 UPSCAYL_PROGRESS:  5.68%

🎒 BACKEND REPORTED:  6.82%

🚧 UPSCAYL_PROGRESS:  6.82%

🎒 BACKEND REPORTED:  7.95%

🚧 UPSCAYL_PROGRESS:  7.95%

🎒 BACKEND REPORTED:  9.09%

🚧 UPSCAYL_PROGRESS:  9.09%

🎒 BACKEND REPORTED:  10.23%

🚧 UPSCAYL_PROGRESS:  10.23%

🎒 BACKEND REPORTED:  11.36%

🚧 UPSCAYL_PROGRESS:  11.36%

🎒 BACKEND REPORTED:  12.50%

🚧 UPSCAYL_PROGRESS:  12.50%

🎒 BACKEND REPORTED:  13.64%

🚧 UPSCAYL_PROGRESS:  13.64%

🎒 BACKEND REPORTED:  14.77%

🚧 UPSCAYL_PROGRESS:  14.77%

🎒 BACKEND REPORTED:  15.91%

🚧 UPSCAYL_PROGRESS:  15.91%

🎒 BACKEND REPORTED:  17.05%

🚧 UPSCAYL_PROGRESS:  17.05%

🎒 BACKEND REPORTED:  18.18%

🚧 UPSCAYL_PROGRESS:  18.18%

🎒 BACKEND REPORTED:  19.32%

🚧 UPSCAYL_PROGRESS:  19.32%

🎒 BACKEND REPORTED:  20.45%

🚧 UPSCAYL_PROGRESS:  20.45%

🎒 BACKEND REPORTED:  21.59%

🚧 UPSCAYL_PROGRESS:  21.59%

🎒 BACKEND REPORTED:  22.73%

🚧 UPSCAYL_PROGRESS:  22.73%

🎒 BACKEND REPORTED:  23.86%

🚧 UPSCAYL_PROGRESS:  23.86%

🎒 BACKEND REPORTED:  25.00%

🚧 UPSCAYL_PROGRESS:  25.00%

🎒 BACKEND REPORTED:  26.14%

🚧 UPSCAYL_PROGRESS:  26.14%

🎒 BACKEND REPORTED:  27.27%

🚧 UPSCAYL_PROGRESS:  27.27%

🎒 BACKEND REPORTED:  28.41%

🚧 UPSCAYL_PROGRESS:  28.41%

🎒 BACKEND REPORTED:  29.55%

🚧 UPSCAYL_PROGRESS:  29.55%

🎒 BACKEND REPORTED:  30.68%

🚧 UPSCAYL_PROGRESS:  30.68%

🎒 BACKEND REPORTED:  31.82%

🚧 UPSCAYL_PROGRESS:  31.82%

🎒 BACKEND REPORTED:  32.95%

🚧 UPSCAYL_PROGRESS:  32.95%

🎒 BACKEND REPORTED:  34.09%

🚧 UPSCAYL_PROGRESS:  34.09%

🎒 BACKEND REPORTED:  35.23%

🚧 UPSCAYL_PROGRESS:  35.23%

🎒 BACKEND REPORTED:  36.36%

🚧 UPSCAYL_PROGRESS:  36.36%

🎒 BACKEND REPORTED:  37.50%

🚧 UPSCAYL_PROGRESS:  37.50%

🎒 BACKEND REPORTED:  38.64%

🚧 UPSCAYL_PROGRESS:  38.64%

🎒 BACKEND REPORTED:  39.77%

🚧 UPSCAYL_PROGRESS:  39.77%

🎒 BACKEND REPORTED:  40.91%

🚧 UPSCAYL_PROGRESS:  40.91%

🎒 BACKEND REPORTED:  42.05%

🚧 UPSCAYL_PROGRESS:  42.05%

🎒 BACKEND REPORTED:  43.18%

🚧 UPSCAYL_PROGRESS:  43.18%

🎒 BACKEND REPORTED:  44.32%

🚧 UPSCAYL_PROGRESS:  44.32%

🎒 BACKEND REPORTED:  45.45%

🚧 UPSCAYL_PROGRESS:  45.45%

🎒 BACKEND REPORTED:  46.59%

🚧 UPSCAYL_PROGRESS:  46.59%

🎒 BACKEND REPORTED:  47.73%

🚧 UPSCAYL_PROGRESS:  47.73%

🎒 BACKEND REPORTED:  48.86%

🚧 UPSCAYL_PROGRESS:  48.86%

🎒 BACKEND REPORTED:  50.00%

🚧 UPSCAYL_PROGRESS:  50.00%

🎒 BACKEND REPORTED:  51.14%

🚧 UPSCAYL_PROGRESS:  51.14%

🎒 BACKEND REPORTED:  52.27%

🚧 UPSCAYL_PROGRESS:  52.27%

🎒 BACKEND REPORTED:  53.41%

🚧 UPSCAYL_PROGRESS:  53.41%

🎒 BACKEND REPORTED:  54.55%

🚧 UPSCAYL_PROGRESS:  54.55%

🎒 BACKEND REPORTED:  55.68%

🚧 UPSCAYL_PROGRESS:  55.68%

🎒 BACKEND REPORTED:  56.82%

🚧 UPSCAYL_PROGRESS:  56.82%

🎒 BACKEND REPORTED:  57.95%

🚧 UPSCAYL_PROGRESS:  57.95%

🎒 BACKEND REPORTED:  59.09%

🚧 UPSCAYL_PROGRESS:  59.09%

🎒 BACKEND REPORTED:  60.23%

🚧 UPSCAYL_PROGRESS:  60.23%

🎒 BACKEND REPORTED:  61.36%

🚧 UPSCAYL_PROGRESS:  61.36%

🎒 BACKEND REPORTED:  62.50%

🚧 UPSCAYL_PROGRESS:  62.50%

🎒 BACKEND REPORTED:  63.64%

🚧 UPSCAYL_PROGRESS:  63.64%

🎒 BACKEND REPORTED:  64.77%

🚧 UPSCAYL_PROGRESS:  64.77%

🎒 BACKEND REPORTED:  65.91%

🚧 UPSCAYL_PROGRESS:  65.91%

🎒 BACKEND REPORTED:  67.05%

🚧 UPSCAYL_PROGRESS:  67.05%

🎒 BACKEND REPORTED:  68.18%

🚧 UPSCAYL_PROGRESS:  68.18%

🎒 BACKEND REPORTED:  69.32%

🚧 UPSCAYL_PROGRESS:  69.32%

🎒 BACKEND REPORTED:  70.45%

🚧 UPSCAYL_PROGRESS:  70.45%

🎒 BACKEND REPORTED:  71.59%

🚧 UPSCAYL_PROGRESS:  71.59%

🎒 BACKEND REPORTED:  72.73%

🚧 UPSCAYL_PROGRESS:  72.73%

🎒 BACKEND REPORTED:  73.86%

🚧 UPSCAYL_PROGRESS:  73.86%

🎒 BACKEND REPORTED:  75.00%

🚧 UPSCAYL_PROGRESS:  75.00%

🎒 BACKEND REPORTED:  76.14%

🚧 UPSCAYL_PROGRESS:  76.14%

🎒 BACKEND REPORTED:  77.27%

🚧 UPSCAYL_PROGRESS:  77.27%

🎒 BACKEND REPORTED:  78.41%

🚧 UPSCAYL_PROGRESS:  78.41%

🎒 BACKEND REPORTED:  79.55%

🚧 UPSCAYL_PROGRESS:  79.55%

🎒 BACKEND REPORTED:  80.68%

🚧 UPSCAYL_PROGRESS:  80.68%

🎒 BACKEND REPORTED:  81.82%

🚧 UPSCAYL_PROGRESS:  81.82%

🎒 BACKEND REPORTED:  82.95%

🚧 UPSCAYL_PROGRESS:  82.95%

🎒 BACKEND REPORTED:  84.09%

🚧 UPSCAYL_PROGRESS:  84.09%

🎒 BACKEND REPORTED:  85.23%

🚧 UPSCAYL_PROGRESS:  85.23%

🎒 BACKEND REPORTED:  86.36%

🚧 UPSCAYL_PROGRESS:  86.36%

🎒 BACKEND REPORTED:  87.50%

🚧 UPSCAYL_PROGRESS:  87.50%

🎒 BACKEND REPORTED:  88.64%

🚧 UPSCAYL_PROGRESS:  88.64%

🎒 BACKEND REPORTED:  89.77%

🚧 UPSCAYL_PROGRESS:  89.77%

🎒 BACKEND REPORTED:  90.91%

🚧 UPSCAYL_PROGRESS:  90.91%

🎒 BACKEND REPORTED:  92.05%

🚧 UPSCAYL_PROGRESS:  92.05%

🎒 BACKEND REPORTED:  93.18%

🚧 UPSCAYL_PROGRESS:  93.18%

🎒 BACKEND REPORTED:  94.32%

🚧 UPSCAYL_PROGRESS:  94.32%

🎒 BACKEND REPORTED:  95.45%

🚧 UPSCAYL_PROGRESS:  95.45%

🎒 BACKEND REPORTED:  96.59%

🚧 UPSCAYL_PROGRESS:  96.59%

🎒 BACKEND REPORTED:  97.73%

🚧 UPSCAYL_PROGRESS:  97.73%

🎒 BACKEND REPORTED:  98.86%

🚧 UPSCAYL_PROGRESS:  98.86%

🎒 BACKEND REPORTED:  🏞️ Resizing image according to output scale

🚧 UPSCAYL_PROGRESS:  🏞️ Resizing image according to output scale

🎒 BACKEND REPORTED:  🏞️ Scaled image from 2048x1536 to 4096x3072

🚧 UPSCAYL_PROGRESS:  🏞️ Scaled image from 2048x1536 to 4096x3072

🎒 BACKEND REPORTED:  100.00

🙌 Upscayled Successfully!

🚧 UPSCAYL_PROGRESS:  100.00

🙌 Upscayled Successfully!

🎒 BACKEND REPORTED:  💯 Done upscaling
upscaledImagePath:  /Users/buster/Diffusion/upt-test/upt-test_upscayl_2x_realesrgan-x4plus-anime.png
💯 UPSCAYL_DONE:  /Users/buster/Diffusion/upt-test/upt-test_upscayl_2x_realesrgan-x4plus-anime.png
🔄 Resetting image paths
🔄 Resetting image paths
🎒 BACKEND REPORTED:  🖼️ Updating Image Path:  /Users/buster/Diffusion/upt-test/upt-test.png
🎒 BACKEND REPORTED:  📄 Selected File Path:  /Users/buster/Diffusion/upt-test/upt-test.png
🖼 Selected Image Path:  /Users/buster/Diffusion/upt-test/upt-test.png
📁 Selected Image Directory:  /Users/buster/Diffusion/upt-test
🖼 imagePath:  /Users/buster/Diffusion/upt-test/upt-test.png
🔤 Extension:  png
⚙️ Getting saveImageAs from localStorage:  png
⚙️ Getting model from localStorage:  {"label":"Digital Art","value":"realesrgan-x4plus-anime"}
⚙️ Setting gpuId to empty string
dosubot[bot] commented 3 months ago

Hello, @silicongarage! I'm here to help you with any bugs, questions, or contributions you have for the Upscayl repository. Let me know how I can assist you!

Upscayl is retaining the previous cached version of an input image because the imagePath and upscaledImagePath states are not being reset properly. The resetImagePaths function, which is responsible for resetting these paths, might not be called in the right places or at the right times.

Here is the relevant code snippet for the resetImagePaths function:

const resetImagePaths = () => {
    logit("🔄 Resetting image paths");
    setDimensions({
      width: null,
      height: null,
    });
    setProgress("");
    setImagePath("");
    setUpscaledImagePath("");
    setBatchFolderPath("");
    setUpscaledBatchFolderPath("");
};

To ensure that the paths are reset when an image is reloaded, you should call resetImagePaths in the appropriate place in your code where the image reload logic is handled [1].

To continue talking to Dosu, mention @dosu.

NayamAmarshe commented 3 months ago

We do not delete original images, ever. It's better to be safe than sorry.

silicongarage commented 3 months ago

Maybe add a user option that allows re-use of the same file name?

I'm using Upscayl in a photo-editing workflow. I will make image changes in the photo-editor, export a .png , Upscayl that file and look at results. Then back into the editor with more changes to the original file, exporting it again and then going through the same Upscayl process. My work flow would create dozens and dozens of intermediate export files if I have to change the name every time I want to Upscayl.

NayamAmarshe commented 3 months ago

You should be using output folders and enable overwrite option in settings.

aaronliu0130 commented 3 months ago

As said above, this is intentional behavior that you can ignore by enabling the overwrite option.