Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various improvements #48

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
2c821a4
Updated gradio interface and models
ashleykleynhans Feb 27, 2024
905475a
Updated requirements
ashleykleynhans Feb 27, 2024
2f6d9f8
Added diffusers to requirements
ashleykleynhans Feb 27, 2024
85bde04
Add back some stuff
ashleykleynhans Feb 27, 2024
51f1535
Reenable LLaVA by default
ashleykleynhans Feb 27, 2024
7ba69c4
Reenable LLaVA by default
ashleykleynhans Feb 27, 2024
7fb5066
Fix typo
ashleykleynhans Feb 27, 2024
ec7a03e
Added bitsandbytes to requirements
ashleykleynhans Feb 27, 2024
8aa303f
Pin gradio versions
ashleykleynhans Feb 27, 2024
7376394
Switch LLaVA 13B to 7B
ashleykleynhans Feb 27, 2024
273c987
Changed SDXL model
ashleykleynhans Feb 27, 2024
783fa29
Merge branch 'Fanghua-Yu:master' into master
ashleykleynhans Feb 27, 2024
c47d6b7
Added batch processing
ashleykleynhans Feb 27, 2024
7de88bf
Merge branch 'master' of github.com:ashleykleynhans/SUPIR
ashleykleynhans Feb 27, 2024
5a7a451
Use step of 0.1 instead of 1 on upscale slider
ashleykleynhans Feb 27, 2024
05749ed
add missing param on gr.Slider
bearstonem Feb 28, 2024
c0d07ce
Merge pull request #1 from bearstonem/fix
ashleykleynhans Feb 28, 2024
0b31941
Removed IntelliJ files
ashleykleynhans Feb 29, 2024
dae7909
Fix typos
ashleykleynhans Feb 29, 2024
1327b60
Updated README and requirements
ashleykleynhans Feb 29, 2024
136b415
Added script to download the models
ashleykleynhans Feb 29, 2024
a6e9dce
Fixed formatting
ashleykleynhans Feb 29, 2024
5a60ca8
Some refactoring
ashleykleynhans Feb 29, 2024
ded8b8c
Support providing outputs_folder as command line argument
ashleykleynhans Feb 29, 2024
9656f0a
Fixes and remove duplicate code
ashleykleynhans Feb 29, 2024
6c84eb1
Additional implementation for outputs_folder command line argument
ashleykleynhans Feb 29, 2024
454c3f1
Added Replicate demo and RunPod template to README
ashleykleynhans Feb 29, 2024
ff9ad55
Added YouTube tutorial
ashleykleynhans Feb 29, 2024
ea332a2
Revert SDXL_CKPT to base SDXL model since Juggernaut is not very good…
ashleykleynhans Mar 1, 2024
9a5689b
Remove unused code
ashleykleynhans Mar 2, 2024
c355688
Resolved merge conflict
ashleykleynhans Mar 2, 2024
37715af
Retain original filename in batch processing
ashleykleynhans Mar 4, 2024
339641e
Resolved merge conflict
ashleykleynhans Mar 5, 2024
4e3e895
Merge branch 'Fanghua-Yu:master' into master
ashleykleynhans Mar 8, 2024
9421fb2
Resolved merge conflict
ashleykleynhans Mar 9, 2024
1c8e7b8
Merge branch 'master' of github.com:ashleykleynhans/SUPIR
ashleykleynhans Mar 9, 2024
b6d497b
Merge branch 'Fanghua-Yu:master' into master
ashleykleynhans Mar 12, 2024
4f35aec
Merge branch 'Fanghua-Yu:master' into master
ashleykleynhans Jun 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
indent_style = space

[*.yaml]
indent_size = 2
indent_style = space
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
models
__pycache__
venv
.idea
.vs
outputs
8 changes: 0 additions & 8 deletions .idea/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/SUPIR.iml

This file was deleted.

23 changes: 0 additions & 23 deletions .idea/deployment.xml

This file was deleted.

38 changes: 0 additions & 38 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/inspectionProfiles/profiles_settings.xml

This file was deleted.

4 changes: 0 additions & 4 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

14 changes: 0 additions & 14 deletions .idea/webResources.xml

This file was deleted.

8 changes: 4 additions & 4 deletions CKPT_PTH.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LLAVA_CLIP_PATH = '/opt/data/private/AIGC_pretrain/LLaVA1.5/clip-vit-large-patch14-336'
LLAVA_MODEL_PATH = '/opt/data/private/AIGC_pretrain/LLaVA1.5/llava-v1.5-13b'
SDXL_CLIP1_PATH = '/opt/data/private/AIGC_pretrain/clip-vit-large-patch14'
SDXL_CLIP2_CKPT_PTH = '/opt/data/private/AIGC_pretrain/CLIP-ViT-bigG-14-laion2B-39B-b160k/open_clip_pytorch_model.bin'
LLAVA_CLIP_PATH = 'openai/clip-vit-large-patch14-336'
LLAVA_MODEL_PATH = 'liuhaotian/llava-v1.5-7b'
SDXL_CLIP1_PATH = 'openai/clip-vit-large-patch14'
SDXL_CLIP2_CKPT_PTH = 'models/open_clip_pytorch_model.bin'
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## (CVPR2024) Scaling Up to Excellence: Practicing Model Scaling for Photo-Realistic Image Restoration In the Wild

> [[Paper](https://arxiv.org/abs/2401.13627)] &emsp; [[Project Page](http://supir.xpixel.group/)] &emsp; [Online Demo (Coming soon)] <br>
> [[Paper](https://arxiv.org/abs/2401.13627)] &emsp; [[Project Page](http://supir.xpixel.group/)]<br>
> Fanghua, Yu, [Jinjin Gu](https://www.jasongt.com/), Zheyuan Li, Jinfan Hu, Xiangtao Kong, [Xintao Wang](https://xinntao.github.io/), [Jingwen He](https://scholar.google.com.hk/citations?user=GUxrycUAAAAJ), [Yu Qiao](https://scholar.google.com.hk/citations?user=gFtI-8QAAAAJ), [Chao Dong](https://scholar.google.com.hk/citations?user=OSDCB0UAAAAJ) <br>
> Shenzhen Institute of Advanced Technology; Shanghai AI Laboratory; University of Sydney; The Hong Kong Polytechnic University; ARC Lab, Tencent PCG; The Chinese University of Hong Kong <br>

Expand Down Expand Up @@ -38,7 +38,7 @@ For users who can connect to huggingface, please setting `LLAVA_CLIP_PATH, SDXL_
* [SDXL CLIP Encoder-2](https://huggingface.co/laion/CLIP-ViT-bigG-14-laion2B-39B-b160k)
* [SDXL base 1.0_0.9vae](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/blob/main/sd_xl_base_1.0_0.9vae.safetensors)
* [LLaVA CLIP](https://huggingface.co/openai/clip-vit-large-patch14-336)
* [LLaVA v1.5 13B](https://huggingface.co/liuhaotian/llava-v1.5-13b)
* [LLaVA v1.5 7B](https://huggingface.co/liuhaotian/llava-v1.5-7b)
* (optional) [Juggernaut-XL_v9_RunDiffusionPhoto_v2](https://huggingface.co/RunDiffusion/Juggernaut-XL-v9/blob/main/Juggernaut-XL_v9_RunDiffusionPhoto_v2.safetensors)
* Replacement of `SDXL base 1.0_0.9vae` for Photo Realistic
* (optional) [Juggernaut_RunDiffusionPhoto2_Lightning_4Steps](https://huggingface.co/RunDiffusion/Juggernaut-XL-Lightning/blob/main/Juggernaut_RunDiffusionPhoto2_Lightning_4Steps.safetensors)
Expand Down Expand Up @@ -124,8 +124,11 @@ CUDA_VISIBLE_DEVICES=0,1 python gradio_demo.py --ip 0.0.0.0 --port 6688 --use_im
</p>


### Online Demo (Coming Soon)
### Online Resources & Demos

1. [Replicate Demo](https://replicate.com/cjwbw/supir)
2. [RunPod Template](https://runpod.io/console/gpu-cloud?template=aa31uo64wv&ref=2xxro4sy)
3. [YouTube Tutorial](https://www.youtube.com/watch?v=PqREA6-bC3w)

---

Expand Down
69 changes: 69 additions & 0 deletions download_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env python3
import os
import requests
from tqdm import tqdm
from huggingface_hub import snapshot_download


def create_directory(path):
"""Create directory if it does not exist."""
if not os.path.exists(path):
os.makedirs(path)
print(f'Directory created: {path}')
else:
print(f'Directory already exists: {path}')


def download_file(url, folder_path, file_name=None):
"""Download a file from a given URL to a specified folder with an optional file name."""
local_filename = file_name if file_name else url.split('/')[-1]
local_filepath = os.path.join(folder_path, local_filename)
print(f'Downloading {url} to: {local_filepath}')

# Stream download to handle large files
with requests.get(url, stream=True) as r:
r.raise_for_status()
total_size_in_bytes = int(r.headers.get('content-length', 0))
block_size = 1024 # 1 Kibibyte
progress_bar = tqdm(total=total_size_in_bytes, unit='iB', unit_scale=True)
with open(local_filepath, 'wb') as f:
for data in r.iter_content(block_size):
progress_bar.update(len(data))
f.write(data)
progress_bar.close()

if total_size_in_bytes != 0 and progress_bar.n != total_size_in_bytes:
print('ERROR, something went wrong')
else:
print(f'Downloaded {local_filename} to {folder_path}')


# Define the folders and their corresponding file URLs with optional file names
folders_and_files = {
os.path.join('models'): [
('https://huggingface.co/laion/CLIP-ViT-bigG-14-laion2B-39B-b160k/resolve/main/open_clip_pytorch_model.bin', None),
('https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0_0.9vae.safetensors', None),
('https://huggingface.co/ashleykleynhans/SUPIR/resolve/main/SUPIR-v0F.ckpt', None),
('https://huggingface.co/ashleykleynhans/SUPIR/resolve/main/SUPIR-v0Q.ckpt', None),
]
}


if __name__ == '__main__':
for folder, files in folders_and_files.items():
create_directory(folder)
for file_url, file_name in files:
download_file(file_url, folder, file_name)

llava_model = os.getenv('LLAVA_MODEL', 'liuhaotian/llava-v1.5-7b')
llava_clip_model = 'openai/clip-vit-large-patch14-336'
sdxl_clip_model = 'openai/clip-vit-large-patch14'

print(f'Downloading LLaVA model: {llava_model}')
snapshot_download(llava_model)

print(f'Downloading LLaVA CLIP model: {llava_clip_model}')
snapshot_download(llava_clip_model)

print(f'Downloading SDXL CLIP model: {sdxl_clip_model}')
snapshot_download(sdxl_clip_model)
Loading