Spaces:
Sleeping
Sleeping
add gaussianblur
Browse files
evals.py
CHANGED
|
@@ -36,7 +36,8 @@ DEFAULT_MODEL_PARAMS = {
|
|
| 36 |
|
| 37 |
class PhysicsWithGenerator(torch.nn.Module):
|
| 38 |
"""Interface between Physics, Generator and Gradio."""
|
| 39 |
-
all_physics = ["MotionBlur_easy", "MotionBlur_medium", "MotionBlur_hard",
|
|
|
|
| 40 |
"MRI", "CT"]
|
| 41 |
|
| 42 |
def __init__(self, physics_name: str, device_str: str = "cpu") -> None:
|
|
@@ -77,16 +78,44 @@ class PhysicsWithGenerator(torch.nn.Module):
|
|
| 77 |
"updatable_params_converter": {"sigma": float},
|
| 78 |
"fixed_params": {"noise_sigma_min": 0.1, "noise_sigma_max": 0.1,
|
| 79 |
"psf_size": 31, "motion_gen_l": 1.2, "motion_gen_s": 1.0}}
|
| 80 |
-
elif self.name == "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
psf_size = 31
|
| 82 |
self.physics = dinv.physics.Blur(noise_model=dinv.physics.GaussianNoise(sigma=0.05), padding="valid",
|
| 83 |
device=device_str)
|
| 84 |
-
self.physics_generator = GaussianBlurGenerator(psf_size=(psf_size, psf_size),
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
"psf_size": 31, "num_channels": 1}}
|
| 91 |
elif self.name == "MRI":
|
| 92 |
self.physics = dinv.physics.MRI(img_size=(640, 320), noise_model=dinv.physics.GaussianNoise(sigma=.01),
|
|
|
|
| 36 |
|
| 37 |
class PhysicsWithGenerator(torch.nn.Module):
|
| 38 |
"""Interface between Physics, Generator and Gradio."""
|
| 39 |
+
all_physics = ["MotionBlur_easy", "MotionBlur_medium", "MotionBlur_hard",
|
| 40 |
+
"GaussianBlur_easy", "GaussianBlur_medium", "GaussianBlur_hard",
|
| 41 |
"MRI", "CT"]
|
| 42 |
|
| 43 |
def __init__(self, physics_name: str, device_str: str = "cpu") -> None:
|
|
|
|
| 78 |
"updatable_params_converter": {"sigma": float},
|
| 79 |
"fixed_params": {"noise_sigma_min": 0.1, "noise_sigma_max": 0.1,
|
| 80 |
"psf_size": 31, "motion_gen_l": 1.2, "motion_gen_s": 1.0}}
|
| 81 |
+
elif self.name == "GaussianBlur_easy":
|
| 82 |
+
psf_size = 31
|
| 83 |
+
self.physics = dinv.physics.Blur(noise_model=dinv.physics.GaussianNoise(sigma=0.01), padding="valid",
|
| 84 |
+
device=device_str)
|
| 85 |
+
self.physics_generator = GaussianBlurGenerator(psf_size=(psf_size, psf_size),
|
| 86 |
+
sigma_min=1.0, sigma_max=1.0,
|
| 87 |
+
num_channels=1,
|
| 88 |
+
device=device_str) + SigmaGenerator(sigma_min=0.01, sigma_max=0.01, device=device_str)
|
| 89 |
+
self.generator = self.physics_generator
|
| 90 |
+
self.saved_params = {"updatable_params": {},
|
| 91 |
+
"updatable_params_converter": {},
|
| 92 |
+
"fixed_params": {"noise_sigma": 0.01, "blur_sigma": 1.0,
|
| 93 |
+
"psf_size": 31, "num_channels": 1}}
|
| 94 |
+
elif self.name == "GaussianBlur_medium":
|
| 95 |
psf_size = 31
|
| 96 |
self.physics = dinv.physics.Blur(noise_model=dinv.physics.GaussianNoise(sigma=0.05), padding="valid",
|
| 97 |
device=device_str)
|
| 98 |
+
self.physics_generator = GaussianBlurGenerator(psf_size=(psf_size, psf_size),
|
| 99 |
+
sigma_min=2.0, sigma_max=2.0,
|
| 100 |
+
num_channels=1,
|
| 101 |
+
device=device_str) + SigmaGenerator(sigma_min=0.05, sigma_max=0.05, device=device_str)
|
| 102 |
+
self.generator = self.physics_generator
|
| 103 |
+
self.saved_params = {"updatable_params": {},
|
| 104 |
+
"updatable_params_converter": {},
|
| 105 |
+
"fixed_params": {"noise_sigma": 0.05, "blur_sigma": 2.0,
|
| 106 |
+
"psf_size": 31, "num_channels": 1}}
|
| 107 |
+
elif self.name == "GaussianBlur_hard":
|
| 108 |
+
psf_size = 31
|
| 109 |
+
self.physics = dinv.physics.Blur(noise_model=dinv.physics.GaussianNoise(sigma=0.05), padding="valid",
|
| 110 |
+
device=device_str)
|
| 111 |
+
self.physics_generator = GaussianBlurGenerator(psf_size=(psf_size, psf_size),
|
| 112 |
+
sigma_min=4.0, sigma_max=4.0,
|
| 113 |
+
num_channels=1,
|
| 114 |
+
device=device_str) + SigmaGenerator(sigma_min=0.1, sigma_max=0.1, device=device_str)
|
| 115 |
+
self.generator = self.physics_generator
|
| 116 |
+
self.saved_params = {"updatable_params": {},
|
| 117 |
+
"updatable_params_converter": {},
|
| 118 |
+
"fixed_params": {"noise_sigma": 0.1, "blur_sigma": 4.0,
|
| 119 |
"psf_size": 31, "num_channels": 1}}
|
| 120 |
elif self.name == "MRI":
|
| 121 |
self.physics = dinv.physics.MRI(img_size=(640, 320), noise_model=dinv.physics.GaussianNoise(sigma=.01),
|