Spaces:
Running
on
Zero
Running
on
Zero
feat: huggingface_hub
Browse files- app.py +16 -16
- net/CIDNet.py +2 -1
- requirements.txt +2 -1
- weights/LOL-Blur.pth +0 -3
- weights/LOLv1/BestLPIPS_0.0868.pth +0 -3
- weights/LOLv1/BestSSIM_0.8631.pth +0 -3
- weights/LOLv1/PSNR_24.74.pth +0 -3
- weights/LOLv1/w_perc.pth +0 -3
- weights/LOLv1/wo_perc.pth +0 -3
- weights/LOLv2_real/best_PSNR.pth +0 -3
- weights/LOLv2_real/best_SSIM.pth +0 -3
- weights/LOLv2_real/w_perc.pth +0 -3
- weights/LOLv2_syn/w_perc.pth +0 -3
- weights/LOLv2_syn/wo_perc.pth +0 -3
- weights/SICE.pth +0 -3
- weights/SID.pth +0 -3
- weights/generalization.pth +0 -3
app.py
CHANGED
@@ -9,6 +9,7 @@ import os
|
|
9 |
import imquality.brisque as brisque
|
10 |
from loss.niqe_utils import *
|
11 |
import spaces
|
|
|
12 |
|
13 |
eval_net = CIDNet().cuda()
|
14 |
eval_net.trans.gated = True
|
@@ -19,7 +20,8 @@ def process_image(input_img,score,model_path,gamma=1.0,alpha_s=1.0,alpha_i=1.0):
|
|
19 |
if model_path is None:
|
20 |
return input_img,"Please choose a model weights."
|
21 |
torch.set_grad_enabled(False)
|
22 |
-
eval_net.
|
|
|
23 |
eval_net.eval()
|
24 |
|
25 |
pil2tensor = transforms.Compose([transforms.ToTensor()])
|
@@ -44,23 +46,21 @@ def process_image(input_img,score,model_path,gamma=1.0,alpha_s=1.0,alpha_i=1.0):
|
|
44 |
else:
|
45 |
return enhanced_img,0
|
46 |
|
47 |
-
def find_pth_files(directory):
|
48 |
-
pth_files = []
|
49 |
-
for root, dirs, files in os.walk(directory):
|
50 |
-
if 'train' in root.split(os.sep):
|
51 |
-
continue
|
52 |
-
for file in files:
|
53 |
-
if file.endswith('.pth'):
|
54 |
-
pth_files.append(os.path.join(root, file))
|
55 |
-
return pth_files
|
56 |
-
|
57 |
-
def remove_weights_prefix(paths):
|
58 |
-
cleaned_paths = [path.replace('weights/', '') for path in paths]
|
59 |
-
return cleaned_paths
|
60 |
|
61 |
directory = "weights"
|
62 |
-
pth_files =
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
interface = gr.Interface(
|
66 |
fn=process_image,
|
|
|
9 |
import imquality.brisque as brisque
|
10 |
from loss.niqe_utils import *
|
11 |
import spaces
|
12 |
+
import huggingface_hub
|
13 |
|
14 |
eval_net = CIDNet().cuda()
|
15 |
eval_net.trans.gated = True
|
|
|
20 |
if model_path is None:
|
21 |
return input_img,"Please choose a model weights."
|
22 |
torch.set_grad_enabled(False)
|
23 |
+
eval_net.from_pretrained(model_path)
|
24 |
+
# eval_net.load_state_dict(torch.load(os.path.join(directory,model_path), map_location=lambda storage, loc: storage))
|
25 |
eval_net.eval()
|
26 |
|
27 |
pil2tensor = transforms.Compose([transforms.ToTensor()])
|
|
|
46 |
else:
|
47 |
return enhanced_img,0
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
directory = "weights"
|
51 |
+
pth_files = [
|
52 |
+
'HVI-CIDNet-Generalization',
|
53 |
+
'HVI-CIDNet-Sony-Total-Dark',
|
54 |
+
'HVI-CIDNet-LOL-Blur',
|
55 |
+
'HVI-CIDNet-SICE',
|
56 |
+
'HVI-CIDNet-LOLv2-real-bestSSIM',
|
57 |
+
'HVI-CIDNet-LOLv2-real-bestPSNR',
|
58 |
+
'HVI-CIDNet-LOLv2-syn-wperc',
|
59 |
+
'HVI-CIDNet-LOLv2-syn-woperc',
|
60 |
+
'HVI-CIDNet-LOLv1-wperc',
|
61 |
+
'HVI-CIDNet-LOLv1-woperc'
|
62 |
+
]
|
63 |
+
|
64 |
|
65 |
interface = gr.Interface(
|
66 |
fn=process_image,
|
net/CIDNet.py
CHANGED
@@ -5,8 +5,9 @@ from einops import rearrange
|
|
5 |
from net.HVI_transform import RGB_HVI
|
6 |
from net.transformer_utils import *
|
7 |
from net.LCA import *
|
|
|
8 |
|
9 |
-
class CIDNet(nn.Module):
|
10 |
def __init__(self,
|
11 |
channels=[36, 36, 72, 144],
|
12 |
heads=[1, 2, 4, 8],
|
|
|
5 |
from net.HVI_transform import RGB_HVI
|
6 |
from net.transformer_utils import *
|
7 |
from net.LCA import *
|
8 |
+
from huggingface_hub import PyTorchModelHubMixin
|
9 |
|
10 |
+
class CIDNet(nn.Module, PyTorchModelHubMixin):
|
11 |
def __init__(self,
|
12 |
channels=[36, 36, 72, 144],
|
13 |
heads=[1, 2, 4, 8],
|
requirements.txt
CHANGED
@@ -8,4 +8,5 @@ torchvision
|
|
8 |
einops
|
9 |
opencv-python
|
10 |
gradio
|
11 |
-
spaces
|
|
|
|
8 |
einops
|
9 |
opencv-python
|
10 |
gradio
|
11 |
+
spaces
|
12 |
+
huggingface_hub
|
weights/LOL-Blur.pth
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:eba53573097b4138be26ffc219826cf87eaeafbc0a6ae90cf4b35330070b5494
|
3 |
-
size 7971076
|
|
|
|
|
|
|
|
weights/LOLv1/BestLPIPS_0.0868.pth
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:533bec252359efc8f05720ce5a73c3a8c891384e62ba62b47b457b4a4c87247e
|
3 |
-
size 7971706
|
|
|
|
|
|
|
|
weights/LOLv1/BestSSIM_0.8631.pth
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:267ed28a7f65af87dd7bd6f486d88cfa25e654234badb974df7bc85dbf267ee3
|
3 |
-
size 7971706
|
|
|
|
|
|
|
|
weights/LOLv1/PSNR_24.74.pth
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:bb268bdf320d7236ba2e70c2b95e8c116d9766a3f3dbf4ccbbab1387228dfbf7
|
3 |
-
size 7971706
|
|
|
|
|
|
|
|
weights/LOLv1/w_perc.pth
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:9206385b514014b60bf9396151a011cabf68abb380c2ad87ffde3d53e8227926
|
3 |
-
size 7968002
|
|
|
|
|
|
|
|
weights/LOLv1/wo_perc.pth
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:2c5afb426fee910dd9806b4e6214f05914fb5988b7982a4624560815aefce2b5
|
3 |
-
size 7970627
|
|
|
|
|
|
|
|
weights/LOLv2_real/best_PSNR.pth
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:44a7f92cf02a1da322c1a34b3aa940341dc93fd53840b7f19b49f461200b00a6
|
3 |
-
size 7971269
|
|
|
|
|
|
|
|
weights/LOLv2_real/best_SSIM.pth
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:3d7ad3e93d65effaeb937cf833b1f2b3fb78c7529a4db95c589ff0ca569347c3
|
3 |
-
size 7971269
|
|
|
|
|
|
|
|
weights/LOLv2_real/w_perc.pth
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:1e0affc8ce89cceeb283dfa3ce7108c767cefc6f59826da37ec4c39482839db8
|
3 |
-
size 7967682
|
|
|
|
|
|
|
|
weights/LOLv2_syn/w_perc.pth
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:460a9956018935cab61ddef3cea14f1dbbc02a65e12ee4d5b5ab45d704d2575b
|
3 |
-
size 7967682
|
|
|
|
|
|
|
|
weights/LOLv2_syn/wo_perc.pth
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:519cc5fc55491cf36b47b8295c0204dde29ba887feeed06a77e716072469e55e
|
3 |
-
size 7974353
|
|
|
|
|
|
|
|
weights/SICE.pth
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:7b0824026124427fe0419465fc06a6be0129356c949794d1d1f52c4173091607
|
3 |
-
size 7964800
|
|
|
|
|
|
|
|
weights/SID.pth
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:49678f69495610a2691bb5b2665d2766b57a6a79201a236f7afa84f67c5fec5f
|
3 |
-
size 7964543
|
|
|
|
|
|
|
|
weights/generalization.pth
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:6395370762ec1fa0f6fe92a38c62382b1ebe21edc012f597023bfcec8b95cd27
|
3 |
-
size 7971462
|
|
|
|
|
|
|
|