keeper commited on
Commit
1d2efde
β€’
1 Parent(s): b425697
.gitattributes DELETED
@@ -1,34 +0,0 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tflite filter=lfs diff=lfs merge=lfs -text
29
- *.tgz filter=lfs diff=lfs merge=lfs -text
30
- *.wasm filter=lfs diff=lfs merge=lfs -text
31
- *.xz filter=lfs diff=lfs merge=lfs -text
32
- *.zip filter=lfs diff=lfs merge=lfs -text
33
- *.zst filter=lfs diff=lfs merge=lfs -text
34
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.idea/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- # Default ignored files
2
- /shelf/
3
- /workspace.xml
4
- # Editor-based HTTP Client requests
5
- /httpRequests/
6
- # Datasource local storage ignored files
7
- /dataSources/
8
- /dataSources.local.xml
 
 
 
 
 
 
 
 
 
.idea/Image_Restoration.iml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="PYTHON_MODULE" version="4">
3
- <component name="NewModuleRootManager">
4
- <content url="file://$MODULE_DIR$" />
5
- <orderEntry type="inheritedJdk" />
6
- <orderEntry type="sourceFolder" forTests="false" />
7
- </component>
8
- </module>
 
 
 
 
 
 
 
 
 
.idea/deployment.xml CHANGED
@@ -23,6 +23,13 @@
23
  </mappings>
24
  </serverdata>
25
  </paths>
 
 
 
 
 
 
 
26
  <paths name="N2N">
27
  <serverdata>
28
  <mappings>
 
23
  </mappings>
24
  </serverdata>
25
  </paths>
26
+ <paths name="Image_Restoration">
27
+ <serverdata>
28
+ <mappings>
29
+ <mapping deploy="/" local="$PROJECT_DIR$" web="/" />
30
+ </mappings>
31
+ </serverdata>
32
+ </paths>
33
  <paths name="N2N">
34
  <serverdata>
35
  <mappings>
.idea/inspectionProfiles/Project_Default.xml DELETED
@@ -1,45 +0,0 @@
1
- <component name="InspectionProjectProfileManager">
2
- <profile version="1.0">
3
- <option name="myName" value="Project Default" />
4
- <inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
5
- <option name="ignoredPackages">
6
- <value>
7
- <list size="25">
8
- <item index="0" class="java.lang.String" itemvalue="tensorboard" />
9
- <item index="1" class="java.lang.String" itemvalue="pytorch" />
10
- <item index="2" class="java.lang.String" itemvalue="hdf5" />
11
- <item index="3" class="java.lang.String" itemvalue="cv2" />
12
- <item index="4" class="java.lang.String" itemvalue="torch" />
13
- <item index="5" class="java.lang.String" itemvalue="numpy" />
14
- <item index="6" class="java.lang.String" itemvalue="torchvision" />
15
- <item index="7" class="java.lang.String" itemvalue="argparse" />
16
- <item index="8" class="java.lang.String" itemvalue="dlib" />
17
- <item index="9" class="java.lang.String" itemvalue="Pillow" />
18
- <item index="10" class="java.lang.String" itemvalue="opencv-python" />
19
- <item index="11" class="java.lang.String" itemvalue="pandas" />
20
- <item index="12" class="java.lang.String" itemvalue="protobuf" />
21
- <item index="13" class="java.lang.String" itemvalue="seaborn" />
22
- <item index="14" class="java.lang.String" itemvalue="thop" />
23
- <item index="15" class="java.lang.String" itemvalue="condac" />
24
- <item index="16" class="java.lang.String" itemvalue="matplotlib" />
25
- <item index="17" class="java.lang.String" itemvalue="tqdm" />
26
- <item index="18" class="java.lang.String" itemvalue="natsort" />
27
- <item index="19" class="java.lang.String" itemvalue="scikit_image" />
28
- <item index="20" class="java.lang.String" itemvalue="opencv_python_headless" />
29
- <item index="21" class="java.lang.String" itemvalue="tensorboardX" />
30
- <item index="22" class="java.lang.String" itemvalue="lpips" />
31
- <item index="23" class="java.lang.String" itemvalue="skimage" />
32
- <item index="24" class="java.lang.String" itemvalue="tensorflow" />
33
- </list>
34
- </value>
35
- </option>
36
- </inspection_tool>
37
- <inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true">
38
- <option name="ignoredIdentifiers">
39
- <list>
40
- <option value="PYQt5" />
41
- </list>
42
- </option>
43
- </inspection_tool>
44
- </profile>
45
- </component>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.idea/inspectionProfiles/profiles_settings.xml DELETED
@@ -1,6 +0,0 @@
1
- <component name="InspectionProjectProfileManager">
2
- <settings>
3
- <option name="USE_PROJECT_PROFILE" value="false" />
4
- <version value="1.0" />
5
- </settings>
6
- </component>
 
 
 
 
 
 
 
.idea/misc.xml DELETED
@@ -1,4 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
4
- </project>
 
 
 
 
 
.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/Image_Restoration.iml" filepath="$PROJECT_DIR$/.idea/Image_Restoration.iml" />
6
- </modules>
7
- </component>
8
- </project>
 
 
 
 
 
 
 
 
 
.idea/remote-mappings.xml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="RemoteMappingsManager">
4
+ <list>
5
+ <list>
6
+ <remote-mappings server-id="python@sftp://water@192.168.3.132:22/usr/local/bin/miniconda3/envs/Pro/bin/python">
7
+ <settings>
8
+ <list>
9
+ <mapping local-root="$PROJECT_DIR$" remote-root="/home/water/HSS/Image_Restoratiom" />
10
+ </list>
11
+ </settings>
12
+ </remote-mappings>
13
+ </list>
14
+ </list>
15
+ </component>
16
+ </project>
.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
- </component>
6
- </project>
 
 
 
 
 
 
 
.idea/webServers.xml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="WebServers">
4
+ <option name="servers">
5
+ <webServer id="2800bc41-c279-4755-a3e1-ee0ae86a7ee9" name="Image_Restoration">
6
+ <fileTransfer rootFolder="/home/water/HSS/Image_Restoratiom" accessType="SFTP" host="192.168.3.132" port="22" sshConfigId="4b8a29b2-50f2-4642-83d7-5355294ef68e" sshConfig="water@192.168.3.132:22 password">
7
+ <advancedOptions>
8
+ <advancedOptions dataProtectionLevel="Private" passiveMode="true" shareSSLContext="true" />
9
+ </advancedOptions>
10
+ </fileTransfer>
11
+ </webServer>
12
+ </option>
13
+ </component>
14
+ </project>
.idea/workspace.xml ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ChangeListManager">
4
+ <list default="true" id="4d53ddea-ecd0-430e-ba7d-7fc01a47d7d2" name="Changes" comment="">
5
+ <change beforePath="$PROJECT_DIR$/.gitattributes" beforeDir="false" />
6
+ <change beforePath="$PROJECT_DIR$/.idea/.gitignore" beforeDir="false" />
7
+ <change beforePath="$PROJECT_DIR$/.idea/Image_Restoration.iml" beforeDir="false" />
8
+ <change beforePath="$PROJECT_DIR$/.idea/deployment.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/deployment.xml" afterDir="false" />
9
+ <change beforePath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" beforeDir="false" />
10
+ <change beforePath="$PROJECT_DIR$/.idea/inspectionProfiles/profiles_settings.xml" beforeDir="false" />
11
+ <change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" />
12
+ <change beforePath="$PROJECT_DIR$/.idea/modules.xml" beforeDir="false" />
13
+ <change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" />
14
+ <change beforePath="$PROJECT_DIR$/LowLight.py" beforeDir="false" afterPath="$PROJECT_DIR$/LowLight.py" afterDir="false" />
15
+ <change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" />
16
+ <change beforePath="$PROJECT_DIR$/app.py" beforeDir="false" afterPath="$PROJECT_DIR$/app.py" afterDir="false" />
17
+ <change beforePath="$PROJECT_DIR$/checkpoints/Epoch99.pth" beforeDir="false" afterPath="$PROJECT_DIR$/checkpoints/LowLight_model.pth" afterDir="false" />
18
+ <change beforePath="$PROJECT_DIR$/demo/Underwater.png" beforeDir="false" />
19
+ <change beforePath="$PROJECT_DIR$/demo/Underwater2.png" beforeDir="false" />
20
+ <change beforePath="$PROJECT_DIR$/demo/X-ray_image.png" beforeDir="false" />
21
+ <change beforePath="$PROJECT_DIR$/demo/X-ray_image2.png" beforeDir="false" />
22
+ <change beforePath="$PROJECT_DIR$/model/Denoising_NAF.py" beforeDir="false" />
23
+ <change beforePath="$PROJECT_DIR$/model/LowLight_HWMNet.py" beforeDir="false" afterPath="$PROJECT_DIR$/model/LowLight_model.py" afterDir="false" />
24
+ <change beforePath="$PROJECT_DIR$/utils/WT/__init__.py" beforeDir="false" />
25
+ <change beforePath="$PROJECT_DIR$/utils/WT/transform.py" beforeDir="false" />
26
+ </list>
27
+ <option name="SHOW_DIALOG" value="false" />
28
+ <option name="HIGHLIGHT_CONFLICTS" value="true" />
29
+ <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
30
+ <option name="LAST_RESOLUTION" value="IGNORE" />
31
+ </component>
32
+ <component name="FlaskConsoleOptions" custom-start-script="import sys&#10;sys.path.extend([WORKING_DIR_AND_PYTHON_PATHS])&#10;from flask.cli import ScriptInfo&#10;locals().update(ScriptInfo(create_app=None).load_app().make_shell_context())&#10;print(&quot;Python %s on %s\nApp: %s [%s]\nInstance: %s&quot; % (sys.version, sys.platform, app.import_name, app.env, app.instance_path))">
33
+ <envs>
34
+ <env key="FLASK_APP" value="app" />
35
+ </envs>
36
+ <option name="myCustomStartScript" value="import sys&#10;sys.path.extend([WORKING_DIR_AND_PYTHON_PATHS])&#10;from flask.cli import ScriptInfo&#10;locals().update(ScriptInfo(create_app=None).load_app().make_shell_context())&#10;print(&quot;Python %s on %s\nApp: %s [%s]\nInstance: %s&quot; % (sys.version, sys.platform, app.import_name, app.env, app.instance_path))" />
37
+ <option name="myEnvs">
38
+ <map>
39
+ <entry key="FLASK_APP" value="app" />
40
+ </map>
41
+ </option>
42
+ </component>
43
+ <component name="Git.Settings">
44
+ <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
45
+ </component>
46
+ <component name="ProjectId" id="2QmiU2cpzs07TPd8whgwy3MwnH7" />
47
+ <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
48
+ <component name="ProjectViewState">
49
+ <option name="hideEmptyMiddlePackages" value="true" />
50
+ <option name="showLibraryContents" value="true" />
51
+ </component>
52
+ <component name="PropertiesComponent">
53
+ <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
54
+ <property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
55
+ <property name="WebServerToolWindowFactoryState" value="true" />
56
+ <property name="WebServerToolWindowPanel.toolwindow.highlight.mappings" value="true" />
57
+ <property name="WebServerToolWindowPanel.toolwindow.highlight.symlinks" value="true" />
58
+ <property name="WebServerToolWindowPanel.toolwindow.show.date" value="false" />
59
+ <property name="WebServerToolWindowPanel.toolwindow.show.permissions" value="false" />
60
+ <property name="WebServerToolWindowPanel.toolwindow.show.size" value="false" />
61
+ <property name="last_opened_file_path" value="$PROJECT_DIR$" />
62
+ <property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" />
63
+ </component>
64
+ <component name="RecentsManager">
65
+ <key name="CopyFile.RECENT_KEYS">
66
+ <recent name="D:\LZ\Image_Restoration\utils" />
67
+ <recent name="D:\LZ\Image_Restoration\model" />
68
+ <recent name="D:\LZ\Image_Restoration\demo" />
69
+ </key>
70
+ <key name="MoveFile.RECENT_KEYS">
71
+ <recent name="D:\LZ\Image_Restoration\demo" />
72
+ <recent name="D:\LZ\Image_Restoration\checkpoints" />
73
+ </key>
74
+ </component>
75
+ <component name="RunManager" selected="Python.app">
76
+ <configuration name="LowLight" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
77
+ <module name="Image_Restoration" />
78
+ <option name="INTERPRETER_OPTIONS" value="" />
79
+ <option name="PARENT_ENVS" value="true" />
80
+ <envs>
81
+ <env name="PYTHONUNBUFFERED" value="1" />
82
+ </envs>
83
+ <option name="SDK_HOME" value="" />
84
+ <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
85
+ <option name="IS_MODULE_SDK" value="true" />
86
+ <option name="ADD_CONTENT_ROOTS" value="true" />
87
+ <option name="ADD_SOURCE_ROOTS" value="true" />
88
+ <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
89
+ <option name="SCRIPT_NAME" value="$PROJECT_DIR$/LowLight.py" />
90
+ <option name="PARAMETERS" value="" />
91
+ <option name="SHOW_COMMAND_LINE" value="false" />
92
+ <option name="EMULATE_TERMINAL" value="false" />
93
+ <option name="MODULE_MODE" value="false" />
94
+ <option name="REDIRECT_INPUT" value="false" />
95
+ <option name="INPUT_FILE" value="" />
96
+ <method v="2" />
97
+ </configuration>
98
+ <configuration name="app" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
99
+ <module name="Image_Restoration" />
100
+ <option name="INTERPRETER_OPTIONS" value="" />
101
+ <option name="PARENT_ENVS" value="true" />
102
+ <envs>
103
+ <env name="PYTHONUNBUFFERED" value="1" />
104
+ </envs>
105
+ <option name="SDK_HOME" value="" />
106
+ <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
107
+ <option name="IS_MODULE_SDK" value="true" />
108
+ <option name="ADD_CONTENT_ROOTS" value="true" />
109
+ <option name="ADD_SOURCE_ROOTS" value="true" />
110
+ <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
111
+ <option name="SCRIPT_NAME" value="$PROJECT_DIR$/app.py" />
112
+ <option name="PARAMETERS" value="" />
113
+ <option name="SHOW_COMMAND_LINE" value="false" />
114
+ <option name="EMULATE_TERMINAL" value="false" />
115
+ <option name="MODULE_MODE" value="false" />
116
+ <option name="REDIRECT_INPUT" value="false" />
117
+ <option name="INPUT_FILE" value="" />
118
+ <method v="2" />
119
+ </configuration>
120
+ <recent_temporary>
121
+ <list>
122
+ <item itemvalue="Python.app" />
123
+ <item itemvalue="Python.LowLight" />
124
+ </list>
125
+ </recent_temporary>
126
+ </component>
127
+ <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
128
+ <component name="TaskManager">
129
+ <task active="true" id="Default" summary="Default task">
130
+ <changelist id="4d53ddea-ecd0-430e-ba7d-7fc01a47d7d2" name="Changes" comment="" />
131
+ <created>1685965188306</created>
132
+ <option name="number" value="Default" />
133
+ <option name="presentableId" value="Default" />
134
+ <updated>1685965188306</updated>
135
+ <workItem from="1685965211267" duration="5654000" />
136
+ <workItem from="1687838183420" duration="2062000" />
137
+ </task>
138
+ <servers />
139
+ </component>
140
+ <component name="TypeScriptGeneratedFilesManager">
141
+ <option name="version" value="3" />
142
+ </component>
143
+ <component name="Vcs.Log.Tabs.Properties">
144
+ <option name="TAB_STATES">
145
+ <map>
146
+ <entry key="MAIN">
147
+ <value>
148
+ <State>
149
+ <option name="FILTERS">
150
+ <map>
151
+ <entry key="branch">
152
+ <value>
153
+ <list>
154
+ <option value="origin/main" />
155
+ </list>
156
+ </value>
157
+ </entry>
158
+ </map>
159
+ </option>
160
+ </State>
161
+ </value>
162
+ </entry>
163
+ </map>
164
+ </option>
165
+ <option name="oldMeFiltersMigrated" value="true" />
166
+ </component>
167
+ <component name="XDebuggerManager">
168
+ <breakpoint-manager>
169
+ <breakpoints>
170
+ <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
171
+ <url>file://$PROJECT_DIR$/model/LowLight_model.py</url>
172
+ <line>5</line>
173
+ <option name="timeStamp" value="1" />
174
+ </line-breakpoint>
175
+ </breakpoints>
176
+ </breakpoint-manager>
177
+ </component>
178
+ <component name="com.intellij.coverage.CoverageDataManagerImpl">
179
+ <SUITE FILE_PATH="coverage/Image_Restoration$LowLight.coverage" NAME="LowLight Coverage Results" MODIFIED="1687848907418" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
180
+ <SUITE FILE_PATH="coverage/Image_Restoration$app.coverage" NAME="app Coverage Results" MODIFIED="1687849248145" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
181
+ </component>
182
+ </project>
LowLight.py CHANGED
@@ -9,19 +9,17 @@ import cv2
9
  import torchvision.utils as tvu
10
  import torch.functional as F
11
  import argparse
12
- from model.LowLight_HWMNet import network
13
 
14
  def inference_img(img_path,Net):
15
 
16
  low_image = Image.open(img_path).convert('RGB')
17
 
18
  # preprocess input image
19
- data_lowlight = (np.asarray(data_lowlight)/255.0)
20
-
21
-
22
- data_lowlight = torch.from_numpy(data_lowlight).float()
23
- data_lowlight = data_lowlight.permute(2,0,1)
24
- data_lowlight = data_lowlight.cuda().unsqueeze(0)
25
 
26
  with torch.no_grad():
27
  start = time.time()
@@ -35,7 +33,7 @@ if __name__ == '__main__':
35
  parser=argparse.ArgumentParser()
36
  parser.add_argument('--test_path',type=str,required=True,help='Path to test')
37
  parser.add_argument('--save_path',type=str,required=True,help='Path to save')
38
- parser.add_argument('--checkpoint',type=str,default='checkpoints/enhancement_model.pth',help='Path of the checkpoint')
39
  opt = parser.parse_args()
40
  if not os.path.isdir(opt.save_path):
41
  os.mkdir(opt.save_path)
 
9
  import torchvision.utils as tvu
10
  import torch.functional as F
11
  import argparse
12
+ from model.LowLight_model import network
13
 
14
  def inference_img(img_path,Net):
15
 
16
  low_image = Image.open(img_path).convert('RGB')
17
 
18
  # preprocess input image
19
+ data_lowlight = (np.asarray(low_image)/255.0)
20
+ data_lowlight = torch.from_numpy(data_lowlight).float()
21
+ data_lowlight = data_lowlight.permute(2,0,1)
22
+ low_image = data_lowlight.cuda().unsqueeze(0)
 
 
23
 
24
  with torch.no_grad():
25
  start = time.time()
 
33
  parser=argparse.ArgumentParser()
34
  parser.add_argument('--test_path',type=str,required=True,help='Path to test')
35
  parser.add_argument('--save_path',type=str,required=True,help='Path to save')
36
+ parser.add_argument('--checkpoint',type=str,default='checkpoints/LowLight_model.pth',help='Path of the checkpoint')
37
  opt = parser.parse_args()
38
  if not os.path.isdir(opt.save_path):
39
  os.mkdir(opt.save_path)
README.md DELETED
@@ -1,13 +0,0 @@
1
- ---
2
- title: Image Restoration
3
- emoji: πŸ“‰
4
- colorFrom: red
5
- colorTo: gray
6
- sdk: gradio
7
- sdk_version: 3.33.1
8
- app_file: app.py
9
- pinned: false
10
- license: openrail
11
- ---
12
-
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app.py CHANGED
@@ -52,7 +52,7 @@ iface = gr.Interface(
52
  enable_queue=True,
53
  examples=examples
54
  )
55
- iface.launch(debug=True,enable_queue=True)
56
 
57
 
58
  # iface = gr.Interface(
 
52
  enable_queue=True,
53
  examples=examples
54
  )
55
+ iface.launch(debug=True,enable_queue=True,share=True)
56
 
57
 
58
  # iface = gr.Interface(
checkpoints/{Epoch99.pth β†’ LowLight_model.pth} RENAMED
File without changes
demo/Underwater.png DELETED
Binary file (79.6 kB)
 
demo/Underwater2.png DELETED
Binary file (117 kB)
 
demo/X-ray_image.png DELETED
Binary file (359 kB)
 
demo/X-ray_image2.png DELETED
Binary file (591 kB)
 
model/Denoising_NAF.py DELETED
@@ -1,202 +0,0 @@
1
- # ------------------------------------------------------------------------
2
- # Copyright (c) 2022 megvii-model. All Rights Reserved.
3
- # ------------------------------------------------------------------------
4
-
5
- '''
6
- Simple Baselines for Image Restoration
7
-
8
- @article{chen2022simple,
9
- title={Simple Baselines for Image Restoration},
10
- author={Chen, Liangyu and Chu, Xiaojie and Zhang, Xiangyu and Sun, Jian},
11
- journal={arXiv preprint arXiv:2204.04676},
12
- year={2022}
13
- }
14
- '''
15
-
16
- import torch
17
- import torch.nn as nn
18
- import torch.nn.functional as F
19
- from model.arch_util import LayerNorm2d
20
- from model.local_arch import Local_Base
21
-
22
- class SimpleGate(nn.Module):
23
- def forward(self, x):
24
- x1, x2 = x.chunk(2, dim=1)
25
- return x1 * x2
26
-
27
- class NAFBlock(nn.Module):
28
- def __init__(self, c, DW_Expand=2, FFN_Expand=2, drop_out_rate=0.):
29
- super().__init__()
30
- dw_channel = c * DW_Expand
31
- self.conv1 = nn.Conv2d(in_channels=c, out_channels=dw_channel, kernel_size=1, padding=0, stride=1, groups=1, bias=True)
32
- self.conv2 = nn.Conv2d(in_channels=dw_channel, out_channels=dw_channel, kernel_size=3, padding=1, stride=1, groups=dw_channel,
33
- bias=True)
34
- self.conv3 = nn.Conv2d(in_channels=dw_channel // 2, out_channels=c, kernel_size=1, padding=0, stride=1, groups=1, bias=True)
35
-
36
- # Simplified Channel Attention
37
- self.sca = nn.Sequential(
38
- nn.AdaptiveAvgPool2d(1),
39
- nn.Conv2d(in_channels=dw_channel // 2, out_channels=dw_channel // 2, kernel_size=1, padding=0, stride=1,
40
- groups=1, bias=True),
41
- )
42
-
43
- # SimpleGate
44
- self.sg = SimpleGate()
45
-
46
- ffn_channel = FFN_Expand * c
47
- self.conv4 = nn.Conv2d(in_channels=c, out_channels=ffn_channel, kernel_size=1, padding=0, stride=1, groups=1, bias=True)
48
- self.conv5 = nn.Conv2d(in_channels=ffn_channel // 2, out_channels=c, kernel_size=1, padding=0, stride=1, groups=1, bias=True)
49
-
50
- self.norm1 = LayerNorm2d(c)
51
- self.norm2 = LayerNorm2d(c)
52
-
53
- self.dropout1 = nn.Dropout(drop_out_rate) if drop_out_rate > 0. else nn.Identity()
54
- self.dropout2 = nn.Dropout(drop_out_rate) if drop_out_rate > 0. else nn.Identity()
55
-
56
- self.beta = nn.Parameter(torch.zeros((1, c, 1, 1)), requires_grad=True)
57
- self.gamma = nn.Parameter(torch.zeros((1, c, 1, 1)), requires_grad=True)
58
-
59
- def forward(self, inp):
60
- x = inp
61
-
62
- x = self.norm1(x)
63
-
64
- x = self.conv1(x)
65
- x = self.conv2(x)
66
- x = self.sg(x)
67
- x = x * self.sca(x)
68
- x = self.conv3(x)
69
-
70
- x = self.dropout1(x)
71
-
72
- y = inp + x * self.beta
73
-
74
- x = self.conv4(self.norm2(y))
75
- x = self.sg(x)
76
- x = self.conv5(x)
77
-
78
- x = self.dropout2(x)
79
-
80
- return y + x * self.gamma
81
-
82
-
83
- class NAFNet(nn.Module):
84
-
85
- def __init__(self, img_channel=3, width=16, middle_blk_num=1, enc_blk_nums=[], dec_blk_nums=[]):
86
- super().__init__()
87
-
88
- self.intro = nn.Conv2d(in_channels=img_channel, out_channels=width, kernel_size=3, padding=1, stride=1, groups=1,
89
- bias=True)
90
- self.ending = nn.Conv2d(in_channels=width, out_channels=img_channel, kernel_size=3, padding=1, stride=1, groups=1,
91
- bias=True)
92
-
93
- self.encoders = nn.ModuleList()
94
- self.decoders = nn.ModuleList()
95
- self.middle_blks = nn.ModuleList()
96
- self.ups = nn.ModuleList()
97
- self.downs = nn.ModuleList()
98
-
99
- chan = width
100
- for num in enc_blk_nums:
101
- self.encoders.append(
102
- nn.Sequential(
103
- *[NAFBlock(chan) for _ in range(num)]
104
- )
105
- )
106
- self.downs.append(
107
- nn.Conv2d(chan, 2*chan, 2, 2)
108
- )
109
- chan = chan * 2
110
-
111
- self.middle_blks = \
112
- nn.Sequential(
113
- *[NAFBlock(chan) for _ in range(middle_blk_num)]
114
- )
115
-
116
- for num in dec_blk_nums:
117
- self.ups.append(
118
- nn.Sequential(
119
- nn.Conv2d(chan, chan * 2, 1, bias=False),
120
- nn.PixelShuffle(2)
121
- )
122
- )
123
- chan = chan // 2
124
- self.decoders.append(
125
- nn.Sequential(
126
- *[NAFBlock(chan) for _ in range(num)]
127
- )
128
- )
129
-
130
- self.padder_size = 2 ** len(self.encoders)
131
-
132
- def forward(self, inp):
133
- B, C, H, W = inp.shape
134
- inp = self.check_image_size(inp)
135
-
136
- x = self.intro(inp)
137
-
138
- encs = []
139
-
140
- for encoder, down in zip(self.encoders, self.downs):
141
- x = encoder(x)
142
- encs.append(x)
143
- x = down(x)
144
-
145
- x = self.middle_blks(x)
146
-
147
- for decoder, up, enc_skip in zip(self.decoders, self.ups, encs[::-1]):
148
- x = up(x)
149
- x = x + enc_skip
150
- x = decoder(x)
151
-
152
- x = self.ending(x)
153
- x = x + inp
154
-
155
- return x[:, :, :H, :W]
156
-
157
- def check_image_size(self, x):
158
- _, _, h, w = x.size()
159
- mod_pad_h = (self.padder_size - h % self.padder_size) % self.padder_size
160
- mod_pad_w = (self.padder_size - w % self.padder_size) % self.padder_size
161
- x = F.pad(x, (0, mod_pad_w, 0, mod_pad_h))
162
- return x
163
-
164
- class NAFNetLocal(Local_Base, NAFNet):
165
- def __init__(self, *args, train_size=(1, 3, 256, 256), fast_imp=False, **kwargs):
166
- Local_Base.__init__(self)
167
- NAFNet.__init__(self, *args, **kwargs)
168
-
169
- N, C, H, W = train_size
170
- base_size = (int(H * 1.5), int(W * 1.5))
171
-
172
- self.eval()
173
- with torch.no_grad():
174
- self.convert(base_size=base_size, train_size=train_size, fast_imp=fast_imp)
175
-
176
-
177
- if __name__ == '__main__':
178
- img_channel = 3
179
- width = 32
180
-
181
- # enc_blks = [2, 2, 4, 8]
182
- # middle_blk_num = 12
183
- # dec_blks = [2, 2, 2, 2]
184
-
185
- enc_blks = [1, 1, 1, 28]
186
- middle_blk_num = 1
187
- dec_blks = [1, 1, 1, 1]
188
-
189
- net = NAFNet(img_channel=img_channel, width=width, middle_blk_num=middle_blk_num,
190
- enc_blk_nums=enc_blks, dec_blk_nums=dec_blks)
191
-
192
-
193
- inp_shape = (3, 256, 256)
194
-
195
- from ptflops import get_model_complexity_info
196
-
197
- macs, params = get_model_complexity_info(net, inp_shape, verbose=False, print_per_layer_stat=False)
198
-
199
- params = float(params[:-3])
200
- macs = float(macs[:-4])
201
-
202
- print(macs, params)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
model/{LowLight_HWMNet.py β†’ LowLight_model.py} RENAMED
File without changes
utils/WT/__init__.py DELETED
@@ -1 +0,0 @@
1
- from .transform import *
 
 
utils/WT/transform.py DELETED
@@ -1,53 +0,0 @@
1
- import torch
2
- import torch.nn as nn
3
-
4
- def dwt_init(x):
5
- x01 = x[:, :, 0::2, :] / 2
6
- x02 = x[:, :, 1::2, :] / 2
7
- x1 = x01[:, :, :, 0::2]
8
- x2 = x02[:, :, :, 0::2]
9
- x3 = x01[:, :, :, 1::2]
10
- x4 = x02[:, :, :, 1::2]
11
- x_LL = x1 + x2 + x3 + x4
12
- x_HL = -x1 - x2 + x3 + x4
13
- x_LH = -x1 + x2 - x3 + x4
14
- x_HH = x1 - x2 - x3 + x4
15
- # print(x_HH[:, 0, :, :])
16
- return torch.cat((x_LL, x_HL, x_LH, x_HH), 1)
17
-
18
- def iwt_init(x):
19
- r = 2
20
- in_batch, in_channel, in_height, in_width = x.size()
21
- out_batch, out_channel, out_height, out_width = in_batch, int(in_channel / (r ** 2)), r * in_height, r * in_width
22
- x1 = x[:, 0:out_channel, :, :] / 2
23
- x2 = x[:, out_channel:out_channel * 2, :, :] / 2
24
- x3 = x[:, out_channel * 2:out_channel * 3, :, :] / 2
25
- x4 = x[:, out_channel * 3:out_channel * 4, :, :] / 2
26
- h = torch.zeros([out_batch, out_channel, out_height, out_width]).cuda() #
27
-
28
- h[:, :, 0::2, 0::2] = x1 - x2 - x3 + x4
29
- h[:, :, 1::2, 0::2] = x1 - x2 + x3 - x4
30
- h[:, :, 0::2, 1::2] = x1 + x2 - x3 - x4
31
- h[:, :, 1::2, 1::2] = x1 + x2 + x3 + x4
32
-
33
- return h
34
-
35
-
36
- class DWT(nn.Module):
37
- def __init__(self):
38
- super(DWT, self).__init__()
39
- self.requires_grad = True
40
-
41
- def forward(self, x):
42
- return dwt_init(x)
43
-
44
-
45
- class IWT(nn.Module):
46
- def __init__(self):
47
- super(IWT, self).__init__()
48
- self.requires_grad = True
49
-
50
- def forward(self, x):
51
- return iwt_init(x)
52
-
53
-