Metadata-Version: 2.1
Name: flask-image-search
Version: 0.0.5
Summary: Flask Image Search works with Flask-SQLAlchemy to add image searching functionality
Home-page: https://github.com/hananf11/flask_image_search
Author: Hanan Fokkens
Author-email: hananfokkens@gmail.com
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Framework :: Flask
Classifier: Topic :: Database
Description-Content-Type: text/markdown
Requires-Dist: Flask (>=1.1.1)
Requires-Dist: Flask-SQLAlchemy (>=2.4.1)
Requires-Dist: Keras (>=2.3.1)
Requires-Dist: numpy (>=1.18.1)
Requires-Dist: pillow (>=7.1.1)
Requires-Dist: tensorflow (>=2.1.0)

## Installation

Run the following to install
```commandline
pip install flask_image_search
```
Run the following to install from github
```commandline
pip install git+https://github.com/hananf11/flask_image_search.git
```

## Usage
```python
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_image_search import ImageSearch

app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///example.sqlite"
db = SQLAlchemy(app)

image_search = ImageSearch(app, db)


@image_search.register(fk_cols=['model_id'])  # register the image model_ and track the also track the model_id column
class Image(db.Model):
    __tablename__ = 'images'

    id = db.Column(db.Integer, primary_key=True)
    url = db.Column(db.Text)
    model_id = db.Column(db.ForeignKey('models.id'))

    model = db.relationship('Model', primaryjoin='Image.model_id == Model.id', backref="images")


image_search.index_model(Image)


class Model(db.Model):
    __tablename__ = 'models'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.Text)


images = Image.query.with_transformation(image_search.query_search(image_path='query.jpg', limit=5)).all()
print(images)
models = Model.query.with_transformation(image_search.query_relation_search(image_path='query.jpg', limit=5)).all()
print(models)
```

