top of page
justthetipwithdani

How to use SUPIR to Restore Low Quality, Damaged Images and Colorize Black and White images

For this tutorial I'm going to teach you how to install and use SUPIR to restore old or pixelated photos as well as use creative upscaling to reimagine super pixelated images.


First of all what is ComfyUI and SUPIR? ComfyUI is a platform that allows you to create AI Art using models that you download from sites like Hugging Face and CivitAI. If you want to learn how to install this tool check out my full tutorial. I will assume you have ComfyUI installed with the Comfy Manager. My tutorial will teach you how to install both.


Next SUPIR. We will be using a workflow from ComfyUI Workflows (this one) to restore an Old Photo. SUPIR stands for Scaling-UP Image Restoration and it's just a fancy name for a upscaler that restores your photo and allows you to introduce a noise into the upscale to create new details that are missing from the image but adding new nodes and a denoise control.


Kijai

Now we will visit the Github repository for the creator of this tool Kijai at Kijai/ComfyUI-SUPIR click this link if you want to do a manual install BUT you don't need to go to this site for this tutorial. I am just giving credit to the author and giving you a resource if you can't install using the automatic manager update method.



Let's Start the Tutorial


First things first


Download the SUPIR Model from Hugging face at this link

there are 2 versions which are the SUPIR-v0F_fp16.safetensors and the SUPIR-v0Q_fp16.safetensors. I will refer to them as the F and Q models.


We will download the Q model which is SUPIR-v0Q_fp16.safetensors


Once you click the click the download button it will be sent to your downloads folder


It will look like an unusable file. Don't worry that's normal. Now Click on the File and Press Ctrl + X at the same time to Cut the file, it should be a Greyish now.


Now go into your ComfyUI\models\checkpoints folder. This was confusing to me at first because it is an upscaler that goes in the checkpoints model. However, this is where the node tries to look for SUPIR so put it there.


This is where Mine is located below:


E:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\models\checkpoints



Paste your file into the directory by Pressing Ctrl + V.


Confirm the file made it in correctly to your ComfyUI\checkpoints folder


Now we need some control net's to make this work for the final upscale.


This tool uses 4 different types of control nets that we will have to download. As you download them rename them if the file you download doesn't name the model by default. If you get too many generic names you won't know which model is which and will have to start over for this part.


NOTE: In a perfect world we would just use union control net to cover all models and all control nets but this workflow wasn't made for that so you will have to tinker with it. I will just show you how to use it as is.


  • Control-Lora-Recolor (Link) you only need the recolor but just download them all


  • Diffusers_xl_depth_Small (Link)

  • t2i-adapater_xl_openpose (Link)


  • t2i_adapter_lineart (Link)


Download all control nets and cut and paste them from your download folder into your ComfyUI\Models\Controlnet


This is what my folder looks like: E:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\models\controlnet


Cut Control net files you downloaded

And paste them into your Control net ComfyUI\models\Controlnet


Great Job! Your done adding Control net to your Models/Controlnet and the SUPIR Model to your Model/Checkpoints. Your almost set.


Now we need a upscaler if you don't have one. I'm going to download the one the author used. 4x Fool Hardy Remacri which you can download at this link.


Notice that this one is a .pth file so we will put this in the ComfyUI/Models/Upscale_Models unlike the SUPIR which we put in checkpoints. Cut and Paste the .pth file you download into the upscale models folder.


The path I put this upscaler in is: E:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\models\upscale_models


Now we need to download a workload that takes advantage of SUPIR. It doesn't have to be this one. But here is the Link for the workflow that I will use.


Click on the download button to grab the workflow




The downloaded workflow will look like a text file just like this.


Don't worry. It will work







Nicely Done!

We got the pre-req's down for the automatic install. We just need to do an automatic update now.

Open up ComfyUI and run it like your normall do by clicking on the run_nvidia_gpu file. If you have an AMD your clicking run_CPU and expect 10x slower generation times.



Loading the Workflow: With ComfyUI open. Drag the workflow into the empty space.



BOOM Goes Dynamite the workflow is in ComfyUI!!!! But wait a min...


When you first drop the workflow in you will see an overwhelming amount of warnings and 10+ Missing nodes. don't worry we aren't download these one by one.


This is the exact warning: "Warning: Missing Node Types

When loading the graph, the following node types were not found:"


Have no fear if you followed my install tutorial you will have the ComfyUI manager from LTDRdata. You did use my tutorial to install ComfyUI right????



Just close that out by clicking on the X and click on the manager button at the right of your screen.


It's right above the Green Share Button...




Step 1. We will click on Update all. Once everything is updated you will be asked to restart. Click on OK with the prompt with your local Loop back address (127.0.0.1) Then you will see the reconnecting sign. Normally ComfyUI will open up on a new tab. Just close the old Tab or Press F5 to refresh if it doesn't refresh on it's own.



You will be met with the Missing nodes warning again. Don't worry. Go back into the manager one more time like you just did and continue to Step 2. which is click on install missing custom nodes.



After Clicking install missing custom nodes you will be met with a list of nodes you will need to download. Click on the ID Button at the top left to checkmark all the nodes because you will need all of them. There should be 12 Custom nodes total.


Just let it install and it will ask you to restart and reconnect again just like when we "updated all" In Step 1.


Now when you restart you should have zero missing nodes. If that is not the case then close out of ComfyUI completely (close your command prompt too) and do the process again.



At first glance it looks crazy and in Chinese. That's because this is ComfyUI and some words are in Chinese actually...


Don't worry about it I'm going through it step by step.


I have translated the note in Chinese and the Fast Groups Muter that has Chinese is not even connected. We will not be using it.


Here is what the note in Chinese said: "Switch: If you don't zoom in on 8K, please turn off all the related 8K, otherwise an error will be reported

If 8K is enabled, the default magnification object is the colored magnification; If you need to switch, switch to 1 at the zoom switch"


Here is an overview to help you understand this workflow


Let's take a look at the first Part of the 2k by SUPIR Flow and do the first 3 Parts. Part 1 Upload Bad Image, Part 2 Load Preferred Mode i.e. SD3, SDXL Lighting and Part 3 Upload SUPIR.


P.S. there is a lot more going on perhaps some of it I don't understand but the above image is the basic flow.


Let's start with this part of the work flow:


Anything I skip means I left the default values or didn't change it. Also, even if the file name is correct by default you have to reselect it if it's your first time because the name might be slightly diff or the workflow was used before you download the models. In any case you should Refresh your page so the models show up.


Let's Upload the Image in the "LOAD NODE" by clicking "choose file to upload" and select your picture


Then click on open after you clicked on the pic you want to upload.





Click in the center of the ckpt name and you can choose from a list of check points.


The controlnet models we are using are SDXL based so you need to choose an SDXL model. I'm using Juggernaut X but most people prefer Juggernaut Lighting because it will speed up the process.


Now go to the SUPIR model loader node to the right and choose your SUPIR model.

IMPORTANT: If your like me and you added the model while ComfyUI was running you will have to refresh by pressing F5 or clicking on the refresh button.


Now go to the middle section where your control net models are and focus on these nodes:


The Green box is your positive prompt. You can describe your image. Then the red box is for the things you don't want in your image.








Now the top left is your Load Control Net Model: Select Control-Lora-Recolor-Rank256 that we downloaded.









A little bit to the right you will see 3 more Loaders for Control Net. Uploaded the appropriate control net. The default workflow will have the model that should be there but you will have to reselect it to activate it since it was created before your installed the model. Plus some of the names may differ as we changed the default name of the file.



Here are the 3:

Note: If you don't see your control net and you put your Control Net models into the ComfyUI/Models/Controlnet folder. Then refresh your ComfyUI webpage.


Whew... K one last thing to download and put in the correct Comfy Folders, which is for your DWPose Node:


You need to get DWPose onnx files from this link :

We are only grabbing 2 to make this work which are the 2 in the default workflow. Feel free to grab all the DWPoses if you have the extra space.















Download Yolox_s and dw-mm_ucocco from the hugging face site.


Then put it in your ComfyUI


Time to click on Generate or Queue Prompt










Trouble Shooting


If your workflow fails find the node that is highlighted a red, orange, yellow or purple.



I have a problem here at these nodes surrounded by red and the error is below in red text. So I'll put 2 and 2 together. The problem is at this node and something about an image resize failed validation.


It seems the Diffusers_XL_Depth controlnet I selected was the default and I didn't reselect it like I mentioned in my instructions so I did that now and I queue'd it again.


By Reading this it seems to be complaining about the method TRUE option in image resize so I tried a diff option "fill/crop" and it's working.

You can tell it's working or what step it's in by looking for a green highlighted nodes like this

one:

You can also see a green percentage complete bar that shows your progress:


You can also check your command prompt:

As long as the last few request don't say failed you should be moving. Keep in mind the failed nodes will still be highlighted until the process get's to that point in the workflow. So some items might still be highlighted red. Just look for the green. If your not using a super quick model like SDXL Lighting you can wait up to 5min for a single upscale.


So I'm still getting held up here: Which is one of the control nets.


I now realize that DWPose require their own files for the bbox_detector and pose estimator which I downloaded and added to the tutorial so you wouldn't go through the same issues. But this is an example how to find the problem.


Note: A big part of trouble shooting is identifying the red nodes and automatically updating them with ComfyUI manager and manually installing the models, control nets or DWPose onnx files into the correct folders. Essentially everything goes into the models folder with their matching files i.e. checkpoints take safetensors or ckpt's, onnx take onnx files, upscalers take .pth files and so on. Also ensure your using the correct model like SDXL for most of these upscalers and you have manually selected the models for all nodes that require them.


4 views0 comments

Commentaires


bottom of page