Skip to content
Snippets Groups Projects
Commit dcc884cd authored by Stephan Hilb's avatar Stephan Hilb
Browse files

add experiment comparing choices of S

parent bf15de74
No related branches found
No related tags found
No related merge requests found
...@@ -190,7 +190,7 @@ function L1L2TVState{m}(mesh; T, tdata, S, ...@@ -190,7 +190,7 @@ function L1L2TVState{m}(mesh; T, tdata, S,
end end
function OptFlowState(mesh; function OptFlowState(mesh;
alpha1, alpha2, beta, lambda, gamma1, gamma2) alpha1, alpha2, beta, lambda, gamma1, gamma2, Schoice)
alpha2 > 0 || beta > 0 || alpha2 > 0 || beta > 0 ||
throw(ArgumentError("operator B is singular with these parameters")) throw(ArgumentError("operator B is singular with these parameters"))
...@@ -208,7 +208,7 @@ function OptFlowState(mesh; ...@@ -208,7 +208,7 @@ function OptFlowState(mesh;
# tdata will be something like nabla(fw) # tdata will be something like nabla(fw)
T(tdata, u) = tdata * u T(tdata, u) = tdata * u
T(::typeof(adjoint), tdata, v) = tdata' * v T(::typeof(adjoint), tdata, v) = tdata' * v
S(u, nablau) = nablau' S(u, nablau) = Schoice == :nabla ? nablau' : u
est = FeFunction(Vest, name = "est") est = FeFunction(Vest, name = "est")
g = FeFunction(Vg, name = "g") g = FeFunction(Vg, name = "g")
...@@ -1526,7 +1526,7 @@ function optflow(ctx) ...@@ -1526,7 +1526,7 @@ function optflow(ctx)
st = OptFlowState(mesh; st = OptFlowState(mesh;
ctx.params.alpha1, ctx.params.alpha2, ctx.params.alpha1, ctx.params.alpha2,
ctx.params.lambda, ctx.params.beta, ctx.params.lambda, ctx.params.beta,
ctx.params.gamma1, ctx.params.gamma2) ctx.params.gamma1, ctx.params.gamma2, ctx.params.Schoice)
function warp!() function warp!()
println("warp and reproject ...") println("warp and reproject ...")
...@@ -1582,8 +1582,8 @@ function optflow(ctx) ...@@ -1582,8 +1582,8 @@ function optflow(ctx)
println("norm_step = $norm_step_") println("norm_step = $norm_step_")
# interior newton stop criterion # interior newton stop criterion
norm_step_ > eps_newton && k_newton < 30 && continue norm_step_ > eps_newton && k_newton < ctx.params.newton_max_iters && continue
k_newton >= 30 && @warn "Newton reached maximum number of iterations" k_newton >= ctx.params.newton_max_iters && @warn "Newton reached maximum number of iterations"
ctx.params.warp || break ctx.params.warp || break
k_newton = 0 k_newton = 0
...@@ -1642,7 +1642,7 @@ function optflow(ctx) ...@@ -1642,7 +1642,7 @@ function optflow(ctx)
saveimg(joinpath(ctx.outdir, "fw.png"), to_img(imgfw)) saveimg(joinpath(ctx.outdir, "fw.png"), to_img(imgfw))
savedata(joinpath(ctx.outdir, "data.tex"); savedata(joinpath(ctx.outdir, "data.tex");
eps_newton, eps_warp, ctx.params.n_refine, eps_newton, eps_warp, ctx.params.n_refine,
st.alpha1, st.alpha2, st.lambda, st.beta, st.gamma1, st.gamma2, st.alpha1, st.alpha2, st.lambda, st.beta, st.gamma1, st.gamma2, ctx.params.Schoice,
width=size(u_sampled, 2), height=size(u_sampled, 3), width=size(u_sampled, 2), height=size(u_sampled, 3),
endpoint_error_mean, endpoint_error_stddev, endpoint_error_mean, endpoint_error_stddev,
angular_error_mean, angular_error_stddev, angular_error_mean, angular_error_stddev,
...@@ -1667,8 +1667,7 @@ function experiment_optflow_middlebury_all_benchmarks(ctx) ...@@ -1667,8 +1667,7 @@ function experiment_optflow_middlebury_all_benchmarks(ctx)
#example == "Dimetrodon" && continue #example == "Dimetrodon" && continue
ctx(experiment_optflow_middlebury, example; ctx(experiment_optflow_middlebury, example;
alpha1 = 10., alpha2 = 0., lambda = 1., beta = 1e-5, alpha1 = 10., alpha2 = 0., lambda = 1., beta = 1e-5,
gamma1 = 1e-4, gamma2 = 1e-4) gamma1 = 1e-4, gamma2 = 1e-4, Schoice = :nabla, newton_max_iters = 30)
#return
end end
end end
...@@ -1694,6 +1693,41 @@ function experiment_optflow_middlebury_warping_comparison_adaptive(ctx) ...@@ -1694,6 +1693,41 @@ function experiment_optflow_middlebury_warping_comparison_adaptive(ctx)
warp = true, refine = true, n_refine = 6) warp = true, refine = true, n_refine = 6)
end end
function experiment_optflow_schoice(ctx)
function run(beta, Schoice)
example = "Dimetrodon"
duration = @elapsed begin
st = ctx(experiment_optflow_middlebury, example;
alpha1 = 10., alpha2 = 0., lambda = 1., beta,
gamma1 = 1e-4, gamma2 = 1e-4, Schoice,
warp = true, refine = false, n_refine = 0, newton_max_iters = 15)
end
u_sampled = sample(st.u)
u_flow = to_img(u_sampled)
# not yet in ctx
gtflow = FileIO.load(joinpath(ctx.indir, example, "flow10.flo"))
endpoint_errors = collect(skipmissing(map_flow(endpoint_error, u_flow, gtflow)))
angular_errors = collect(skipmissing(map_flow(angular_error, u_flow, gtflow)))
endpoint_error_mean = mean(endpoint_errors)
endpoint_error_stddev = stdm(endpoint_errors, endpoint_error_mean)
angular_error_mean = mean(angular_errors)
angular_error_stddev = stdm(angular_errors, angular_error_mean)
return (;Schoice, beta, duration, endpoint_error_mean, endpoint_error_stddev, angular_error_mean, angular_error_stddev)
end
df = DataFrame()
for Schoice in (:id, :nabla)
for beta in 10 .^ range(-6,3,10)
res = run(beta, Schoice)
push!(df, res)
end
end
CSV.write(joinpath(ctx.outdir, "schoice.csv"), df)
end
function test_image(n = 2^6; supersample_factor = 16) function test_image(n = 2^6; supersample_factor = 16)
q = supersample_factor q = supersample_factor
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment