2.1.10 • Published 8 months ago

@prosopo/datasets-fs v2.1.10

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
8 months ago

README

How to produce captchas

You need 3 files:

  1. a json file containing labelled data in the form:

    [
        {
            "label": "dog",
            "data": "http://example.com/a.png"
        },
        {
            "label": "cat",
            "data": "http://example.com/b.png"
        },
        ...
    ]
  2. a json file containing unlabelled data in the form:

    [
        {
            "data": "http://example.com/c.png"
        },
        {
            "data": "http://example.com/d.png"
        },
        ...
    ]
  3. (optional) a json file with an array of labels which unlabelled data can be categorised into. If not specified will default to the same labels as seen in the labelled data.

Then build and run the cli, passing appropriate parameters: npm run build && node ./dist/js/cli.js generate --labelled /path/to/my/labelled/data.json --unlabelled /path/to/my/unlabelled/data.json --seed 0 --labels /path/to/my/labels.json --output /path/to/the/output/captchas.json

Use node ./dist/js/cli.ts --help to inspect other parameters.

Commands:

  1. flatten converts a hierarchical directory structure into a single directory with corresponding map file, e.g.

    data/
        dog/
            a.png
            ...
        cat/
            b.png
            ...

    into

    data/
        a.png
        b.png
        ...
    map.json

    where map.json looks like:

    [
        {
            "label": "dog",
            "data": "http://example.com/a.png"
        },
        {
            "label": "cat",
            "data": "http://example.com/b.png"
        },
        ...
    ]

    e.g. npm run -w @prosopo/datasets-fs build && node packages/datasets-fs/dist/cli.js flatten --in ~/bench/test/data --out ~/bench/test/flat --overwrite

  2. generateDistinct takes the 3 files described above and produces captcha challenges comprising 2 rounds, one labelled and one unlabelled. e.g. npm run -w @prosopo/datasets-fs build && node packages/datasets-fs/dist/cli.js generate distinct --out ~/bench/test/captchas.json --labelled ~/bench/test/flat/data.json --unlabelled ~/bench/test/flat/data.json --seed 0 --size 9 --allow-duplicates --solved 1 --unsolved 1 --overwrite --labels ~/bench/test/flat/labels.json

  3. generateUnion takes the 3 files described above and produces captcha challenges comprising one or more rounds, mixing labelled and unlabelled data into a single round. e.g. npm run -w @prosopo/datasets-fs build && node packages/datasets-fs/dist/cli.js generate union --out ~/bench/test/captchas-union.json --labelled ~/bench/test/flat/data.json --unlabelled ~/bench/test/flat/data.json --seed 0 --size 9 --allow-duplicates --count 2 --overwrite --labels ~/bench/test/flat/labels.json
  4. 'labels' gets all labels from a data json. e.g. npm run -w @prosopo/datasets-fs build && node packages/datasets-fs/dist/cli.js labels --data ~/bench/test/flat/data2.json
  5. 'get' fetches all images using a GET request, displaying errors for any images which hit 404 or not OK. e.g. npm run -w @prosopo/datasets-fs build && node packages/datasets-fs/dist/cli.js get --data ~/bench/test/flat/data2.json
  6. 'relocate' rewrites the url of images in a json file. e.g. npm run -w @prosopo/datasets-fs build && node packages/datasets-fs/dist/cli.js relocate --from example.com --to web.site --data ~/bench/test/flat/data2.json
  7. 'scale' rescales images in a flat directory structure to a given size. e.g. npm run -w @prosopo/datasets-fs build && node packages/datasets-fs/dist/cli.js scale --data ~/bench/test/flat/data.json --out ~/bench/test/flat/images2 --overwrite --size 128

Generating test data

The test data was generated using:

cli generate-v1 --min-correct 1 --max-correct 6 --labelled $PWD/src/tests/data/flat_resized/data.json --unlabelled $PWD/src/tests/data/flat_resized/data.json --out $PWD/src/tests/data/flat_resized/captchas_v1.json --solved 50 --unsolved 50 --seed 0 --allowDuplicates --seed 0

cli generate-v2 --count 100 --min-correct 1 --min-incorrect 1 --min-labelled 2 --max-labelled 7 --labelled $PWD/src/tests/data/flat_resized/data.json --unlabelled $PWD/src/tests/data/flat_resized/data.json --out $PWD/src/tests/data/flat_resized/captchas_v2.json --seed 0 --allowDuplicates --seed 0

cli relocate --from '${repo}' --to newwebsite.com --input $PWD/src/tests/data/flat_resized/data.json --output $PWD/src/tests/data/flat_resized/relocated_data.json --overwrite

cli labels --input $PWD/src/tests/data/flat_resized/data.json --output $PWD/src/tests/data/flat_resized/labels.json --overwrite

cli flatten --in $PWD/src/tests/data/hierarchical --out $PWD/src/tests/data/flat --overwrite

cli resize --square --size 128 --in $PWD/src/tests/data/flat/data.json --out $PWD/src/tests/data/flat_resized --overwrite

cli is an alias to npm run build && npm run cli --

2.1.9

8 months ago

2.1.10

8 months ago

2.1.8

8 months ago

2.1.7

8 months ago

2.1.6

8 months ago

2.1.5

9 months ago

2.1.2

9 months ago

2.1.1

9 months ago

2.1.4

9 months ago

2.1.3

9 months ago

2.1.0

9 months ago

2.0.3

10 months ago

2.0.2

10 months ago

1.0.2

1 year ago

1.0.1

1 year ago

2.0.1

10 months ago

2.0.0

11 months ago

0.3.42

1 year ago

0.3.41

1 year ago

0.3.40

1 year ago

0.3.39

1 year ago

0.3.38

1 year ago

0.3.37

1 year ago

0.3.36

1 year ago

0.3.5

1 year ago

0.3.4

1 year ago

0.3.3

1 year ago

0.3.2

1 year ago

0.3.1

1 year ago

0.2.41

1 year ago

0.2.40

1 year ago

0.2.39

1 year ago

0.2.38

1 year ago

0.2.37

1 year ago

0.2.36

1 year ago

0.2.33

1 year ago

0.2.32

1 year ago

0.2.29

1 year ago

0.2.25

1 year ago

0.2.24

1 year ago

0.2.23

1 year ago

0.2.22

1 year ago

0.2.21

1 year ago

0.2.20

1 year ago

0.2.19

2 years ago

0.2.17

2 years ago

0.2.16

2 years ago

0.2.15

2 years ago

0.2.14

2 years ago

0.2.13

2 years ago

0.2.11

2 years ago

0.2.10

2 years ago

0.2.9

2 years ago

0.2.8

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.19

2 years ago

0.1.18

2 years ago

0.1.17

2 years ago