Giter Site home page Giter Site logo

style-stack's Introduction

Style Stack A library for style similarity search for art and design images.

Contents

  • analysis.ipynb: a walkthrough of the the EDA, development, and analysis of my similarity search method. Note that there is some dynamic inheritence modificaiton and method declaration (monkey patching) to enhance the story-like flow of the notebook, which is not included in the analysts.py class versions, and would not be included in production code.
  • analysts.py: classes used in analysis and EDA
  • style_stack.py: primary similarity search classes for production

Installation

To install the package above, pleae run:

GPU

conda install faiss-gpu -c pytorch
conda install requirements.txt

CPU

conda install faiss-cpu -c pytorch
conda install requirements.txt

Requisites

  • conda

Dependencies

Usage

Build GramStack

Import GramStack and choose a model from keras.applications

from keras.applications.vgg16 import VGG16
from stylestack.gram_stack import GramStack

Set up arguments

image_dir = '../data/my_data'
model = VGG16(weights='imagenet', include_top=False)
layer_range = ('block1_conv1', 'block2_pool')

Build GramStack

stack = GramStack.build(image_dir, model, layer_range)

Query GramStack

Set weighting for embedding layers in similarity search. Any layers not specified will be weighted as 0, or all layers can be used by specifying None.

embedding_weights = {
    'block1_conv1': 1,
    'block3_conv2': 0.5,
    'block3_pool': .25
}

Set other arguments. Use write_output to output results JSON to /output/.

image_path = '../data/my_data/cat_painting.jpg'
n_results = 5
write_output = True

Query GramStack

results = stack.query(image_path, embedding_weights, n_results, write_output)

Save to disk

stack.save(lib_name='my_data')

Load from disk

GramStack.load(lib_name='my_data')

Once the GramStack is loaded, it can be queried and behaves the same as when it was built.

style-stack's People

Contributors

theaustinator avatar

Watchers

James Cloos 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.