-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding nullable column to postgres images table with type Vector to s… #357
base: develop
Are you sure you want to change the base?
Adding nullable column to postgres images table with type Vector to s… #357
Conversation
…tore sscd embedding vectors.
This looks really promising, probably lots of cool things we can do with direct access to the vector. But it looks like we need to first get Alegre migrated to python 3.8? Build is failing with
|
Upgrading to 3.8 is a good idea - I'm usually against over-eager version bumps, but this code is now very long in the tooth and 3.8 is very old. @skyemeedan I wonder if we should hold on the version bump until we release all the dependencies off alegre? That would very likely make a bump much easier... |
@ahmednasserswe are there earlier versions of pgvector that provide functionality but don't require python 3.8? |
…ions, making sscd vector size 512, and removing version number from pgvector in requirements.tx
app/main/model/image.py
Outdated
@@ -43,6 +44,7 @@ def from_url(url, doc_id, context={}, created_at=None): | |||
raw = remote_response.read() | |||
im = Image.open(io.BytesIO(raw)).convert('RGB') | |||
phash = compute_phash_int(im) | |||
sscd = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused variable 'sscd'
@@ -19,6 +19,7 @@ | |||
from app.main.lib.language_analyzers import init_indices | |||
from app.main.lib.image_hash import compute_phash_int | |||
from PIL import Image | |||
from sqlalchemy import text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imports from package sqlalchemy are not grouped
|
||
from app.main.lib.presto import Presto | ||
import json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
standard import import json
should be placed before from flask import current_app as app
|
||
from app.main.lib.presto import Presto |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imports from package app are not grouped
…['phash']' to 'post' '/image/similarity/' in test_image_similarity.py'
# models = ['phash'] | ||
try: | ||
models = [m.lower() for m in models] | ||
except: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No exception type(s) specified
if not context: | ||
context = {} | ||
if not threshold: | ||
threshold = 0.9 | ||
if url: | ||
image = ImageModel.from_url(url, None) | ||
result = [] | ||
image = ImageModel.from_url(url, None,models = models) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No space allowed around keyword argument assignment
if not context: | ||
context = {} | ||
if not threshold: | ||
threshold = 0.9 | ||
if url: | ||
image = ImageModel.from_url(url, None) | ||
result = [] | ||
image = ImageModel.from_url(url, None,models = models) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly one space required after comma
@@ -31,23 +34,51 @@ class ImageModel(db.Model): | |||
) | |||
|
|||
@staticmethod | |||
def from_url(url, doc_id, context={}, created_at=None): | |||
def from_url(url, doc_id, context={}, created_at=None, models=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too many local variables (18/15)
Code Climate has analyzed commit 8b59feb and detected 9 issues on this pull request. Here's the issue category breakdown:
The test coverage on the diff in this pull request is 41.3% (50% is the threshold). This pull request will bring the total coverage in the repository to 86.4%. View more on Code Climate. |
Description
Adding nullable column to postgres images table with type Vector to store sscd embedding vectors.
This included changes to both Postgress dockerfile and Alegre dockerfile.
Reference: TICKET-ID CV2-3917
How has this been tested?
tested locally
Have you considered secure coding practices when writing this code?
No potential security threads