Navigation

  • index
  • modules |
  • previous |
  • Flask Image Search 1.0.1 documentation »
  • flask_image_search package

flask_image_search package¶

class flask_image_search.ImageSearch(app=None, **kwargs)[source]¶

Bases: object

This is a class used to add Image searching functionality to your flask app, that uses Flask-SQLAlchemy.

There are two ways to use Flask-Image-Search.

app = Flask(__name__)
db = SQLAlchemy(app)
image_search = ImageSearch(app, db)

or

db = SQLAlchemy()
image_search = ImageSearch()

def create_app():
    app = Flask(__name__)
    db.init_app(app)
    image_search.init_app(app, db)
    return app
app¶
case(image, model, column=None, limit=None)[source]¶

Creates a case statement that contains the distances to the query image matching up to ids.

Parameters
  • image (PIL.Image.Image or str) – The query image

  • model (flask_sqlalchemy.Model) – The model containing the indexed images.

  • column (str or sqlalchemy.schema.Column) – The column that the case statement relates to (Primary key column of the indexed Model)

static create_keras_model()[source]¶

This functions exists so that tensorflow=False works with a custom model.

db¶
delete_index(entry)[source]¶

Delete an index

Parameters

entry (flask_sqlalchemy.Model) – The entry in the database to be removed from the index.

feature_extract(image)[source]¶

This is a helper function that takes an image processes it and returns the features.

Parameters

image (PIL.Image.Image) – The image to get the features from.

features(model)[source]¶

Returns features of a model.

Parameters

model (flask_sqlalchemy.Model or str) – The model that you want to get the features

Returns

The group containing the datasets for each image

Return type

zarr.hierarchy.Group

index(entry, replace=False)[source]¶

Indexes an entry of a registered Model.

Parameters
  • entry (flask_sqlalchemy.Model) – The Model instance to be indexed.

  • replace (bool) – Set to True to replace an existing index of this image, defaults to False

index_model(model, replace=False, threaded=True)[source]¶

Index all the images in a model.

Parameters
  • model (flask_sqlalchemy.Model) – The model containing the images to be indexed.

  • replace (bool) – Set to True to replace an existing index of this image, defaults to False

  • threaded (bool) – Set this to true to make index_model non blocking.

init_app(app, tensorflow=True)[source]¶

Initialize Flask-Image-Search. This function is called by __init__ if an app is passed.

Parameters
  • app (flask.Flask) – The Flask app for this project.

  • tensorflow (bool) – Should tensorflow be used, tensorflow can be dissabled to make working on other parts of your app easier defaults to True

Raises

Exception – Exception may be raised if Flask-SQLAlchemy is not initialized.

keras_model¶
models¶
static preprocess_image_array(image_array)[source]¶
register(id='id', path='path', ignore='ignore')[source]¶

This decorator is used to register Flask-SQLAlchemy Model with the image search. After a model is registered it can then indexed and searched.

Parameters
  • id (str) – This is the name of the primary_key column. Defaults to “id”.

  • path (str) – This is the name of the column containing the image path. Defaults to “path”.

  • ignore (str) – This is the name of the column used to decide if an image should be ignored. defaults to “ignore” if no column is found there is no ignore column.

root¶
search(model, image, sorted=True, limit=None)[source]¶

This searches the indexed data with an image and returns a tuple of id strings.

Parameters
  • model (str or flask_sqlalchemy.Model) – This is the model to be search. Either a SQLAlchemy model can be passed or a string of the tablename.

  • image (PIL.Image.Image or str) – The search image

  • sorted (bool) – Should the results be sorted

  • limit (None or int) – Limit the number of results

Returns

This returns a tuple of tuples containing the id and the distance from the search image.

Return type

tuple[tuple[str, int]]

storage¶

Flask Image Search

Project Links

  • PyPI Releases
  • Source Code

Navigation

  • Flask Image Search
  • Installation
  • Usage
  • Contributing
  • Credits
  • History
  • flask_image_search package

Quick search

© Copyright 2020, Hanan Fokkens. Created using Sphinx 4.2.0.