Markov Meme
Wouldn't it be great to generate themed memes with Markov Models? Or just randomly generated text? I think so too.
Usage
Install
You can install from pypi
pip install markovmeme
or install from the repository directly:
$ git clone https://github.com/vsoch/markovmeme
$ python setup.py install
Usage
You can see the basic usage as follows. Basically, there is a "generate" command:
$ markov-meme
usage: markov-meme [-h] {generate} ...
Markov Meme Generator
optional arguments:
-h, --help show this help message and exit
actions:
actions for Markov Meme Generator
{generate} markovmeme actions
generate generate a meme
You can see the corpus available by looking at the generate help:
$ markov-meme generate --help
usage: markov-meme generate [-h] [--outfile OUTFILE] [--fontsize FONTSIZE]
[--font {OpenSans-Regular,Pacifico-Regular,Anton-Regular}]
[--corpus {hamlet,dr_seuss,trump_speech,the_office,office/stanley,office/toby,office/meredith,office/holly,office/creed,office/oscar,office/deangelo,office/david,office/dwight,office/kelly,office/phyllis,office/jim,office/nellie,office/gabe,office/clark,office/roy,office/karen,office/michael,office/andy,office/charles,office/kevin,office/pam,office/ryan,office/erin,office/robert,office/darryl,office/pete,office/jan,office/jo,office/angela}]
[--custom-corpus CUSTOM_CORPUS]
[--image CUSTOM_IMAGE] [--no-model]
optional arguments:
-h, --help show this help message and exit
--outfile OUTFILE the output file to save the image (defaults to
randomly generated png)
--fontsize FONTSIZE font size of text (if desired) defaults to 16
--font {OpenSans-Regular,Pacifico-Regular,Anton-Regular}
choice of font (defaults to open sans)
--corpus {hamlet,dr_seuss,trump_speech,the_office,office/stanley,office/toby,office/meredith,office/holly,office/creed,office/oscar,office/deangelo,office/david,office/dwight,office/kelly,office/phyllis,office/jim,office/nellie,office/gabe,office/clark,office/roy,office/karen,office/michael,office/andy,office/charles,office/kevin,office/pam,office/ryan,office/erin,office/robert,office/darryl,office/pete,office/jan,office/jo,office/angela}
the corpus to use to generate the meme, matches to
images.
--custom-corpus CUSTOM_CORPUS
A custom corpus file, full path
--image CUSTOM_IMAGE A custom image file, full path
--no-model Don't generate a sentence from corpus, just randomly
select sentence.
Random Generation
To generate a meme from a random corpus, you can just run:
$ markov-meme generate
If the randomly selected corpus doesn't have matching images, you'll see
No images exist for corpus office/clark. Please specify --image.
Corpus and Image Selection
And you can run the same command again, or specify a specific corpus and image.
$ markov-meme generate --corpus office/michael --image markovmeme/data/images/office/michael1.png
The same can be done for specifying a custom corpus, which should be a text file with lines to generate the model from.
$ markov-meme generate --custom-corpus markovmeme/data/corpus/office/michael.txt --image markovmeme/data/images/office/michael2.png
Skip Model
If you don't want to use a model (and want real lines from some corpus) add --no-model
$ markov-meme generate --no-model
Interactive Python
For the most part, text size and number of characters are limited to fit reasonable within 1-3 lines. If you want to customize or otherwise play around with this, you can interact with the class directly:
from markovmeme.main import MemeImage
from markovmeme.text import generate_text
# corpus is absolute path, or relative to module's data/corpus folder
corpus = "office/michael"
text = generate_text(corpus=corpus, use_model=True, size=10)
# Set image to full path, or None to select based on corpus
meme = MemeImage(image=None, corpus=corpus)
# Add text generated, centered on top
meme.write_text(text, fontsize=args.fontsize, font=font)
# Leave outfile as None to generate random name
meme.save_image(None)
Support
Do you have a question? Or want to suggest a feature to make it better? Please open an issue!
Metadata
Release files for markovmeme 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| markovmeme-0.0.1.tar.gz | 51.8 MB | Without provenance | Details for markovmeme-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| markovmeme-0.0.1-py3.7.egg | Legacy Egg format | - | - | Details for markovmeme-0.0.1-py3.7.egg |
Total release size: 103.8 MB
Release files / markovmeme-0.0.1.tar.gz
| Download URL | markovmeme-0.0.1.tar.gz |
|---|---|
| Size | 51.8 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bd46d74dcda01f73d978a91de696b5a1a077bda9263464188ac902333e1a9752
|
|
BLAKE2b-256 checksum How to use checksums |
aecabf345eb16403330c63d66890e5814219647d95b1f7df9cf1c9a39257880c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Release files / markovmeme-0.0.1-py3.7.egg
| Download URL | markovmeme-0.0.1-py3.7.egg |
|---|---|
| Size | 51.9 MB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
8518ffaf4a430efc31d3fd5e9d2d20ca3829e8e94785eefcaed8bb489e8fbe72
|
|
BLAKE2b-256 checksum How to use checksums |
87e1526c8d324573ce45da47d845e27929e9d5b66dd769e108f568038c77ede3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Security for markovmeme 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.