Spaces:
Running
on
Zero
Running
on
Zero
fix: brisque
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ eval_net.trans.gated2 = True
|
|
15 |
|
16 |
def process_image(input_img,score,model_path,gamma=1.0,alpha_s=1.0,alpha_i=1.0):
|
17 |
if model_path is None:
|
18 |
-
return input_img,"Please choose a model weights."
|
19 |
torch.set_grad_enabled(False)
|
20 |
eval_net.load_state_dict(torch.load(os.path.join(directory,model_path), map_location=lambda storage, loc: storage))
|
21 |
eval_net.eval()
|
@@ -36,13 +36,11 @@ def process_image(input_img,score,model_path,gamma=1.0,alpha_s=1.0,alpha_i=1.0):
|
|
36 |
output = output[:, :, :h, :w]
|
37 |
enhanced_img = transforms.ToPILImage()(output.squeeze(0))
|
38 |
if score == 'Yes':
|
39 |
-
im1 = enhanced_img
|
40 |
-
# score_brisque = brisque.score(im1)
|
41 |
-
im1 = np.array(im1)
|
42 |
score_niqe = calculate_niqe(im1)
|
43 |
-
return enhanced_img,score_niqe
|
44 |
else:
|
45 |
-
return enhanced_img,0
|
46 |
|
47 |
def find_pth_files(directory):
|
48 |
pth_files = []
|
@@ -74,8 +72,7 @@ interface = gr.Interface(
|
|
74 |
],
|
75 |
outputs=[
|
76 |
gr.Image(label="Result", type="pil"),
|
77 |
-
gr.Textbox(label="NIQE")
|
78 |
-
gr.Textbox(label="BRISQUE")
|
79 |
],
|
80 |
title="HVI-CIDNet (Low-Light Image Enhancement)",
|
81 |
description="The demo of paper \"You Only Need One Color Space: An Efficient Network for Low-light Image Enhancement\"",
|
|
|
15 |
|
16 |
def process_image(input_img,score,model_path,gamma=1.0,alpha_s=1.0,alpha_i=1.0):
|
17 |
if model_path is None:
|
18 |
+
return input_img,"Please choose a model weights."
|
19 |
torch.set_grad_enabled(False)
|
20 |
eval_net.load_state_dict(torch.load(os.path.join(directory,model_path), map_location=lambda storage, loc: storage))
|
21 |
eval_net.eval()
|
|
|
36 |
output = output[:, :, :h, :w]
|
37 |
enhanced_img = transforms.ToPILImage()(output.squeeze(0))
|
38 |
if score == 'Yes':
|
39 |
+
im1 = np.array(enhanced_img)
|
|
|
|
|
40 |
score_niqe = calculate_niqe(im1)
|
41 |
+
return enhanced_img,score_niqe
|
42 |
else:
|
43 |
+
return enhanced_img,0
|
44 |
|
45 |
def find_pth_files(directory):
|
46 |
pth_files = []
|
|
|
72 |
],
|
73 |
outputs=[
|
74 |
gr.Image(label="Result", type="pil"),
|
75 |
+
gr.Textbox(label="NIQE")
|
|
|
76 |
],
|
77 |
title="HVI-CIDNet (Low-Light Image Enhancement)",
|
78 |
description="The demo of paper \"You Only Need One Color Space: An Efficient Network for Low-light Image Enhancement\"",
|