Git Product home page Git Product logo

memes's Introduction

Memes

Script to convert images to memes.

Usage

Prerequisites

  • argparse==1.1
  • json==2.0.9
  • PILLOW==5.1.0

Structure

The folder data will have folders within it which will represent categories. Each category folder will have a name and a file “data.txt” within it which will hold the category detail. Within each category, there can be sub-categories or images. Images can have any descriptive name say img.jpg . Along with the image, there maybe another file img.json which will contain the image data.

Format of img.json

{
	"description": "img_description"
}

Format of memes.json

{
    "mode": "generation_mode",
    "format": "meme_rating",
    "description": "meme_description",
    "rating": 0
}

Installation

Project memes has been ported to package, now it can be installed using the following command from the memes directory.

pip install --editable .

This will install the memes project, Now it can be invoked using openmemes.

Preprocessing

Images in data folder can be preprocessed by running the following command.

openmemes --preprocess=1 --data="path" --width=600

Preprocessed images are scaled according to the width provided and converted to jpg format.

Indexing

Index script maintains index.json which contains the description of images present in the data. Description varies depending on the presence of img.json.

python index_data.py

To force memedb indexing

openmemes --force_index=1

Searching

With searchp script available under the search switch in package, now you can search for images present index json file. Current version compares the search string to the description of images.

There are two types of search:

  • Index - Displays image in accordance with input .Can be enabled by setting index_search to 1
  • String - Displays image from search string entered .Enabled by default.

Each of the types have two modes:

  • Command Line
openmemes --search=1 --mode=0 --search_str=string
openmemes --search=1 --mode=0 --index_search=1 --search_idx=index
  • Interactive
openmemes --search=1 --mode=1

Recommendation

The script has ability to recommend memes based on the meme location and the word match in the description of the meme.

openmemes --recommend=1 --meme=image_path

Meme Generation

The current version of the script has the ability to create memes in four different formats using custom user defined images. The script can be either in interactive or command line depending on chosen mode.

Format 1

Text can be added either at the top type 1, at the bottom type 2, or at both type 3. See more

openmemes --generate=1 --mode=0 --format=1 --image1=path --text1=text

Format 2

Two images are merged vertically and texts can be added to the top of image 1 and to the bottom of image 2. See more

openmemes --generate=1 --mode=0 --format=2 --image1=path --image2=path --text1=text --text2=text

Format 3

Two images are merged horizontally and texts appear in four styles type 1, type 2, type 3, type 4. See more

openmemes --generate=1 --mode=0 --format=3 --image1=path --image2 =path --text1=text --text2=text

Above formats can also be accessed interactively using mode=1

openmemes --generate=1 --mode=1 --format=1

Ratings

Meme_generation also supports ratings now , and these ratings can be used subjectively for setting trending memes and creating recommendations.

--generate=1 --mode=0 --format=3 --image1=path --image2 =path --text1=text --text2=text --rating=value_from_0_to_5

Description

At the time of meme generation a description can be assigned to the meme for lookup and classification based use cases.

--generate=1 --mode=0 --format=3 --image1=path --image2 =path --text1=text --text2=text --description=description_text

Testing

The project can be tested for errors using the command

openmemes --test=1 --module=<module_name>

if all services are to be tested, --module argument is not required For testing a specific service set it to module args. example-

openmemes --test=1 --module=generate

Response - If something fails, expected point of error is also mentioned Example -

  • Resolve - recommendation.py [ * ], * means check all part of recommendation.py file
  • Resolve - meme_generator[start()],formats/format2 means error is expected in start() function of meme_generator and formats/format2

Note

Even after porting to package, all the functionalities can be accessed using the bridge.py file without installation

python bridge.py <option-switch>=1 <arguments>

Features

  • Use the generated meme to set as desktop background.
# Under development. To try the script run:
python utilities.py "<image-path>"

memes's People

Contributors

adichat avatar adityaprakash-bobby avatar adityarakhecha avatar anshulh avatar juliocesark avatar moderneinstein avatar nadaa avatar nickjiang2378 avatar rohanbanerjee avatar sj029626 avatar sorablaze11 avatar srivkrnt avatar teeniv001 avatar ulshell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

memes's Issues

Tests for APIs

The test service contains test for the services, it can be extended to test the APIs ( Image Tagging API) .

  • Proper test report based on the problem in the API if its not working should be generated in the test report.

  • This endpoint should be modified so that APIs can be independently tested.

temp

Running tests break meme_generator service

The logo files in the ./data directory automatically change from .png to .jpg after the first run of the test. This breaks the meme_generator.py service as it looks for the logos with .png extensions.

Steps to reproduce
1- openmemes --test=1

Running preprocess on the ./data directory also results in the same problem. I guess the issue is because of the preprocess service.
Everyone is invited to try solving this issue.

Caching tags to improve latency

The recommendation service uses API for fetching the tag list for the images to calculate the score for the matching. Right now every time recommendation service is run these tags are generated and that is an additional overhead.

This can be solved by caching the tags for images because images are static and it ensures that tags will not change for the same image over time. So on the first run for an image the tags can be stored into a field in the JSON and when the recommendation service runs it may first check the JSON for the tags and if they are not present it may request the API for the tags.

Platform changes causing an error.

One needs to modify files of index_data.py and recommendation just a small change of os.sep what it is returning in two of python 2 or 3 in Windows os as I am using Mac it is returning the same in both cases kindly see what it and if someone wants correct it. I would suggest to make different files for both users as it will be ease for both users to work.

Adding support for multiple fonts

Right now the application support only one font. This can be extended to multiple fonts with a command line argument to select appropriate font based on the requirements of the user and the services.

Anyone interested can claim the issue.

Abstraction : Restructuring project

I suggest restructuring the project.
We have a setup.py file that can interact with all other files for a successful installation and therefore we can hide irrelevant details(Files) from a user installing the package.
A new structure could be .

| root dir

  • A folder ___ (Some relevant name) containing all the data files, logos and other content files.
  • A folder services that can contain all the services like recommendation, meme_generator, searchp etc.
  • setup.py

After this we are left with only relevant folder in the root dir of the project and we need to modify module and file imports to support the structure.

Please have a look and claim this issue if you wish to work on this.

Enhancing recommendations by classifications

I was thinking of enhancing the way recommendations are generated, right now recommendations are generated based on the description and their location that is not a correct measure of how close two memes/images are in terms of similarity to be recommended.
I suggest image classification as a solution.

Example

Untitled
Taking up tags from this type of API can help us store them in the description json of the memes and these tags can be used for calculating the matchScore in recommendation.py

Another way is generating these classifications locally using the tensorflow or similar tools/frameworks with pre-trained models. This will eliminate online dependency.

Please share your approaches and thoughts to solve this problem.

Pre-processing with no args for path breaks meme_generator service

Running preprocessing service with no args triggers /data directory and a similar issue like #115 is encountered.

To reproduce

  • openmemes --preprocess=1
  • openmemes --test=1 or (Run meme_generator service)

Screenshot (59)

This can be fixed by :-

  • Either changing the preprocessing default path.
  • Excluding the logos from getting preprocessed.

Font error for macOS

Facing font errors while the script meme_generator.py is executed in macOS machine.
The #51 pull request was added to resolve the above mentioned issue.

Fix metadata generation directory.

In one of the cases for meme_generation service, the metadata and probably the meme is not generated in the correct directory. The metadata and generated meme should be generated in the corresponding directory of the meme.

  • Files to modify - [ services/meme_generation.py ]
  • Expected point of issue = [ use routine Line 20 to Line 33 ]

Steps to reproduce :-
openmemes --test=1 --module=generate

Possible Security Issue

The auth.ini file in the root directory contains credentials for social media sites. This is obviously not a recommended practice, because others can freely use your API key to access the website. It is recommended that secrets are NEVER committed to version control.

For maximum security, I would recommend rewriting the git history so that the secrets file isn't there at all.

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.