init
Browse files- .gitignore +0 -1
- README.md +11 -0
- SuperResolutionAnimeDiffusion.zip +3 -0
- Waifu2x/model_check_points/CRAN_V2/CARN_model_checkpoint.pt +3 -0
- Waifu2x/model_check_points/CRAN_V2/ReadME.md +34 -0
- app.py +9 -7
- random_examples.zip +3 -0
- test.py +23 -0
.gitignore
CHANGED
@@ -10,7 +10,6 @@ integrated_datasets/
|
|
10 |
*.state_dict
|
11 |
*.config
|
12 |
*.args
|
13 |
-
*.zip
|
14 |
*.gz
|
15 |
*.bin
|
16 |
*.result.txt
|
|
|
10 |
*.state_dict
|
11 |
*.config
|
12 |
*.args
|
|
|
13 |
*.gz
|
14 |
*.bin
|
15 |
*.result.txt
|
README.md
CHANGED
@@ -1,3 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# Super Resolution Anime Diffusion
|
2 |
|
3 |
|
|
|
1 |
+
---
|
2 |
+
title: Anything V3.0
|
3 |
+
emoji: 🏃
|
4 |
+
colorFrom: gray
|
5 |
+
colorTo: yellow
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.10.1
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
---
|
11 |
+
|
12 |
# Super Resolution Anime Diffusion
|
13 |
|
14 |
|
SuperResolutionAnimeDiffusion.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ef0a17ab5723e783a679cab83a05411ab09bb04886a629a5181bb18df0175c76
|
3 |
+
size 256633269
|
Waifu2x/model_check_points/CRAN_V2/CARN_model_checkpoint.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3a0ef4fdea5b0b2a91b05b7a39fe63df3e27e1d18df477065e7f268a7feaaad2
|
3 |
+
size 4329165
|
Waifu2x/model_check_points/CRAN_V2/ReadME.md
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Resume & Use Model Check Points
|
2 |
+
|
3 |
+
This folder contains check points for models and their weights. They are generated from [PyTorch's pickle](https://pytorch.org/docs/master/notes/serialization.html).
|
4 |
+
|
5 |
+
Model specifications are in each folder's ReadME.
|
6 |
+
|
7 |
+
Pickle names with "model" contain the entire models, and they can be used as an freeze module by calling the "forward_checkpoint" function to generate images.
|
8 |
+
|
9 |
+
Example:
|
10 |
+
```python
|
11 |
+
import torch
|
12 |
+
# No need to reconstruct the model
|
13 |
+
model = torch.load("./DCSCN/DCSCN_model_387epos_L12_noise_1.pt")
|
14 |
+
x = torch.randn((1,3,10,10)), torch.randn((1,3,20,20))
|
15 |
+
out = model.forward_checkpoint(a)
|
16 |
+
```
|
17 |
+
|
18 |
+
Pickle names with "weights" are model weights, and they are named dictionaries.
|
19 |
+
|
20 |
+
Example:
|
21 |
+
```python
|
22 |
+
model = DCSCN(*) # the setting must be the same to load check points weights.
|
23 |
+
model.load_state_dict(torch.load("./DCSCN/DCSCN_weights_387epos_L12_noise_1.pt"))
|
24 |
+
# then you can resume the model training
|
25 |
+
```
|
26 |
+
|
27 |
+
Model check poins in Upconv_7 and vgg_7 are from [waifu2x's repo](https://github.com/nagadomi/waifu2x/tree/master/models). To load weights into a model, please use ```load_pre_train_weights``` function.
|
28 |
+
|
29 |
+
Example:
|
30 |
+
```python
|
31 |
+
model = UpConv_7()
|
32 |
+
model.load_pre_train_weights(json_file=...)
|
33 |
+
# then the model is ready to use
|
34 |
+
```
|
app.py
CHANGED
@@ -2,17 +2,19 @@ import os
|
|
2 |
import random
|
3 |
import zipfile
|
4 |
import findfile
|
5 |
-
|
6 |
-
for z_file in findfile.find_cwd_files(and_key=['.zip'],
|
7 |
-
exclude_key=['.ignore', 'git', 'SuperResolutionAnimeDiffusion'],
|
8 |
-
recursive=1):
|
9 |
-
with zipfile.ZipFile(z_file, 'r') as zip_ref:
|
10 |
-
zip_ref.extractall()
|
11 |
-
|
12 |
import PIL.Image
|
13 |
import autocuda
|
14 |
from pyabsa.utils.pyabsa_utils import fprint
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
from diffusers import (
|
17 |
AutoencoderKL,
|
18 |
UNet2DConditionModel,
|
|
|
2 |
import random
|
3 |
import zipfile
|
4 |
import findfile
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
import PIL.Image
|
6 |
import autocuda
|
7 |
from pyabsa.utils.pyabsa_utils import fprint
|
8 |
|
9 |
+
# for z_file in findfile.find_cwd_files(and_key=['.zip'],
|
10 |
+
# exclude_key=['.ignore', 'git', 'SuperResolutionAnimeDiffusion'],
|
11 |
+
# recursive=10):
|
12 |
+
# fprint(f"Extracting {z_file}...")
|
13 |
+
# with zipfile.ZipFile(z_file, 'r') as zip_ref:
|
14 |
+
# zip_ref.extractall(os.path.dirname(z_file))
|
15 |
+
|
16 |
+
os.system('unzip random_examples.zip -d random_examples')
|
17 |
+
|
18 |
from diffusers import (
|
19 |
AutoencoderKL,
|
20 |
UNet2DConditionModel,
|
random_examples.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0d38130425c106b715732609413675a33cd3eb551fe7eb7789ca87b5210d9f55
|
3 |
+
size 8051179
|
test.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
# file: test.py
|
3 |
+
# time: 23:21 2023/1/27
|
4 |
+
# author: yangheng <hy345@exeter.ac.uk>
|
5 |
+
# github: https://github.com/yangheng95
|
6 |
+
# huggingface: https://huggingface.co/yangheng
|
7 |
+
# google scholar: https://scholar.google.com/citations?user=NPq5a_0AAAAJ&hl=en
|
8 |
+
# Copyright (C) 2021. All Rights Reserved.
|
9 |
+
|
10 |
+
def fixBadZipfile(zipFile):
|
11 |
+
f = open(zipFile, 'r+b')
|
12 |
+
data = f.read()
|
13 |
+
pos = data.find('\x50\x4b\x05\x06') # End of central directory signature
|
14 |
+
if (pos > 0):
|
15 |
+
f.seek(pos + 22) # size of 'ZIP end of central directory record'
|
16 |
+
f.truncate()
|
17 |
+
f.close()
|
18 |
+
else:
|
19 |
+
pass
|
20 |
+
|
21 |
+
|
22 |
+
if __name__ == '__main__':
|
23 |
+
fixBadZipfile('RealESRGANv030/weights/RealESRGAN_x4plus_anime_6B.zip')
|