GithubHelp home page GithubHelp logo

yi-jiayu / shuffled-images Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 30 KB

A fully-automated greedy square jigsaw puzzle solver based on the paper of the same name by Pomeranz et al.

Home Page: https://blog.jiayu.co/2019/12/my-huawei-honorcup-marathon-2-experience/

Python 21.97% Jupyter Notebook 78.03%

shuffled-images's Introduction

shuffled-images

Square jigsaw puzzle solver based on [1]. Generates solutions for the Huawei Honorcup Marathon 2

Prerequisites

  • Python 3.6+

Quickstart

  1. Create a new virtual environment and install dependencies:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
  1. Dataset can be downloaded from https://yadi.sk/d/BmnFhkaD1Vy4vA
  2. Extract the data into data/ in the project root
  3. To run the solver on an image cut into 8x8 parts and scrambled:
$ python main.py data/data_train/64/1623.png 8 8
1623.png
50 8 43 45 25 57 52 35 11 36 56 63 40 41 5 12 0 21 1 27 13 46 33 17 31 34 58 60 15 59 14 38 54 23 26 49 18 37 55 16 32 42 47 6 3 53 7 2 62 61 30 39 29 44 48 24 22 9 10 28 20 51 19 4
1623.png,5.762885261,0.9553571428571429,1

The first two lines of the output are printed to stdout and are in the contest submission format, while the 3rd line was actually printed to stderr and contains some statistics about the solving process in the format basename,time taken,score,iterations.

  1. To view the unscrambled image, you can pass the tile indices (second line of the output above) to rearrange_image.py via standard input. The rest of the arguments are the input image, number of rows and columns and output file.
$ pbpaste | python rearrange_image.py data/data_train/64/1623.png 8 8 out.png

Running in parallel entire dataset

I used GNU Parallel to run the solver on the 300-600 images in each group. For example, to generate solutions for all the images in the data/data_test2_blank/64 folder:

mkdir -p results/A3
ls data/data_test2_blank/64 | parallel "python main.py data/data_test2_blank/64/{} 8 8 > results/A3/{}.txt"

lhis writes the solutions for each image into the results/A3 folder while printing statistics to the terminal through standard error.

To generate the final submission, just concatenate all the results together:

cat results/A3/* > results/A3.txt

[1]: D. Pomeranz, M. Shemesh, and O. Ben-Shahar, A fully automated greedy square jigsaw puzzle solver, In the Proceedings of the IEEE International Conference on Computer Vision and Pattern Recognition (CVPR), Colorado Springs, USA, June, pp. 9-16, 2011. See also the project page for more demos, info, and code

shuffled-images's People

Contributors

yi-jiayu avatar

Watchers

James Cloos avatar  avatar Rong Ying avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.