Skip to main content

A downloader for e621.net with meant for iterability, using e621 db post exports, designed for deep learning.

Project description

py621dl - an iterable E621 downloader

This package is meant to be used in deep learning applications and automation, not as a means to download specific images and post IDs or searching for tags. For that application, please check out py621 which is not related to this package in any way.

The package is meant to be used with the official db export format from E621, posts information. See here for available db exports and here for general information on the API.

!! This is a pre-release version, and is not meant for production use !!

Proper documentation, tests, and automated updates to the package will be added later.

Installation

You can install the package using pip install py621dl on python>=3.11

Usage

The E621Downloader class must be initialized using the Reader class, to which the csv file must be passed. The Reader supports only the official db export csv files of the format "posts-YYYY-MM-DD.csv.gz", either compressed or uncompressed.

The E621Downloader class can be initialized with the following parameters:

  • csv_reader: the Reader object
  • timeout: the timeout for the requests, in seconds
  • retries: the number of retries for the requests

It can be used as an iterable, yielding lists of np.ndarray objects of the images. The list size will depend on your batch_size specified for Reader. The images are of opencv BGR format. The downloader automatically handles and filters deleted or flagged posts, and will attempt to fill the batch with new images so that it will always yield a full batch.

The Reader class can be initialized with the following parameters:

  • csv_file: the path to the csv file
  • batch_size: the size of the batch to be returned by the E621Downloader
  • excluded_tags: a list of E621 tags to be excluded from the results
  • minimum_score: the minimum score of the posts to be included in the results
  • chunk_size: the size of the chunk to be read from the csv file at once
  • checkpoint_file: the path to the checkpoint file, to resume from any point. If path doesn't exist, a new file will be created.
  • repeat: whether to repeat from the beginning of the csv file when the end is reached automatically. Otherwise StopIteration is raised. E621Downloader handles this exception and raises its own StopIteration when the end is reached.

Example use

from py621dl import Reader, E621Downloader

reader = Reader("posts-2022-10-30.csv.gz")
downloader = E621Downloader(reader, timeout=10, retries=3)

for batch in downloader:
    # do something with the batch
    pass

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py621dl-0.1a1.dev0.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py621dl-0.1a1.dev0-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

Details for the file py621dl-0.1a1.dev0.tar.gz.

File metadata

  • Download URL: py621dl-0.1a1.dev0.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.11.0 Linux/5.15.0-1022-azure

File hashes

Hashes for py621dl-0.1a1.dev0.tar.gz
Algorithm Hash digest
SHA256 0903dea65da9470a308db4b198b6ce81a6c2dec144d2f8cf40a674230c2a80c0
MD5 d115ee92bfc0722be2b4aba0e8a901b5
BLAKE2b-256 53fd0fdf6d8d7734cfddbb08f44d2518aa14f2f6d6d8b658a3d59a8a93a53ae9

See more details on using hashes here.

File details

Details for the file py621dl-0.1a1.dev0-py3-none-any.whl.

File metadata

  • Download URL: py621dl-0.1a1.dev0-py3-none-any.whl
  • Upload date:
  • Size: 19.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.11.0 Linux/5.15.0-1022-azure

File hashes

Hashes for py621dl-0.1a1.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 2afb73d724b7ed344d1da0cff68cbf22018de2e945add37e56ab7a6122232d2e
MD5 f2bada0e84c5ca2434df92acb836bc8b
BLAKE2b-256 a77659271a482b662bb9e3e2e51a8e34abeb6d32bdf3a708f99bf24096a5ce38

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page