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

add readme and fix minor stuff

parent b9e15c67
No related branches found
No related tags found
No related merge requests found
...@@ -6,3 +6,18 @@ Read and use at your own risk. ...@@ -6,3 +6,18 @@ Read and use at your own risk.
[1] Stephan Hilb and Andreas Langer. 'A General Decomposition Method [1] Stephan Hilb and Andreas Langer. 'A General Decomposition Method
for a Convex Problem Related to Total Variation Minimization'. In preparation. for a Convex Problem Related to Total Variation Minimization'. In preparation.
2022 2022
## Getting started
1. `julia --project=scripts/`
2. `]instantiate`
3. execute statements in `include("scripts/run.jl")`. There is a memory leak
currently, so the Julia session should better be restarted after every
experiment.
### Running parallel scaling tests
1. start Julia with e.g. `julia -p 9 --project=scripts/`
2. `@everywhere using Pkg`
3. `@everywhere Pkg.activate("scripts/")`
4. as above
...@@ -8,6 +8,7 @@ using CSV ...@@ -8,6 +8,7 @@ using CSV
using Colors: HSV using Colors: HSV
using DataFrames using DataFrames
using Distributed using Distributed
@everywhere using DualTVDD
@everywhere using DualTVDD: @everywhere using DualTVDD:
DualTVL1ROFOpProblem, DualTVL1ROFOpProblem,
DualTVDDAlgorithm, ChambolleAlgorithm, NStepAlgorithm, ProjGradAlgorithm,# TVNewtonAlgorithm, DualTVDDAlgorithm, ChambolleAlgorithm, NStepAlgorithm, ProjGradAlgorithm,# TVNewtonAlgorithm,
...@@ -60,7 +61,7 @@ function halve(img) ...@@ -60,7 +61,7 @@ function halve(img)
return res return res
end end
# Problems # Problem Definitions
function DenoiseProblem(img::AbstractArray{T,d}; λ, β = 0.) where {T,d} function DenoiseProblem(img::AbstractArray{T,d}; λ, β = 0.) where {T,d}
B = (1 + β) * I B = (1 + β) * I
...@@ -73,9 +74,6 @@ function InpaintProblem(img::AbstractArray{T,d}, imgmask::AbstractArray{Bool,d}; ...@@ -73,9 +74,6 @@ function InpaintProblem(img::AbstractArray{T,d}, imgmask::AbstractArray{Bool,d};
pwop = imgmask .+ β .* Ref(I) pwop = imgmask .+ β .* Ref(I)
B = Diagonal(vec(inv.(pwop))) B = Diagonal(vec(inv.(pwop)))
## we grey-out the inpainting area.
## since β > 0 this actually matters and should be a sane default
#g = imgmask .* img .+ .!imgmask .* 0.5
g = imgmask .* img g = imgmask .* img
return DualTVL1ROFOpProblem(g, B, λ) return DualTVL1ROFOpProblem(g, B, λ)
end end
...@@ -280,21 +278,17 @@ function experiment_scaling_opticalflow(ctx) ...@@ -280,21 +278,17 @@ function experiment_scaling_opticalflow(ctx)
ntimings = 3 ntimings = 3
prob = OptFlowProblem(f0, f1; λ, β) prob = OptFlowProblem(f0, f1; λ, β)
#return prob
galg = ChambolleAlgorithm(prob) galg = ChambolleAlgorithm(prob)
dalg(workers) = alg_ddseq(workers) = DualTVDDAlgorithm(prob; workers, M, overlap, ninner, parallel = false, σ = 1., subalg = x -> ChambolleAlgorithm(x))
DualTVDDAlgorithm(prob; alg_ddpar(workers) = DualTVDDAlgorithm(prob; workers, M, overlap, ninner, parallel = true, σ = 0.25, subalg = x -> ChambolleAlgorithm(x))
workers, M, overlap, ninner, parallel=false, σ=1.,
subalg = x -> ChambolleAlgorithm(x))
function timeit(alg) function timeit(alg)
# precompile # warmup for precompilation
run_while((_, _) -> false, alg) run_while((_, _) -> false, alg)
times = map(1:ntimings) do _ times = map(1:ntimings) do _
return @elapsed run_while(alg) do st, k return @elapsed run_while(alg) do st, k
# min ~107
return energy(fetch(st), prob) > stopenergy return energy(fetch(st), prob) > stopenergy
end end
end end
...@@ -311,13 +305,14 @@ function experiment_scaling_opticalflow(ctx) ...@@ -311,13 +305,14 @@ function experiment_scaling_opticalflow(ctx)
nparallel % nw == 0 || continue nparallel % nw == 0 || continue
push!(df, ( push!(df, (
nworkers = nw, nworkers = nw,
time = timeit(dalg(ws[1:nw])))) time_ddseq = timeit(alg_ddseq(ws[1:nw])),
time_ddpar = timeit(alg_ddpar(ws[1:nw]))
))
end end
display(df) display(df)
CSV.write(joinpath(ctx.outdir, "timings.csv"), df) CSV.write(joinpath(ctx.outdir, "timings.csv"), df)
#saveimg(joinpath(ctx.outdir, "output_glob.png"), fetch_u(states.glob))
savedata(joinpath(ctx.outdir, "data.tex"); savedata(joinpath(ctx.outdir, "data.tex");
lambda=λ, beta=β, Mdir, M=prod(M), lambda=λ, beta=β, Mdir, M=prod(M),
ntimings, stopenergy, ninner, ntimings, stopenergy, ninner,
...@@ -372,7 +367,7 @@ function _experiment_surrogate_outerinner(ctx, ref) ...@@ -372,7 +367,7 @@ function _experiment_surrogate_outerinner(ctx, ref)
#residual = residual(fetch(state), prob), #residual = residual(fetch(state), prob),
) )
end end
display(df) #display(df)
CSV.write(joinpath(ctx.outdir, "energies.csv"), df) CSV.write(joinpath(ctx.outdir, "energies.csv"), df)
#saveimg(joinpath(ctx.outdir, "output_glob.png"), fetch_u(states.glob)) #saveimg(joinpath(ctx.outdir, "output_glob.png"), fetch_u(states.glob))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment