MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / graph_structure

Method graph_structure

examples/OpticalFlow/flownet_models.py:181–228  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

179 return prediction
180
181 def graph_structure(self, x):
182 x1, x2 = tf.split(x, 2, axis=0)
183 x1x2 = tf.reshape(x, [1, -1, self.height, self.width]) # 1(2C)HW
184
185 # FlowNet-C
186 flownetc_flow2 = FlowNet2C().graph_structure(x)
187 flownetc_flow = resize(flownetc_flow2 * DISP_SCALE, mode='bilinear')
188
189 resampled_img1 = resample(x2, flownetc_flow)
190 norm_diff_img0 = channel_norm(x1 - resampled_img1)
191
192 # FlowNet-S
193 concat1 = tf.concat([x1x2, resampled_img1, flownetc_flow / DISP_SCALE, norm_diff_img0], axis=1)
194 with tf.variable_scope('flownet_s1'):
195 flownets1_flow2 = FlowNet2S().graph_structure(concat1, standalone=False)
196 flownets1_flow = resize(flownets1_flow2 * DISP_SCALE, mode='bilinear')
197
198 resampled_img1 = resample(x2, flownets1_flow)
199 norm_diff_img0 = channel_norm(x1 - resampled_img1)
200
201 # FlowNet-S
202 concat2 = tf.concat([x1x2, resampled_img1, flownets1_flow / DISP_SCALE, norm_diff_img0], axis=1)
203 with tf.variable_scope('flownet_s2'):
204 flownets2_flow2 = FlowNet2S().graph_structure(concat2, standalone=False)
205 flownets2_flow = resize(flownets2_flow2 * DISP_SCALE, mode='nearest')
206
207 norm_flownets2_flow = channel_norm(flownets2_flow)
208 diff_flownets2_flow = resample(x2, flownets2_flow)
209 diff_flownets2_img1 = channel_norm(x1 - diff_flownets2_flow)
210
211 # FlowNet-SD
212 with tf.variable_scope('flownet_sd'):
213 flownetsd_flow = self.flownet2_sd(x1x2)
214
215 norm_flownetsd_flow = channel_norm(flownetsd_flow)
216 diff_flownetsd_flow = resample(x2, flownetsd_flow)
217 diff_flownetsd_img1 = channel_norm(x1 - diff_flownetsd_flow)
218
219 concat3 = tf.concat([x1,
220 flownetsd_flow, flownets2_flow,
221 norm_flownetsd_flow, norm_flownets2_flow,
222 diff_flownetsd_img1, diff_flownets2_img1], axis=1)
223
224 # FlowNet-Fusion
225 with tf.variable_scope('flownet_fusion'):
226 flownetfusion_flow = self.flownet2_fusion(concat3)
227
228 return flownetfusion_flow
229
230 def flownet2_fusion(self, x):
231 """

Callers

nothing calls this directly

Calls 7

flownet2_sdMethod · 0.95
flownet2_fusionMethod · 0.95
FlowNet2CClass · 0.85
resizeFunction · 0.85
resampleFunction · 0.85
channel_normFunction · 0.85
FlowNet2SClass · 0.85

Tested by

no test coverage detected