Skip to content

Conversation

@lmmx
Copy link
Owner

@lmmx lmmx commented Dec 11, 2025

Uses batch execution (and process forking in a ProcessPoolExecutor 🤫 ) to cut down the speed of execution on GPU 🍴

This involved having to use BFGS-B, as it's the only method supported by the JAX in-library shim of scipy.optimize.minimize (but making it vmappable). So far this has affected the quality

  • edit I found a L-BFGS-B marked "do not rely on" in JAX, if they fully deprecate it then will have to vendor

The effect can be seen more easily if you duplicate the example_input dir by copying the files (not sure if this necessarily works in general or it's cheating somehow, but as an initial test it's promising!)

# Create duplicates for testing
cd example_input
for i in 1 2 3; do
  for f in *.jpg; do
    cp "$f" "${f%.jpg}_copy$i.jpg"
  done
done
cd ..

# Now test with 40 images
time just refresh-examples
  • Serial is from doing the same without this PR branch checked out

Benchmark on 40 images

Device Serial Batch Speedup
CPU 36s 8.7s 4.1x
GPU 53s 11.2s 4.7x
Image Initial Final Reduction
boston_cooking_a 0.074429 0.004874 15.3×
boston_cooking_b 0.131337 0.003856 34.1×
finnish_cooking_a 0.032092 0.018795 1.7×
linguistics_thesis_a 0.024761 0.000620 39.9×
linguistics_thesis_b 0.000024 0.000021 1.1×

Previous best to current best: 4.1x faster

Optimisation results

Image Trunk CPU Trunk GPU vmap CPU vmap GPU
boston_cooking_a 0.004874 0.008789 0.004874 0.004874
boston_cooking_b 0.003856 0.005931 0.003856 0.003856
finnish_cooking_a 0.018795 0.023118 0.018795 0.018795
linguistics_thesis_a 0.000620 0.001388 0.000620 0.000620
linguistics_thesis_b 0.000021 0.000021 0.000021 0.000021

The key fix was enabling float64 (jax.config.update("jax_enable_x64", True)) and keeping the objective function identical to the original. The vmap L-BFGS now:

  • Matches trunk CPU quality exactly on both devices
  • Beats trunk GPU quality (trunk GPU had worse convergence)
  • Massive speedup for batches - effectively ~0.2-0.3s per image vs 7-10s serial

The float64 was critical because the L-BFGS Hessian approximation accumulates numerical errors that compound over iterations - float32 just doesn't have enough precision for this geometric optimization problem.

Update: x64 enabled, experimental L-BFGS-B, quality now at parity

CPU

(page-dewarp) louis 🌟 ~/dev/page-dewarp/src/page_dewarp $ time just refresh-examples
Parsed config: Config(OPT_MAX_ITER=600000, OPT_METHOD='auto', DEVICE='auto', FOCAL_LENGTH=1.2, TEXT_MIN_WIDTH=15, TEXT_MIN_HEIGHT=2, TEXT_MIN_ASPECT=1.5, TEXT_MAX_THICKNESS=10, DEBUG_LEVEL=0, DEBUG_OUTPUT='file', EDGE_MAX_OVERLAP=1.0, EDGE_MAX_LENGTH=100.0, EDGE_ANGLE_COST=10.0, EDGE_MAX_ANGLE=7.5, SCREEN_MAX_W=1280, SCREEN_MAX_H=700, PAGE_MARGIN_X=50, PAGE_MARGIN_Y=20, ADAPTIVE_WINSZ=55, OUTPUT_ZOOM=1.0, OUTPUT_DPI=300, REMAP_DECIMATE=16, NO_BINARY=0, SHEAR_COST=0.0, MAX_CORR=100, RVEC_IDX=(0, 3), TVEC_IDX=(3, 6), CUBIC_IDX=(6, 8), SPAN_MIN_WIDTH=30, SPAN_PX_PER_STEP=20)
WARNING:2025-12-11 10:53:57,588:jax._src.xla_bridge:854: An NVIDIA GPU may be present on this machine, but a CUDA-enabled jaxlib is not installed. Falling back to cpu.
Processing 40 images with batched optimization...

=== Phase 1: Preprocessing ===
  boston_cooking_a_copy1_copy2_copy3.jpg: 38 spans, 554 points
  boston_cooking_a_copy1_copy2.jpg: 38 spans, 554 points
  boston_cooking_a_copy1_copy3.jpg: 38 spans, 554 points
  boston_cooking_a_copy1.jpg: 38 spans, 554 points
  boston_cooking_a_copy2_copy3.jpg: 38 spans, 554 points
  boston_cooking_a_copy2.jpg: 38 spans, 554 points
  boston_cooking_a_copy3.jpg: 38 spans, 554 points
  boston_cooking_a.jpg: 38 spans, 554 points
  boston_cooking_b_copy1_copy2_copy3.jpg: 38 spans, 475 points
  boston_cooking_b_copy1_copy2.jpg: 38 spans, 475 points
  boston_cooking_b_copy1_copy3.jpg: 38 spans, 475 points
  boston_cooking_b_copy1.jpg: 38 spans, 475 points
  boston_cooking_b_copy2_copy3.jpg: 38 spans, 475 points
  boston_cooking_b_copy2.jpg: 38 spans, 475 points
  boston_cooking_b_copy3.jpg: 38 spans, 475 points
  boston_cooking_b.jpg: 38 spans, 475 points
  finnish_cooking_a_copy1_copy2_copy3.jpg: 40 spans, 369 points
  finnish_cooking_a_copy1_copy2.jpg: 40 spans, 369 points
  finnish_cooking_a_copy1_copy3.jpg: 40 spans, 369 points
  finnish_cooking_a_copy1.jpg: 40 spans, 369 points
  finnish_cooking_a_copy2_copy3.jpg: 40 spans, 369 points
  finnish_cooking_a_copy2.jpg: 40 spans, 369 points
  finnish_cooking_a_copy3.jpg: 40 spans, 369 points
  finnish_cooking_a.jpg: 40 spans, 369 points
  linguistics_thesis_a_copy1_copy2_copy3.jpg: 20 spans, 161 points
  linguistics_thesis_a_copy1_copy2.jpg: 20 spans, 161 points
  linguistics_thesis_a_copy1_copy3.jpg: 20 spans, 161 points
  linguistics_thesis_a_copy1.jpg: 20 spans, 161 points
  linguistics_thesis_a_copy2_copy3.jpg: 20 spans, 161 points
  linguistics_thesis_a_copy2.jpg: 20 spans, 161 points
  linguistics_thesis_a_copy3.jpg: 20 spans, 161 points
  linguistics_thesis_a.jpg: 20 spans, 161 points
  linguistics_thesis_b_copy1_copy2_copy3.jpg: 1 spans, 7 points
  linguistics_thesis_b_copy1_copy2.jpg: 1 spans, 7 points
  linguistics_thesis_b_copy1_copy3.jpg: 1 spans, 7 points
  linguistics_thesis_b_copy1.jpg: 1 spans, 7 points
  linguistics_thesis_b_copy2_copy3.jpg: 1 spans, 7 points
  linguistics_thesis_b_copy2.jpg: 1 spans, 7 points
  linguistics_thesis_b_copy3.jpg: 1 spans, 7 points
  linguistics_thesis_b.jpg: 1 spans, 7 points

=== Phase 2: Parallel Optimization ===
  [boston_cooking_a_copy1_copy2_copy3] initial objective is 0.074429
  [boston_cooking_a_copy1_copy2] initial objective is 0.074429
  [boston_cooking_a_copy1_copy3] initial objective is 0.074429
  [boston_cooking_a_copy1] initial objective is 0.074429
  [boston_cooking_a_copy2_copy3] initial objective is 0.074429
  [boston_cooking_a_copy2] initial objective is 0.074429
  [boston_cooking_a_copy3] initial objective is 0.074429
  [boston_cooking_a] initial objective is 0.074429
  [boston_cooking_b_copy1_copy2_copy3] initial objective is 0.131337
  [boston_cooking_b_copy1_copy2] initial objective is 0.131337
  [boston_cooking_b_copy1_copy3] initial objective is 0.131337
  [boston_cooking_b_copy1] initial objective is 0.131337
  [boston_cooking_b_copy2_copy3] initial objective is 0.131337
  [boston_cooking_b_copy2] initial objective is 0.131337
  [boston_cooking_b_copy3] initial objective is 0.131337
  [boston_cooking_b] initial objective is 0.131337
  [finnish_cooking_a_copy1_copy2_copy3] initial objective is 0.032092
  [finnish_cooking_a_copy1_copy2] initial objective is 0.032092
  [finnish_cooking_a_copy1_copy3] initial objective is 0.032092
  [finnish_cooking_a_copy1] initial objective is 0.032092
  [finnish_cooking_a_copy2_copy3] initial objective is 0.032092
  [finnish_cooking_a_copy2] initial objective is 0.032092
  [finnish_cooking_a_copy3] initial objective is 0.032092
  [finnish_cooking_a] initial objective is 0.032092
  [linguistics_thesis_a_copy1_copy2_copy3] initial objective is 0.024761
  [linguistics_thesis_a_copy1_copy2] initial objective is 0.024761
  [linguistics_thesis_a_copy1_copy3] initial objective is 0.024761
  [linguistics_thesis_a_copy1] initial objective is 0.024761
  [linguistics_thesis_a_copy2_copy3] initial objective is 0.024761
  [linguistics_thesis_a_copy2] initial objective is 0.024761
  [linguistics_thesis_a_copy3] initial objective is 0.024761
  [linguistics_thesis_a] initial objective is 0.024761
  [linguistics_thesis_b_copy1_copy2_copy3] initial objective is 0.000024
  [linguistics_thesis_b_copy1_copy2] initial objective is 0.000024
  [linguistics_thesis_b_copy1_copy3] initial objective is 0.000024
  [linguistics_thesis_b_copy1] initial objective is 0.000024
  [linguistics_thesis_b_copy2_copy3] initial objective is 0.000024
  [linguistics_thesis_b_copy2] initial objective is 0.000024
  [linguistics_thesis_b_copy3] initial objective is 0.000024
  [linguistics_thesis_b] initial objective is 0.000024

  Running 40 parallel L-BFGS optimizations on CPU...
  parallel L-BFGS optimization took 3.22s
  [boston_cooking_a_copy1_copy2_copy3] final objective is 0.004874
  [boston_cooking_a_copy1_copy2] final objective is 0.004874
  [boston_cooking_a_copy1_copy3] final objective is 0.004874
  [boston_cooking_a_copy1] final objective is 0.004874
  [boston_cooking_a_copy2_copy3] final objective is 0.004874
  [boston_cooking_a_copy2] final objective is 0.004874
  [boston_cooking_a_copy3] final objective is 0.004874
  [boston_cooking_a] final objective is 0.004874
  [boston_cooking_b_copy1_copy2_copy3] final objective is 0.003856
  [boston_cooking_b_copy1_copy2] final objective is 0.003856
  [boston_cooking_b_copy1_copy3] final objective is 0.003856
  [boston_cooking_b_copy1] final objective is 0.003856
  [boston_cooking_b_copy2_copy3] final objective is 0.003856
  [boston_cooking_b_copy2] final objective is 0.003856
  [boston_cooking_b_copy3] final objective is 0.003856
  [boston_cooking_b] final objective is 0.003856
  [finnish_cooking_a_copy1_copy2_copy3] final objective is 0.018795
  [finnish_cooking_a_copy1_copy2] final objective is 0.018795
  [finnish_cooking_a_copy1_copy3] final objective is 0.018795
  [finnish_cooking_a_copy1] final objective is 0.018795
  [finnish_cooking_a_copy2_copy3] final objective is 0.018795
  [finnish_cooking_a_copy2] final objective is 0.018795
  [finnish_cooking_a_copy3] final objective is 0.018795
  [finnish_cooking_a] final objective is 0.018795
  [linguistics_thesis_a_copy1_copy2_copy3] final objective is 0.000620
  [linguistics_thesis_a_copy1_copy2] final objective is 0.000620
  [linguistics_thesis_a_copy1_copy3] final objective is 0.000620
  [linguistics_thesis_a_copy1] final objective is 0.000620
  [linguistics_thesis_a_copy2_copy3] final objective is 0.000620
  [linguistics_thesis_a_copy2] final objective is 0.000620
  [linguistics_thesis_a_copy3] final objective is 0.000620
  [linguistics_thesis_a] final objective is 0.000620
  [linguistics_thesis_b_copy1_copy2_copy3] final objective is 0.000021
  [linguistics_thesis_b_copy1_copy2] final objective is 0.000021
  [linguistics_thesis_b_copy1_copy3] final objective is 0.000021
  [linguistics_thesis_b_copy1] final objective is 0.000021
  [linguistics_thesis_b_copy2_copy3] final objective is 0.000021
  [linguistics_thesis_b_copy2] final objective is 0.000021
  [linguistics_thesis_b_copy3] final objective is 0.000021
  [linguistics_thesis_b] final objective is 0.000021

=== Phase 3: Generating Outputs ===
  got page dims 1.1184494074319429 x 1.744754012361811
  output will be 1472x2288
  got page dims 1.160047017646461 x 1.7901052788270981
  output will be 1904x2928
  got page dims 1.2252621226967872 x 1.968851862997054
  output will be 2016x3216
  got page dims 1.2252621226967872 x 1.968851862997054
  output will be 2016x3216
  got page dims 1.2252621226967872 x 1.968851862997054
  output will be 2016x3216
  got page dims 1.160047017646461 x 1.7901052788270981
  output will be 1904x2928
  got page dims 1.160047017646461 x 1.7901052788270981
  output will be 1904x2928
  got page dims 1.160047017646461 x 1.7901052788270981
  got page dims 1.160047017646461 x 1.7901052788270981
  output will be 1904x2928
  output will be 1904x2928
  got page dims 1.160047017646461 x 1.7901052788270981
  output will be 1904x2928
  got page dims 1.2252621226967872 x 1.968851862997054
  output will be 2016x3216
  got page dims 1.2252621226967872 x 1.968851862997054
  output will be 2016x3216
  got page dims 1.160047017646461 x 1.7901052788270981
  output will be 1904x2928
  got page dims 1.160047017646461 x 1.7901052788270981
  output will be 1904x2928
  got page dims 1.2252621226967872 x 1.968851862997054
  output will be 2016x3216
  got page dims 1.1184494074319429 x 1.744754012361811
  output will be 1472x2288
  got page dims 1.2252621226967872 x 1.968851862997054
  output will be 2016x3216
  got page dims 1.2252621226967872 x 1.968851862997054
  output will be 2016x3216
  got page dims 1.1184494074319429 x 1.744754012361811
  output will be 1472x2288
  got page dims 1.1184494074319429 x 1.744754012361811
  output will be 1472x2288
  got page dims 1.1184494074319429 x 1.744754012361811
  output will be 1472x2288
  got page dims 1.1184494074319429 x 1.744754012361811
  output will be 1472x2288
  got page dims 1.1184494074319429 x 1.744754012361811
  output will be 1472x2288
  got page dims 1.1184494074319429 x 1.744754012361811
  output will be 1472x2288
  got page dims 1.257906065163575 x 1.9022361686370612
  output will be 2912x4384
  got page dims 1.257906065163575 x 1.9022361686370612
  output will be 2912x4384
  got page dims 1.257906065163575 x 1.9022361686370612
  output will be 2912x4384
  got page dims 1.257906065163575 x 1.9022361686370612
  output will be 2912x4384
  got page dims 1.257906065163575 x 1.9022361686370612
  output will be 2912x4384
  got page dims 1.257906065163575 x 1.9022361686370612
  output will be 2912x4384
  got page dims 1.4683131541666512 x 2.047168900289947
  output will be 3392x4720
  got page dims 1.4683131541666512 x 2.047168900289947
  output will be 3392x4720
  got page dims 1.4683131541666512 x 2.047168900289947
  output will be 3392x4720
  got page dims 1.257906065163575 x 1.9022361686370612
  output will be 2912x4384
  got page dims 1.257906065163575 x 1.9022361686370612
  output will be 2912x4384
  got page dims 1.4683131541666512 x 2.047168900289947
  output will be 3392x4720
  got page dims 1.4683131541666512 x 2.047168900289947
  output will be 3392x4720
  got page dims 1.4683131541666512 x 2.047168900289947
  output will be 3392x4720
  got page dims 1.4683131541666512 x 2.047168900289947
  output will be 3392x4720
  got page dims 1.4683131541666512 x 2.047168900289947
  output will be 3392x4720
  wrote boston_cooking_a_copy1_copy2_copy3_thresh.png
  wrote boston_cooking_a_copy1_copy2_thresh.png
  wrote boston_cooking_a_copy1_copy3_thresh.png
  wrote boston_cooking_a_copy1_thresh.png
  wrote boston_cooking_a_copy2_copy3_thresh.png
  wrote boston_cooking_a_copy2_thresh.png
  wrote boston_cooking_a_copy3_thresh.png
  wrote boston_cooking_a_thresh.png
  wrote boston_cooking_b_copy1_copy2_copy3_thresh.png
  wrote boston_cooking_b_copy1_copy2_thresh.png
  wrote boston_cooking_b_copy1_copy3_thresh.png
  wrote boston_cooking_b_copy1_thresh.png
  wrote boston_cooking_b_copy2_copy3_thresh.png
  wrote boston_cooking_b_copy2_thresh.png
  wrote boston_cooking_b_copy3_thresh.png
  wrote boston_cooking_b_thresh.png
  wrote finnish_cooking_a_copy1_copy2_copy3_thresh.png
  wrote finnish_cooking_a_copy1_copy2_thresh.png
  wrote finnish_cooking_a_copy1_copy3_thresh.png
  wrote finnish_cooking_a_copy1_thresh.png
  wrote finnish_cooking_a_copy2_copy3_thresh.png
  wrote finnish_cooking_a_copy2_thresh.png
  wrote finnish_cooking_a_copy3_thresh.png
  wrote finnish_cooking_a_thresh.png
  wrote linguistics_thesis_a_copy1_copy2_copy3_thresh.png
  wrote linguistics_thesis_a_copy1_copy2_thresh.png
  wrote linguistics_thesis_a_copy1_copy3_thresh.png
  wrote linguistics_thesis_a_copy1_thresh.png
  wrote linguistics_thesis_a_copy2_copy3_thresh.png
  wrote linguistics_thesis_a_copy2_thresh.png
  wrote linguistics_thesis_a_copy3_thresh.png
  wrote linguistics_thesis_a_thresh.png
  wrote linguistics_thesis_b_copy1_copy2_copy3_thresh.png
  wrote linguistics_thesis_b_copy1_copy2_thresh.png
  wrote linguistics_thesis_b_copy1_copy3_thresh.png
  wrote linguistics_thesis_b_copy1_thresh.png
  wrote linguistics_thesis_b_copy2_copy3_thresh.png
  wrote linguistics_thesis_b_copy2_thresh.png
  wrote linguistics_thesis_b_copy3_thresh.png
  wrote linguistics_thesis_b_thresh.png

=== Summary ===
  ✓ boston_cooking_a_copy1_copy2_copy3_thresh.png
  ✓ boston_cooking_a_copy1_copy2_thresh.png
  ✓ boston_cooking_a_copy1_copy3_thresh.png
  ✓ boston_cooking_a_copy1_thresh.png
  ✓ boston_cooking_a_copy2_copy3_thresh.png
  ✓ boston_cooking_a_copy2_thresh.png
  ✓ boston_cooking_a_copy3_thresh.png
  ✓ boston_cooking_a_thresh.png
  ✓ boston_cooking_b_copy1_copy2_copy3_thresh.png
  ✓ boston_cooking_b_copy1_copy2_thresh.png
  ✓ boston_cooking_b_copy1_copy3_thresh.png
  ✓ boston_cooking_b_copy1_thresh.png
  ✓ boston_cooking_b_copy2_copy3_thresh.png
  ✓ boston_cooking_b_copy2_thresh.png
  ✓ boston_cooking_b_copy3_thresh.png
  ✓ boston_cooking_b_thresh.png
  ✓ finnish_cooking_a_copy1_copy2_copy3_thresh.png
  ✓ finnish_cooking_a_copy1_copy2_thresh.png
  ✓ finnish_cooking_a_copy1_copy3_thresh.png
  ✓ finnish_cooking_a_copy1_thresh.png
  ✓ finnish_cooking_a_copy2_copy3_thresh.png
  ✓ finnish_cooking_a_copy2_thresh.png
  ✓ finnish_cooking_a_copy3_thresh.png
  ✓ finnish_cooking_a_thresh.png
  ✓ linguistics_thesis_a_copy1_copy2_copy3_thresh.png
  ✓ linguistics_thesis_a_copy1_copy2_thresh.png
  ✓ linguistics_thesis_a_copy1_copy3_thresh.png
  ✓ linguistics_thesis_a_copy1_thresh.png
  ✓ linguistics_thesis_a_copy2_copy3_thresh.png
  ✓ linguistics_thesis_a_copy2_thresh.png
  ✓ linguistics_thesis_a_copy3_thresh.png
  ✓ linguistics_thesis_a_thresh.png
  ✓ linguistics_thesis_b_copy1_copy2_copy3_thresh.png
  ✓ linguistics_thesis_b_copy1_copy2_thresh.png
  ✓ linguistics_thesis_b_copy1_copy3_thresh.png
  ✓ linguistics_thesis_b_copy1_thresh.png
  ✓ linguistics_thesis_b_copy2_copy3_thresh.png
  ✓ linguistics_thesis_b_copy2_thresh.png
  ✓ linguistics_thesis_b_copy3_thresh.png
  ✓ linguistics_thesis_b_thresh.png

real    0m8.737s
user    0m57.117s
sys     0m22.714s
  • Trunk (just the original 5 images to show objective value obtained):
(page-dewarp) louis 🌟 ~/dev/page-dewarp/example_input $ time just refresh-examples
Parsed config: Config(OPT_MAX_ITER=600000, OPT_METHOD='auto', DEVICE='auto', FOCAL_LENGTH=1.2, TEXT_MIN_WIDTH=15, TEXT_MIN_HEIGHT=2, TEXT_MIN_ASPECT=1.5, TEXT_MAX_THICKNESS=10, DEBUG_LEVEL=0, DEBUG_OUTPUT='file', EDGE_MAX_OVERLAP=1.0, EDGE_MAX_LENGTH=100.0, EDGE_ANGLE_COST=10.0, EDGE_MAX_ANGLE=7.5, SCREEN_MAX_W=1280, SCREEN_MAX_H=700, PAGE_MARGIN_X=50, PAGE_MARGIN_Y=20, ADAPTIVE_WINSZ=55, OUTPUT_ZOOM=1.0, OUTPUT_DPI=300, REMAP_DECIMATE=16, NO_BINARY=0, SHEAR_COST=0.0, MAX_CORR=100, RVEC_IDX=(0, 3), TVEC_IDX=(3, 6), CUBIC_IDX=(6, 8), SPAN_MIN_WIDTH=30, SPAN_PX_PER_STEP=20)
Loaded boston_cooking_a.jpg at size='2448x3264' --> resized='490x653'
  got 38 spans with 554 points.
WARNING:2025-12-11 02:47:36,563:jax._src.xla_bridge:854: An NVIDIA GPU may be present on this machine, but a CUDA-enabled jaxlib is not installed. Falling back to cpu.
  initial objective is 0.07442903186407843
  optimizing 600 parameters on CPU...
  optimization (L-BFGS-B + JAX autodiff) took 0.85s, 147 evals
  final objective is 0.004874
  got page dims 1.1602281564480117 x 1.7904296993766273
  output will be 1904x2928
  wrote boston_cooking_a_thresh.png

Loaded boston_cooking_b.jpg at size='2448x3264' --> resized='490x653'
  got 38 spans with 475 points.
  initial objective is 0.13133749948751292
  optimizing 521 parameters on CPU...
  optimization (L-BFGS-B + JAX autodiff) took 0.63s, 116 evals
  final objective is 0.003856
  got page dims 1.2252146182728851 x 1.968748016390222
  output will be 2016x3216
  wrote boston_cooking_b_thresh.png

Loaded finnish_cooking_a.jpg at size='1964x2619' --> resized='491x655'
  got 40 spans with 369 points.
  initial objective is 0.0320922595402046
  optimizing 417 parameters on CPU...
  optimization (L-BFGS-B + JAX autodiff) took 0.79s, 161 evals
  final objective is 0.018795
  got page dims 1.1185314040070804 x 1.7448740825298554
  output will be 1472x2288
  wrote finnish_cooking_a_thresh.png

Loaded linguistics_thesis_a.jpg at size='3456x4608' --> resized='494x658'
  got 20 spans with 161 points.
  initial objective is 0.02476134606067954
  optimizing 189 parameters on CPU...
  optimization (L-BFGS-B + JAX autodiff) took 0.64s, 115 evals
  final objective is 0.000620
  got page dims 1.2577664631556598 x 1.9020731215522966
  output will be 2912x4384
  wrote linguistics_thesis_a_thresh.png

Loaded linguistics_thesis_b.jpg at size='3456x4608' --> resized='494x658'
  detecting lines because only 1 text spans
  got 1 spans with 7 points.
  initial objective is 2.4258143062261982e-05
  optimizing 16 parameters on CPU...
  optimization (L-BFGS-B + JAX autodiff) took 0.33s, 37 evals
  final objective is 0.000021
  got page dims 1.4682452099437735 x 2.0474756805730805
  output will be 3392x4720
  wrote linguistics_thesis_b_thresh.png


real    0m6.292s
user    0m47.110s
sys     0m2.178s

GPU

(page-dewarp) louis 🌟 ~/dev/page-dewarp/src/page_dewarp $ time just refresh-examples                                                                                                                                                                                                                                                                                
Parsed config: Config(OPT_MAX_ITER=600000, OPT_METHOD='auto', DEVICE='auto', FOCAL_LENGTH=1.2, TEXT_MIN_WIDTH=15, TEXT_MIN_HEIGHT=2, TEXT_MIN_ASPECT=1.5, TEXT_MAX_THICKNESS=10, DEBUG_LEVEL=0, DEBUG_OUTPUT='file', EDGE_MAX_OVERLAP=1.0, EDGE_MAX_LENGTH=100.0, EDGE_ANGLE_COST=10.0, EDGE_MAX_ANGLE=7.5, SCREEN_MAX_W=1280, SCREEN_MAX_H=700, PAGE_MARGIN_X=50, PA
GE_MARGIN_Y=20, ADAPTIVE_WINSZ=55, OUTPUT_ZOOM=1.0, OUTPUT_DPI=300, REMAP_DECIMATE=16, NO_BINARY=0, SHEAR_COST=0.0, MAX_CORR=100, RVEC_IDX=(0, 3), TVEC_IDX=(3, 6), CUBIC_IDX=(6, 8), SPAN_MIN_WIDTH=30, SPAN_PX_PER_STEP=20)                                                                                                                                        
W1211 10:52:08.341888  168186 cuda_executor.cc:1802] GPU interconnect information not available: INTERNAL: NVML doesn't support extracting fabric info or NVLink is not used by the device.                                                                                                                                                                          
W1211 10:52:08.343166  168102 cuda_executor.cc:1802] GPU interconnect information not available: INTERNAL: NVML doesn't support extracting fabric info or NVLink is not used by the device.                                                                                                                                                                          
Processing 40 images with batched optimization...                                                                                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                                                                                                     
=== Phase 1: Preprocessing ===                                                                                                                                                                                                                                                                                                                                       
  boston_cooking_a_copy1_copy2_copy3.jpg: 38 spans, 554 points                                                                                                                                                                                                                                                                                                       
  boston_cooking_a_copy1_copy2.jpg: 38 spans, 554 points                                                                                                                                                                                                                                                                                                             
  boston_cooking_a_copy1_copy3.jpg: 38 spans, 554 points                                                                                                                                                                                                                                                                                                             
  boston_cooking_a_copy1.jpg: 38 spans, 554 points                                                                                                                                                                                                                                                                                                                   
  boston_cooking_a_copy2_copy3.jpg: 38 spans, 554 points                                                                                                                                                                                                                                                                                                             
  boston_cooking_a_copy2.jpg: 38 spans, 554 points                                                                                                                                                                                                                                                                                                                   
  boston_cooking_a_copy3.jpg: 38 spans, 554 points                                                                                                                                                                                                                                                                                                                   
  boston_cooking_a.jpg: 38 spans, 554 points                                                                                                                                                                                                                                                                                                                         
  boston_cooking_b_copy1_copy2_copy3.jpg: 38 spans, 475 points                                                                                                                                                                                                                                                                                                       
  boston_cooking_b_copy1_copy2.jpg: 38 spans, 475 points                                                                                                                                                                                                                                                                                                             
  boston_cooking_b_copy1_copy3.jpg: 38 spans, 475 points                                                                                                                                                                                                                                                                                                             
  boston_cooking_b_copy1.jpg: 38 spans, 475 points                                                                                                                                                                                                                                                                                                                   
  boston_cooking_b_copy2_copy3.jpg: 38 spans, 475 points                                                                                                                                                                                                                                                                                                             
  boston_cooking_b_copy2.jpg: 38 spans, 475 points                                                                                                                                                                                                                                                                                                                   
  boston_cooking_b_copy3.jpg: 38 spans, 475 points                                                                                                                                                                                                                                                                                                                   
  boston_cooking_b.jpg: 38 spans, 475 points                                                                                                                                                                                                                                                                                                                         
  finnish_cooking_a_copy1_copy2_copy3.jpg: 40 spans, 369 points                                                                                                                                                                                                                                                                                                      
  finnish_cooking_a_copy1_copy2.jpg: 40 spans, 369 points                                                                                                                                                                                                                                                                                                            
  finnish_cooking_a_copy1_copy3.jpg: 40 spans, 369 points                                                                                                                                                                                                                                                                                                            
  finnish_cooking_a_copy1.jpg: 40 spans, 369 points                                                                                                                                                                                                                                                                                                                  
  finnish_cooking_a_copy2_copy3.jpg: 40 spans, 369 points                                                                                                                                                                                                                                                                                                            
  finnish_cooking_a_copy2.jpg: 40 spans, 369 points                                                                                                                                                                                                                                                                                                                  
  finnish_cooking_a_copy3.jpg: 40 spans, 369 points                                                                                                                                                                                                                                                                                                                  
  finnish_cooking_a.jpg: 40 spans, 369 points                                                                                                                                                                                                                                                                                                                        
  linguistics_thesis_a_copy1_copy2_copy3.jpg: 20 spans, 161 points                                                                                                                                                                                                                                                                                                   
  linguistics_thesis_a_copy1_copy2.jpg: 20 spans, 161 points                                                                                                                                                                                                                                                                                                         
  linguistics_thesis_a_copy1_copy3.jpg: 20 spans, 161 points                                                                                                                                                                                                                                                                                                         
  linguistics_thesis_a_copy1.jpg: 20 spans, 161 points                                                                                                                                                                                                                                                                                                               
  linguistics_thesis_a_copy2_copy3.jpg: 20 spans, 161 points                                                                                                                                                                                                                                                                                                         
  linguistics_thesis_a_copy2.jpg: 20 spans, 161 points                                                                                                                                                                                                                                                                                                               
  linguistics_thesis_a_copy3.jpg: 20 spans, 161 points                                                                                                                                                                                                                                                                                                               
  linguistics_thesis_a.jpg: 20 spans, 161 points                                                                                                                                                                                                                                                                                                                     
  linguistics_thesis_b_copy1_copy2_copy3.jpg: 1 spans, 7 points                                                                                                                                                                                                                                                                                                      
  linguistics_thesis_b_copy1_copy2.jpg: 1 spans, 7 points                                                                                                                                                                                                                                                                                                            
  linguistics_thesis_b_copy1_copy3.jpg: 1 spans, 7 points                                                                                                                                                                                                                                                                                                            
  linguistics_thesis_b_copy1.jpg: 1 spans, 7 points                                                                                                                                                                                                                                                                                                                  
  linguistics_thesis_b_copy2_copy3.jpg: 1 spans, 7 points                                                                                                                                                                                                                                                                                                            
  linguistics_thesis_b_copy2.jpg: 1 spans, 7 points                                                                                                                                                                                                                                                                                                                  
  linguistics_thesis_b_copy3.jpg: 1 spans, 7 points                                                                                                                                                                                                                                                                                                                  
  linguistics_thesis_b.jpg: 1 spans, 7 points                                                                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                                                                                     
=== Phase 2: Parallel Optimization ===                                                                                                                                                                                                                                                                                                                               
  [boston_cooking_a_copy1_copy2_copy3] initial objective is 0.074429                                                                                                                                                                                                                                                                                                 
  [boston_cooking_a_copy1_copy2] initial objective is 0.074429                                                                                                                                                                                                                                                                                                       
  [boston_cooking_a_copy1_copy3] initial objective is 0.074429                                                                                                                                                                                                                                                                                                       
  [boston_cooking_a_copy1] initial objective is 0.074429                                                                                                                                                                                                                                                                                                             
  [boston_cooking_a_copy2_copy3] initial objective is 0.074429                                                                                                                                                                                                                                                                                                       
  [boston_cooking_a_copy2] initial objective is 0.074429                                                                                                                                                                                                                                                                                                             
  [boston_cooking_a_copy3] initial objective is 0.074429                                                                                                                                                                                                                                                                                                             
  [boston_cooking_a] initial objective is 0.074429                                                                                                                                                                                                                                                                                                                   
  [boston_cooking_b_copy1_copy2_copy3] initial objective is 0.131337                                                                                                                                                                                                                                                                                                 
  [boston_cooking_b_copy1_copy2] initial objective is 0.131337                                                                                                                                                                                                                                                                                                       
  [boston_cooking_b_copy1_copy3] initial objective is 0.131337                                                                                                                                                                                                                                                                                                       
  [boston_cooking_b_copy1] initial objective is 0.131337                                                                                                                                                                                                                                                                                                             
  [boston_cooking_b_copy2_copy3] initial objective is 0.131337                                                                                                                                                                                                                                                                                                       
  [boston_cooking_b_copy2] initial objective is 0.131337                                                                                                                                                                                                                                                                                                             
  [boston_cooking_b_copy3] initial objective is 0.131337                                                                                                                                                                                                                                                                                                             
  [boston_cooking_b] initial objective is 0.131337                                                                                                                                                                                                                                                                                                                   
  [finnish_cooking_a_copy1_copy2_copy3] initial objective is 0.032092                                                                                                                                                                                                                                                                                                
  [finnish_cooking_a_copy1_copy2] initial objective is 0.032092                                                                                                                                                                                                                                                                                                      
  [finnish_cooking_a_copy1_copy3] initial objective is 0.032092                                                                                                                                                                                                                                                                                                      
  [finnish_cooking_a_copy1] initial objective is 0.032092                                                                                                                                                                                                                                                                                                            
  [finnish_cooking_a_copy2_copy3] initial objective is 0.032092                                                                                                                                                                                                                                                                                                      
  [finnish_cooking_a_copy2] initial objective is 0.032092                                                                                                                                                                                                                                                                                                            
  [finnish_cooking_a_copy3] initial objective is 0.032092                                                                                                                                                                                                                                                                                                            
  [finnish_cooking_a] initial objective is 0.032092                                                                                                                                                                                                                                                                                                                  
  [linguistics_thesis_a_copy1_copy2_copy3] initial objective is 0.024761                                                                                                                                                                                                                                                                                             
  [linguistics_thesis_a_copy1_copy2] initial objective is 0.024761                                                                                                                                                                                                                                                                                                   
  [linguistics_thesis_a_copy1_copy3] initial objective is 0.024761                                                                                                                                                                                                                                                                                                   
  [linguistics_thesis_a_copy1] initial objective is 0.024761                                                                                                                                                                                                                                                                                                         
  [linguistics_thesis_a_copy2_copy3] initial objective is 0.024761                                                                                                                                                                                                                                                                                                   
  [linguistics_thesis_a_copy2] initial objective is 0.024761                                                                                                                                                                                                                                                                                                         
  [linguistics_thesis_a_copy3] initial objective is 0.024761                                                                                                                                                                                                                                                                                                         
  [linguistics_thesis_a] initial objective is 0.024761                                                                                                                                                                                                                                                                                                               
  [linguistics_thesis_b_copy1_copy2_copy3] initial objective is 0.000024                                                                                                                                                                                                                                                                                             
  [linguistics_thesis_b_copy1_copy2] initial objective is 0.000024                                                                                                                                                                                                                                                                                                   
  [linguistics_thesis_b_copy1_copy3] initial objective is 0.000024                                                                                                                                                                                                                                                                                                   
  [linguistics_thesis_b_copy1] initial objective is 0.000024                                                                                                                                                                                                                                                                                                         
  [linguistics_thesis_b_copy2_copy3] initial objective is 0.000024                                                                                                                                                                                                                                                                                                   
  [linguistics_thesis_b_copy2] initial objective is 0.000024                                                                                                                                                                                                                                                                                                         
  [linguistics_thesis_b_copy3] initial objective is 0.000024                                                                                                                                                                                                                                                                                                         
  [linguistics_thesis_b] initial objective is 0.000024                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                                                                     
  Running 40 parallel L-BFGS optimizations on NVIDIA GEFORCE RTX 3090...                                                                                                                                                                                                                                                                                             
  parallel L-BFGS optimization took 4.75s                                                                                                                                                                                                                                                                                                                            
  [boston_cooking_a_copy1_copy2_copy3] final objective is 0.004874                                                                                                                                                                                                                                                                                                   
  [boston_cooking_a_copy1_copy2] final objective is 0.004874                                                                                                                                                                                                                                                                                                         
  [boston_cooking_a_copy1_copy3] final objective is 0.004874                                                                                                                                                                                                                                                                                                         
  [boston_cooking_a_copy1] final objective is 0.004874                                                                                                                                                                                                                                                                                                               
  [boston_cooking_a_copy2_copy3] final objective is 0.004874                                                                                                                                                                                                                                                                                                         
  [boston_cooking_a_copy2] final objective is 0.004874                                                                                                                                                                                                                                                                                                               
  [boston_cooking_a_copy3] final objective is 0.004874                                                                                                                                                                                                                                                                                                               
  [boston_cooking_a] final objective is 0.004874                                                                                                                                                                                                                                                                                                                     
  [boston_cooking_b_copy1_copy2_copy3] final objective is 0.003856                                                                                                                                                                                                                                                                                                   
  [boston_cooking_b_copy1_copy2] final objective is 0.003856                                                                                                                                                                                                                                                                                                         
  [boston_cooking_b_copy1_copy3] final objective is 0.003856                                                                                                                                                                                                                                                                                                         
  [boston_cooking_b_copy1] final objective is 0.003856                                                                                                                                                                                                                                                                                                               
  [boston_cooking_b_copy2_copy3] final objective is 0.003856                                                                                                                                                                                                                                                                                                         
  [boston_cooking_b_copy2] final objective is 0.003856                                                                                                                                                                                                                                                                                                               
  [boston_cooking_b_copy3] final objective is 0.003856                                                                                                                                                                                                                                                                                                               
  [boston_cooking_b] final objective is 0.003856                                                                                                                                                                                                                                                                                                                     
  [finnish_cooking_a_copy1_copy2_copy3] final objective is 0.018795                                                                                                                                                                                                                                                                                                  
  [finnish_cooking_a_copy1_copy2] final objective is 0.018795                                                                                                                                                                                                                                                                                                        
  [finnish_cooking_a_copy1_copy3] final objective is 0.018795                                                                                                                                                                                                                                                                                                        
  [finnish_cooking_a_copy1] final objective is 0.018795                                                                                                                                                                                                                                                                                                              
  [finnish_cooking_a_copy2_copy3] final objective is 0.018795                                                                                                                                                                                                                                                                                                        
  [finnish_cooking_a_copy2] final objective is 0.018795                                                                                                                                                                                                                                                                                                              
  [finnish_cooking_a_copy3] final objective is 0.018795                                                                                                                                                                                                                                                                                                              
  [finnish_cooking_a] final objective is 0.018795                                                                                                                                                                                                                                                                                                                    
  [linguistics_thesis_a_copy1_copy2_copy3] final objective is 0.000620                                                                                                                                                                                                                                                                                               
  [linguistics_thesis_a_copy1_copy2] final objective is 0.000620                                                                                                                                                                                                                                                                                                     
  [linguistics_thesis_a_copy1_copy3] final objective is 0.000620                                                                                                                                                                                                                                                                                                     
  [linguistics_thesis_a_copy1] final objective is 0.000620                                                                                                                                                                                                                                                                                                           
  [linguistics_thesis_a_copy2_copy3] final objective is 0.000620                                                                                                                                                                                                                                                                                                     
  [linguistics_thesis_a_copy2] final objective is 0.000620                                                                                                                                                                                                                                                                                                           
  [linguistics_thesis_a_copy3] final objective is 0.000620                                                                                                                                                                                                                                                                                                           
  [linguistics_thesis_a] final objective is 0.000620                                                                                                                                                                                                                                                                                                                 
  [linguistics_thesis_b_copy1_copy2_copy3] final objective is 0.000021                                                                                                                                                                                                                                                                                               
  [linguistics_thesis_b_copy1_copy2] final objective is 0.000021                                                                                                                                                                                                                                                                                                     
  [linguistics_thesis_b_copy1_copy3] final objective is 0.000021                                                                                                                                                                                                                                                                                                     
  [linguistics_thesis_b_copy1] final objective is 0.000021                                                                                                                                                                                                                                                                                                           
  [linguistics_thesis_b_copy2_copy3] final objective is 0.000021                                                                                                                                                                                                                                                                                                     
  [linguistics_thesis_b_copy2] final objective is 0.000021                                                                                                                                                                                                                                                                                                           
  [linguistics_thesis_b_copy3] final objective is 0.000021                                                                                                                                                                                                                                                                                                           
  [linguistics_thesis_b] final objective is 0.000021                                                                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                                                                                                     
=== Phase 3: Generating Outputs ===                                                                                                                                                                                                                                                                                                                                  
  got page dims 1.1603141905430236 x 1.790592536206604                                                                                                                                                                                                                                                                                                               
  output will be 1904x2928                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.160314181795095 x 1.7905925024205593                                                                                                                                                                                                                                                                                                               
  output will be 1904x2928                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.2252621226960194 x 1.9688518629959182                                                                                                                                                                                                                                                                                                              
  output will be 2016x3216                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.1603142127377444 x 1.7905926068342917                                                                                                                                                                                                                                                                                                              
  output will be 1904x2928                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.2252621226961955 x 1.9688518629960496                                                                                                                                                                                                                                                                                                              
  output will be 2016x3216                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.160045714992826 x 1.7901027681930066                                                                                                                                                                                                                                                                                                               
  output will be 1904x2928                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.1603141885573802 x 1.7905925220138743                                                                                                                                                                                                                                                                                                              
  output will be 1904x2928                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.2252621226975609 x 1.9688518629981273                                                                                                                                                                                                                                                                                                              
  output will be 2016x3216                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.1603142079137931 x 1.7905925907057059                                                                                                                                                                                                                                                                                                              
  got page dims 1.118493963362335 x 1.7448090231890947                                                                                                                                                                                                                                                                                                               
  got page dims 1.2252621226966474 x 1.968851862996814                                                                                                                                                                                                                                                                                                               
  output will be 2016x3216                                                                                                                                                                                                                                                                                                                                           
  output will be 1904x2928                                                                                                                                                                                                                                                                                                                                           
  output will be 1472x2288                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.225262122697142 x 1.9688518629975615                                                                                                                                                                                                                                                                                                               
  output will be 2016x3216                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.1600460927164487 x 1.7901034909346025                                                                                                                                                                                                                                                                                                              
  output will be 1904x2928                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.2252621226960452 x 1.9688518629956095                                                                                                                                                                                                                                                                                                              
  output will be 2016x3216                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.1184511889186997 x 1.744756143798338                                                                                                                                                                                                                                                                                                               
  output will be 1472x2288                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.1603141828537773 x 1.7905925076005955                                                                                                                                                                                                                                                                                                              
  output will be 1904x2928                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.2252621226968328 x 1.9688518629970637                                                                                                                                                                                                                                                                                                              
  output will be 2016x3216                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.2252621226941935 x 1.9688518629927134                                                                                                                                                                                                                                                                                                              
  output will be 2016x3216                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.1184494581218956 x 1.7447540976135476                                                                                                                                                                                                                                                                                                              
  output will be 1472x2288                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.118463334329836 x 1.7447743752182348                                                                                                                                                                                                                                                                                                               
  output will be 1472x2288                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.1184524131481675 x 1.7447561305007693                                                                                                                                                                                                                                                                                                              
  output will be 1472x2288                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.1184489117334069 x 1.7447528215828156                                                                                                                                                                                                                                                                                                              
  output will be 1472x2288                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.1184543519579357 x 1.7447583950285608                                                                                                                                                                                                                                                                                                              
  output will be 1472x2288                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.1184569694231685 x 1.744761631593441                                                                                                                                                                                                                                                                                                               
  output will be 1472x2288                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.257905832125835 x 1.9022359055195421                                                                                                                                                                                                                                                                                                               
  output will be 2912x4384                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.2579059176064795 x 1.9022360020363083                                                                                                                                                                                                                                                                                                              
  output will be 2912x4384                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.2579059708355727 x 1.9022360621361023                                                                                                                                                                                                                                                                                                              
  output will be 2912x4384                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.2579058459097712 x 1.9022359210823137                                                                                                                                                                                                                                                                                                              
  output will be 2912x4384                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.2579059143475397 x 1.9022359983566033                                                                                                                                                                                                                                                                                                              
  output will be 2912x4384                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.2579058870298576 x 1.902235967512232                                                                                                                                                                                                                                                                                                               
  output will be 2912x4384                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.4683131541666916 x 2.047168900289984                                                                                                                                                                                                                                                                                                               
  output will be 3392x4720                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.2579058994452106 x 1.902235981529938                                                                                                                                                                                                                                                                                                               
  output will be 2912x4384                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.468313154166679 x 2.0471689002899964                                                                                                                                                                                                                                                                                                               
  output will be 3392x4720                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.4683131541666743 x 2.0471689002899596                                                                                                                                                                                                                                                                                                              
  output will be 3392x4720                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.2579059539467474 x 1.902236043066379                                                                                                                                                                                                                                                                                                               
  output will be 2912x4384                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.468313154166679 x 2.0471689002899964                                                                                                                                                                                                                                                                                                               
  output will be 3392x4720                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.468313154166679 x 2.0471689002899964                                                                                                                                                                                                                                                                                                               
  output will be 3392x4720                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.468313154166679 x 2.0471689002899964                                                                                                                                                                                                                                                                                                               
  output will be 3392x4720                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.468313154166679 x 2.0471689002899964                                                                                                                                                                                                                                                                                                               
  output will be 3392x4720                                                                                                                                                                                                                                                                                                                                           
  got page dims 1.4683131541666636 x 2.04716890028996                                                                                                                                                                                                                                                                                                                
  output will be 3392x4720                                                                                                                                                                                                                                                                                                                                           
  wrote boston_cooking_a_copy1_copy2_copy3_thresh.png                                                                                                                                                                                                                                                                                                                
  wrote boston_cooking_a_copy1_copy2_thresh.png                                                                                                                                                                                                                                                                                                                      
  wrote boston_cooking_a_copy1_copy3_thresh.png                                                                                                                                                                                                                                                                                                                      
  wrote boston_cooking_a_copy1_thresh.png                                                                                                                                                                                                                                                                                                                            
  wrote boston_cooking_a_copy2_copy3_thresh.png                                                                                                                                                                                                                                                                                                                      
  wrote boston_cooking_a_copy2_thresh.png                                                                                                                                                                                                                                                                                                                            
  wrote boston_cooking_a_copy3_thresh.png                                                                                                                                                                                                                                                                                                                            
  wrote boston_cooking_a_thresh.png                                                                                                                                                                                                                                                                                                                                  
  wrote boston_cooking_b_copy1_copy2_copy3_thresh.png                                                                                                                                                                                                                                                                                                                
  wrote boston_cooking_b_copy1_copy2_thresh.png                                                                                                                                                                                                                                                                                                                      
  wrote boston_cooking_b_copy1_copy3_thresh.png                                                                                                                                                                                                                                                                                                                      
  wrote boston_cooking_b_copy1_thresh.png                                                                                                                                                                                                                                                                                                                            
  wrote boston_cooking_b_copy2_copy3_thresh.png                                                                                                                                                                                                                                                                                                                      
  wrote boston_cooking_b_copy2_thresh.png                                                                                                                                                                                                                                                                                                                            
  wrote boston_cooking_b_copy3_thresh.png                                                                                                                                                                                                                                                                                                                            
  wrote boston_cooking_b_thresh.png                                                                                                                                                                                                                                                                                                                                  
  wrote finnish_cooking_a_copy1_copy2_copy3_thresh.png                                                                                                                                                                                                                                                                                                               
  wrote finnish_cooking_a_copy1_copy2_thresh.png                                                                                                                                                                                                                                                                                                                     
  wrote finnish_cooking_a_copy1_copy3_thresh.png                                                                                                                                                                                                                                                                                                                     
  wrote finnish_cooking_a_copy1_thresh.png                                                                                                                                                                                                                                                                                                                           
  wrote finnish_cooking_a_copy2_copy3_thresh.png                                                                                                                                                                                                                                                                                                                     
  wrote finnish_cooking_a_copy2_thresh.png                                                                                                                                                                                                                                                                                                                           
  wrote finnish_cooking_a_copy3_thresh.png                                                                                                                                                                                                                                                                                                                           
  wrote finnish_cooking_a_thresh.png                                                                                                                                                                                                                                                                                                                                 
  wrote linguistics_thesis_a_copy1_copy2_copy3_thresh.png                                                                                                                                                                                                                                                                                                            
  wrote linguistics_thesis_a_copy1_copy2_thresh.png                                                                                                                                                                                                                                                                                                                  
  wrote linguistics_thesis_a_copy1_copy3_thresh.png                                                                                                                                                                                                                                                                                                                  
  wrote linguistics_thesis_a_copy1_thresh.png                                                                                                                                                                                                                                                                                                                        
  wrote linguistics_thesis_a_copy2_copy3_thresh.png                                                                                                                                                                                                                                                                                                                  
  wrote linguistics_thesis_a_copy2_thresh.png                                                                                                                                                                                                                                                                                                                        
  wrote linguistics_thesis_a_copy3_thresh.png                                                                                                                                                                                                                                                                                                                        
  wrote linguistics_thesis_a_thresh.png                                                                                                                                                                                                                                                                                                                              
  wrote linguistics_thesis_b_copy1_copy2_copy3_thresh.png                                                                                                                                                                                                                                                                                                            
  wrote linguistics_thesis_b_copy1_copy2_thresh.png                                                                                                                                                                                                                                                                                                                  
  wrote linguistics_thesis_b_copy1_copy3_thresh.png                                                                                                                                                                                                                                                                                                                  
  wrote linguistics_thesis_b_copy1_thresh.png                                                                                                                                                                                                                                                                                                                        
  wrote linguistics_thesis_b_copy2_copy3_thresh.png                                                                                                                                                                                                                                                                                                                  
  wrote linguistics_thesis_b_copy2_thresh.png                                                                                                                                                                                                                                                                                                                        
  wrote linguistics_thesis_b_copy3_thresh.png                                                                                                                                                                                                                                                                                                                        
  wrote linguistics_thesis_b_thresh.png                                                                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                                                                     
=== Summary ===                                                                                                                                                                                                                                                                                                                                                      
  ✓ boston_cooking_a_copy1_copy2_copy3_thresh.png                                                                                                                                                                                                                                                                                                                    
  ✓ boston_cooking_a_copy1_copy2_thresh.png                                                                                                                                                                                                                                                                                                                          
  ✓ boston_cooking_a_copy1_copy3_thresh.png                                                                                                                                                                                                                                                                                                                          
  ✓ boston_cooking_a_copy1_thresh.png                                                                                                                                                                                                                                                                                                                                
  ✓ boston_cooking_a_copy2_copy3_thresh.png                                                                                                                                                                                                                                                                                                                          
  ✓ boston_cooking_a_copy2_thresh.png                                                                                                                                                                                                                                                                                                                                
  ✓ boston_cooking_a_copy3_thresh.png                                                                                                                                                                                                                                                                                                                                
  ✓ boston_cooking_a_thresh.png                                                                                                                                                                                                                                                                                                                                      
  ✓ boston_cooking_b_copy1_copy2_copy3_thresh.png                                                                                                                                                                                                                                                                                                                    
  ✓ boston_cooking_b_copy1_copy2_thresh.png                                                                                                                                                                                                                                                                                                                          
  ✓ boston_cooking_b_copy1_copy3_thresh.png                                                                                                                                                                                                                                                                                                                          
  ✓ boston_cooking_b_copy1_thresh.png                                                                                                                                                                                                                                                                                                                                
  ✓ boston_cooking_b_copy2_copy3_thresh.png                                                                                                                                                                                                                                                                                                                          
  ✓ boston_cooking_b_copy2_thresh.png                                                                                                                                                                                                                                                                                                                                
  ✓ boston_cooking_b_copy3_thresh.png                                                                                                                                                                                                                                                                                                                                
  ✓ boston_cooking_b_thresh.png                                                                                                                                                                                                                                                                                                                                      
  ✓ finnish_cooking_a_copy1_copy2_copy3_thresh.png                                                                                                                                                                                                                                                                                                                   
  ✓ finnish_cooking_a_copy1_copy2_thresh.png                                                                                                                                                                                                                                                                                                                         
  ✓ finnish_cooking_a_copy1_copy3_thresh.png                                                                                                                                                                                                                                                                                                                         
  ✓ finnish_cooking_a_copy1_thresh.png                                                                                                                                                                                                                                                                                                                               
  ✓ finnish_cooking_a_copy2_copy3_thresh.png                                                                                                                                                                                                                                                                                                                         
  ✓ finnish_cooking_a_copy2_thresh.png                                                                                                                                                                                                                                                                                                                               
  ✓ finnish_cooking_a_copy3_thresh.png                                                                                                                                                                                                                                                                                                                               
  ✓ finnish_cooking_a_thresh.png                                                                                                                                                                                                                                                                                                                                     
  ✓ linguistics_thesis_a_copy1_copy2_copy3_thresh.png                                                                                                                                                                                                                                                                                                                
  ✓ linguistics_thesis_a_copy1_copy2_thresh.png                                                                                                                                                                                                                                                                                                                      
  ✓ linguistics_thesis_a_copy1_copy3_thresh.png                                                                                                                                                                                                                                                                                                                      
  ✓ linguistics_thesis_a_copy1_thresh.png                                                                                                                                                                                                                                                                                                                            
  ✓ linguistics_thesis_a_copy2_copy3_thresh.png                                                                                                                                                                                                                                                                                                                      
  ✓ linguistics_thesis_a_copy2_thresh.png                                                                                                                                                                                                                                                                                                                            
  ✓ linguistics_thesis_a_copy3_thresh.png                                                                                                                                                                                                                                                                                                                            
  ✓ linguistics_thesis_a_thresh.png                                                                                                                                                                                                                                                                                                                                  
  ✓ linguistics_thesis_b_copy1_copy2_copy3_thresh.png                                                                                                                                                                                                                                                                                                                
  ✓ linguistics_thesis_b_copy1_copy2_thresh.png                                                                                                                                                                                                                                                                                                                      
  ✓ linguistics_thesis_b_copy1_copy3_thresh.png                                                                                                                                                                                                                                                                                                                      
  ✓ linguistics_thesis_b_copy1_thresh.png                                                                                                                                                                                                                                                                                                                            
  ✓ linguistics_thesis_b_copy2_copy3_thresh.png                                                                                                                                                                                                                                                                                                                      
  ✓ linguistics_thesis_b_copy2_thresh.png                                                                                                                                                                                                                                                                                                                            
  ✓ linguistics_thesis_b_copy3_thresh.png                                                                                                                                                                                                                                                                                                                            
  ✓ linguistics_thesis_b_thresh.png                                                                                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                                                                                                                     
real    0m11.207s                                                                                                                                                                                                                                                                                                                                                    
user    0m50.746s                                                                                                                                                                                                                                                                                                                                                    
sys     0m23.155s  
  • Trunk (just the original 5 images to show objective value reached):
(page-dewarp) louis 🌟 ~/dev/page-dewarp/example_input $ time just refresh-examples
Parsed config: Config(OPT_MAX_ITER=600000, OPT_METHOD='auto', DEVICE='auto', FOCAL_LENGTH=1.2, TEXT_MIN_WIDTH=15, TEXT_MIN_HEIGHT=2, TEXT_MIN_ASPECT=1.5, TEXT_MAX_THICKNESS=10, DEBUG_LEVEL=0, DEBUG_OUTPUT='file', EDGE_MAX_OVERLAP=1.0, EDGE_MAX_LENGTH=100.0, EDGE_ANGLE_COST=10.0, EDGE_MAX_ANGLE=7.5, SCREEN_MAX_W=1280, SCREEN_MAX_H=700, PAGE_MARGIN_X=50, PAGE_MARGIN_Y=20, ADAPTIVE_WINSZ=55, OUTPUT_ZOOM=1.0, OUTPUT_DPI=300, REMAP_DECIMATE=16, NO_BINARY=0, SHEAR_COST=0.0, MAX_CORR=100, RVEC_IDX=(0, 3), TVEC_IDX=(3, 6), CUBIC_IDX=(6, 8), SPAN_MIN_WIDTH=30, SPAN_PX_PER_STEP=20)
Loaded boston_cooking_a.jpg at size='2448x3264' --> resized='490x653'
  got 38 spans with 554 points.
W1211 02:46:47.124141  146157 cuda_executor.cc:1802] GPU interconnect information not available: INTERNAL: NVML doesn't support extracting fabric info or NVLink is not used by the device.
W1211 02:46:47.125528  146054 cuda_executor.cc:1802] GPU interconnect information not available: INTERNAL: NVML doesn't support extracting fabric info or NVLink is not used by the device.
  initial objective is 0.07442903186407843
  optimizing 600 parameters on NVIDIA GEFORCE RTX 3090...
  optimization (L-BFGS-B + JAX autodiff) took 1.82s, 63 evals
  final objective is 0.008789
  got page dims 1.1949972698506042 x 1.855141368062113
  output will be 1968x3040
  wrote boston_cooking_a_thresh.png

Loaded boston_cooking_b.jpg at size='2448x3264' --> resized='490x653'
  got 38 spans with 475 points.
  initial objective is 0.13133749948751292
  optimizing 521 parameters on NVIDIA GEFORCE RTX 3090...
  optimization (L-BFGS-B + JAX autodiff) took 1.52s, 107 evals
  final objective is 0.005931
  got page dims 1.2644529217895766 x 1.9970900548613895
  output will be 2080x3264
  wrote boston_cooking_b_thresh.png

Loaded finnish_cooking_a.jpg at size='1964x2619' --> resized='491x655'
  got 40 spans with 369 points.
  initial objective is 0.0320922595402046
  optimizing 417 parameters on NVIDIA GEFORCE RTX 3090...
  optimization (L-BFGS-B + JAX autodiff) took 1.43s, 77 evals
  final objective is 0.023118
  got page dims 1.2831832262179288 x 1.980280861428031
  output will be 1696x2608
  wrote finnish_cooking_a_thresh.png

Loaded linguistics_thesis_a.jpg at size='3456x4608' --> resized='494x658'
  got 20 spans with 161 points.
  initial objective is 0.02476134606067954
  optimizing 189 parameters on NVIDIA GEFORCE RTX 3090...
  optimization (L-BFGS-B + JAX autodiff) took 1.24s, 78 evals
  final objective is 0.001388
  got page dims 1.228849178263319 x 1.9130865598117066
  output will be 2848x4416
  wrote linguistics_thesis_a_thresh.png

Loaded linguistics_thesis_b.jpg at size='3456x4608' --> resized='494x658'
  detecting lines because only 1 text spans
  got 1 spans with 7 points.
  initial objective is 2.4258143062261982e-05
  optimizing 16 parameters on NVIDIA GEFORCE RTX 3090...
  optimization (L-BFGS-B + JAX autodiff) took 0.71s, 22 evals
  final objective is 0.000021
  got page dims 1.4682518754030853 x 2.0474673262751604
  output will be 3392x4720
  wrote linguistics_thesis_b_thresh.png


real    0m10.043s
user    0m34.589s
sys     0m3.294s

@vercel
Copy link

vercel bot commented Dec 11, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
page-dewarp Ready Ready Preview Comment Dec 11, 2025 11:58am

@lmmx lmmx changed the title perf: speed up CUDA on the test corpus perf: faster batch, correct CUDA numerics Dec 11, 2025
@lmmx lmmx moved this from 🐣 Hatching to 🏗 WIP in Planner Dec 11, 2025
@lmmx lmmx self-assigned this Dec 11, 2025
@lmmx lmmx added ⚡ performance Make things go fast 📦 dependencies Dependency related labels Dec 11, 2025
@lmmx lmmx merged commit 7f52aa3 into master Dec 11, 2025
3 of 5 checks passed
@lmmx lmmx deleted the crazy-fast-cuda branch December 11, 2025 11:57
@github-project-automation github-project-automation bot moved this from 🏗 WIP to ✅ Done in Planner Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📦 dependencies Dependency related ⚡ performance Make things go fast

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants