mterris commited on
Commit
e0ec252
·
1 Parent(s): 1eb9e66
Files changed (2) hide show
  1. .idea/workspace.xml +192 -0
  2. app.py +16 -16
.idea/workspace.xml ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="AutoImportSettings">
4
+ <option name="autoReloadType" value="SELECTIVE" />
5
+ </component>
6
+ <component name="ChangeListManager">
7
+ <list default="true" id="280aa5dd-95a6-46b6-8ccf-766e4d770a29" name="Changes" comment="">
8
+ <change beforePath="$PROJECT_DIR$/app.py" beforeDir="false" afterPath="$PROJECT_DIR$/app.py" afterDir="false" />
9
+ </list>
10
+ <option name="SHOW_DIALOG" value="false" />
11
+ <option name="HIGHLIGHT_CONFLICTS" value="true" />
12
+ <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
13
+ <option name="LAST_RESOLUTION" value="IGNORE" />
14
+ </component>
15
+ <component name="Git.Settings">
16
+ <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
17
+ </component>
18
+ <component name="ProjectColorInfo">{
19
+ &quot;associatedIndex&quot;: 7
20
+ }</component>
21
+ <component name="ProjectId" id="2ur8V3IK3Y3vXXdI1C58I2bhbPp" />
22
+ <component name="ProjectViewState">
23
+ <option name="hideEmptyMiddlePackages" value="true" />
24
+ <option name="showLibraryContents" value="true" />
25
+ </component>
26
+ <component name="PropertiesComponent"><![CDATA[{
27
+ "keyToString": {
28
+ "RunOnceActivity.ShowReadmeOnStart": "true",
29
+ "RunOnceActivity.git.unshallow": "true",
30
+ "git-widget-placeholder": "Rebasing main",
31
+ "last_opened_file_path": "/Users/matthieuterris/Documents/work/codes/denoising",
32
+ "node.js.detected.package.eslint": "true",
33
+ "node.js.detected.package.tslint": "true",
34
+ "node.js.selected.package.eslint": "(autodetect)",
35
+ "node.js.selected.package.tslint": "(autodetect)",
36
+ "nodejs_package_manager_path": "npm",
37
+ "settings.editor.selected.configurable": "http.proxy",
38
+ "vue.rearranger.settings.migration": "true"
39
+ }
40
+ }]]></component>
41
+ <component name="RunManager">
42
+ <configuration default="true" type="DjangoTestsConfigurationType">
43
+ <option name="ENV_FILES" value="" />
44
+ <option name="INTERPRETER_OPTIONS" value="" />
45
+ <option name="PARENT_ENVS" value="true" />
46
+ <envs>
47
+ <env name="PYTHONUNBUFFERED" value="1" />
48
+ </envs>
49
+ <option name="SDK_HOME" value="" />
50
+ <option name="WORKING_DIRECTORY" value="" />
51
+ <option name="IS_MODULE_SDK" value="false" />
52
+ <option name="ADD_CONTENT_ROOTS" value="true" />
53
+ <option name="ADD_SOURCE_ROOTS" value="true" />
54
+ <module name="" />
55
+ <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
56
+ <option name="TARGET" value="" />
57
+ <option name="SETTINGS_FILE" value="" />
58
+ <option name="CUSTOM_SETTINGS" value="false" />
59
+ <option name="USE_OPTIONS" value="false" />
60
+ <option name="OPTIONS" value="" />
61
+ <method v="2" />
62
+ </configuration>
63
+ <configuration default="true" type="PythonConfigurationType" factoryName="Python">
64
+ <option name="ENV_FILES" value="" />
65
+ <option name="INTERPRETER_OPTIONS" value="" />
66
+ <option name="PARENT_ENVS" value="true" />
67
+ <envs>
68
+ <env name="PYTHONUNBUFFERED" value="1" />
69
+ </envs>
70
+ <option name="SDK_HOME" value="" />
71
+ <option name="WORKING_DIRECTORY" value="" />
72
+ <option name="IS_MODULE_SDK" value="false" />
73
+ <option name="ADD_CONTENT_ROOTS" value="true" />
74
+ <option name="ADD_SOURCE_ROOTS" value="true" />
75
+ <module name="" />
76
+ <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
77
+ <option name="SCRIPT_NAME" value="" />
78
+ <option name="PARAMETERS" value="" />
79
+ <option name="SHOW_COMMAND_LINE" value="false" />
80
+ <option name="EMULATE_TERMINAL" value="false" />
81
+ <option name="MODULE_MODE" value="false" />
82
+ <option name="REDIRECT_INPUT" value="false" />
83
+ <option name="INPUT_FILE" value="" />
84
+ <method v="2" />
85
+ </configuration>
86
+ <configuration default="true" type="Python.FlaskServer">
87
+ <option name="ENV_FILES" value="" />
88
+ <option name="INTERPRETER_OPTIONS" value="" />
89
+ <option name="PARENT_ENVS" value="true" />
90
+ <option name="SDK_HOME" value="" />
91
+ <option name="WORKING_DIRECTORY" value="" />
92
+ <option name="IS_MODULE_SDK" value="false" />
93
+ <option name="ADD_CONTENT_ROOTS" value="true" />
94
+ <option name="ADD_SOURCE_ROOTS" value="true" />
95
+ <module name="" />
96
+ <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
97
+ <option name="launchJavascriptDebuger" value="false" />
98
+ <method v="2" />
99
+ </configuration>
100
+ <configuration default="true" type="Tox" factoryName="Tox">
101
+ <option name="ENV_FILES" value="" />
102
+ <option name="INTERPRETER_OPTIONS" value="" />
103
+ <option name="PARENT_ENVS" value="true" />
104
+ <option name="SDK_HOME" value="" />
105
+ <option name="WORKING_DIRECTORY" value="" />
106
+ <option name="IS_MODULE_SDK" value="false" />
107
+ <option name="ADD_CONTENT_ROOTS" value="true" />
108
+ <option name="ADD_SOURCE_ROOTS" value="true" />
109
+ <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
110
+ <method v="2" />
111
+ </configuration>
112
+ <configuration default="true" type="docs" factoryName="Docutils task">
113
+ <option name="ENV_FILES" value="" />
114
+ <option name="INTERPRETER_OPTIONS" value="" />
115
+ <option name="PARENT_ENVS" value="true" />
116
+ <option name="SDK_HOME" value="" />
117
+ <option name="WORKING_DIRECTORY" value="" />
118
+ <option name="IS_MODULE_SDK" value="false" />
119
+ <option name="ADD_CONTENT_ROOTS" value="true" />
120
+ <option name="ADD_SOURCE_ROOTS" value="true" />
121
+ <module name="" />
122
+ <option name="docutils_input_file" value="" />
123
+ <option name="docutils_output_file" value="" />
124
+ <option name="docutils_params" value="" />
125
+ <option name="docutils_task" value="" />
126
+ <option name="docutils_open_in_browser" value="false" />
127
+ <method v="2" />
128
+ </configuration>
129
+ <configuration default="true" type="docs" factoryName="Sphinx task">
130
+ <option name="ENV_FILES" value="" />
131
+ <option name="INTERPRETER_OPTIONS" value="" />
132
+ <option name="PARENT_ENVS" value="true" />
133
+ <option name="SDK_HOME" value="" />
134
+ <option name="WORKING_DIRECTORY" value="" />
135
+ <option name="IS_MODULE_SDK" value="false" />
136
+ <option name="ADD_CONTENT_ROOTS" value="true" />
137
+ <option name="ADD_SOURCE_ROOTS" value="true" />
138
+ <module name="" />
139
+ <option name="docutils_input_file" value="" />
140
+ <option name="docutils_output_file" value="" />
141
+ <option name="docutils_params" value="" />
142
+ <option name="docutils_task" value="" />
143
+ <option name="docutils_open_in_browser" value="false" />
144
+ <method v="2" />
145
+ </configuration>
146
+ <configuration default="true" type="tests" factoryName="Doctests">
147
+ <option name="ENV_FILES" value="" />
148
+ <option name="INTERPRETER_OPTIONS" value="" />
149
+ <option name="PARENT_ENVS" value="true" />
150
+ <option name="SDK_HOME" value="" />
151
+ <option name="WORKING_DIRECTORY" value="" />
152
+ <option name="IS_MODULE_SDK" value="false" />
153
+ <option name="ADD_CONTENT_ROOTS" value="true" />
154
+ <option name="ADD_SOURCE_ROOTS" value="true" />
155
+ <module name="" />
156
+ <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
157
+ <option name="SCRIPT_NAME" value="" />
158
+ <option name="CLASS_NAME" value="" />
159
+ <option name="METHOD_NAME" value="" />
160
+ <option name="FOLDER_NAME" value="" />
161
+ <option name="TEST_TYPE" value="TEST_SCRIPT" />
162
+ <option name="PATTERN" value="" />
163
+ <option name="USE_PATTERN" value="false" />
164
+ <method v="2" />
165
+ </configuration>
166
+ </component>
167
+ <component name="SharedIndexes">
168
+ <attachedChunks>
169
+ <set>
170
+ <option value="bundled-js-predefined-d6986cc7102b-1632447f56bf-JavaScript-PY-243.26053.29" />
171
+ <option value="bundled-python-sdk-b1dbf8ef85a6-4df51de95216-com.jetbrains.pycharm.pro.sharedIndexes.bundled-PY-243.26053.29" />
172
+ </set>
173
+ </attachedChunks>
174
+ </component>
175
+ <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
176
+ <component name="TaskManager">
177
+ <task active="true" id="Default" summary="Default task">
178
+ <changelist id="280aa5dd-95a6-46b6-8ccf-766e4d770a29" name="Changes" comment="" />
179
+ <created>1742995354373</created>
180
+ <option name="number" value="Default" />
181
+ <option name="presentableId" value="Default" />
182
+ <updated>1742995354373</updated>
183
+ <workItem from="1742995355868" duration="24113000" />
184
+ <workItem from="1743172745480" duration="8448000" />
185
+ <workItem from="1744016523411" duration="2852000" />
186
+ </task>
187
+ <servers />
188
+ </component>
189
+ <component name="TypeScriptGeneratedFilesManager">
190
+ <option name="version" value="3" />
191
+ </component>
192
+ </project>
app.py CHANGED
@@ -16,7 +16,7 @@ from factories import PhysicsWithGenerator, EvalModel, BaselineModel, EvalDatase
16
 
17
 
18
  ### Config
19
- DEVICE_STR = 'cuda' # run model inference on NVIDIA gpu
20
  torch.set_grad_enabled(False) # stops tracking values for gradients
21
 
22
 
@@ -164,10 +164,10 @@ with gr.Blocks(title=title, theme=gr.themes.Glass()) as interface:
164
  ### LAYOUT
165
  # Display images
166
  with gr.Row():
167
- gt_img = gr.Image(label="Ground-truth IMAGE", interactive=True)
168
- observed_img = gr.Image(label="Observed IMAGE", interactive=False)
169
- model_a_out = gr.Image(label="RAM OUTPUT", interactive=False)
170
- model_b_out = gr.Image(label="DPIR OUTPUT", interactive=False)
171
 
172
  @gr.render(inputs=[dataset_placeholder, physics_placeholder, available_physics_placeholder])
173
  def dynamic_layout(dataset, physics, available_physics):
@@ -175,23 +175,23 @@ with gr.Blocks(title=title, theme=gr.themes.Glass()) as interface:
175
 
176
  # Manage datasets and display metric values
177
  with gr.Row():
178
- with gr.Column():
179
- run_button = gr.Button("Demo on above image")
180
  choose_dataset = gr.Radio(choices=EvalDataset.all_datasets,
181
  label="Datasets",
182
  value=dataset.name)
183
  idx_slider = gr.Slider(minimum=0, maximum=len(dataset)-1, step=1, label="Sample index", key=0)
184
  with gr.Row():
185
- load_button = gr.Button("Run on index image from dataset")
186
- load_random_button = gr.Button("Run on random image from dataset")
187
- with gr.Column():
188
- observed_metrics = gr.Textbox(label="PSNR(Observed, Ground-truth)",
189
  lines=1)
190
- with gr.Column():
191
- out_a_metric = gr.Textbox(label="PSNR(RAM, Ground-truth)",
192
  lines=1)
193
- with gr.Column():
194
- out_b_metric = gr.Textbox(label="PSNR(DPIR, Ground-truth)",
195
  lines=1)
196
 
197
  # Manage physics
@@ -200,7 +200,7 @@ with gr.Blocks(title=title, theme=gr.themes.Glass()) as interface:
200
  choose_physics = gr.Radio(choices=available_physics,
201
  label="Physics",
202
  value=physics.name)
203
- use_generator_button = gr.Checkbox(label="Generate physics parameters during inference")
204
  with gr.Column(scale=1):
205
  with gr.Row():
206
  key_selector = gr.Dropdown(choices=list(physics.saved_params["updatable_params"].keys()),
 
16
 
17
 
18
  ### Config
19
+ DEVICE_STR = 'cuda' if torch.cuda.is_available() else 'cpu' # run model inference on NVIDIA gpu
20
  torch.set_grad_enabled(False) # stops tracking values for gradients
21
 
22
 
 
164
  ### LAYOUT
165
  # Display images
166
  with gr.Row():
167
+ gt_img = gr.Image(label="Ground-truth image", interactive=True)
168
+ observed_img = gr.Image(label="Observed image", interactive=False)
169
+ model_a_out = gr.Image(label="RAM output", interactive=False)
170
+ model_b_out = gr.Image(label="DPIR output", interactive=False)
171
 
172
  @gr.render(inputs=[dataset_placeholder, physics_placeholder, available_physics_placeholder])
173
  def dynamic_layout(dataset, physics, available_physics):
 
175
 
176
  # Manage datasets and display metric values
177
  with gr.Row():
178
+ with gr.Column(scale=1, min_width=160):
179
+ run_button = gr.Button("Demo on above image", size='md')
180
  choose_dataset = gr.Radio(choices=EvalDataset.all_datasets,
181
  label="Datasets",
182
  value=dataset.name)
183
  idx_slider = gr.Slider(minimum=0, maximum=len(dataset)-1, step=1, label="Sample index", key=0)
184
  with gr.Row():
185
+ load_button = gr.Button("Run on index image from dataset", size='md')
186
+ load_random_button = gr.Button("Run on random image from dataset", size='md')
187
+ with gr.Column(scale=1, min_width=160):
188
+ observed_metrics = gr.Textbox(label="PSNR Observed",
189
  lines=1)
190
+ with gr.Column(scale=1, min_width=160):
191
+ out_a_metric = gr.Textbox(label="PSNR RAM output",
192
  lines=1)
193
+ with gr.Column(scale=1, min_width=160):
194
+ out_b_metric = gr.Textbox(label="PSNR DPIR",
195
  lines=1)
196
 
197
  # Manage physics
 
200
  choose_physics = gr.Radio(choices=available_physics,
201
  label="Physics",
202
  value=physics.name)
203
+ use_generator_button = gr.Checkbox(label="Generate physics parameters during inference", value=True)
204
  with gr.Column(scale=1):
205
  with gr.Row():
206
  key_selector = gr.Dropdown(choices=list(physics.saved_params["updatable_params"].keys()),