Git Product home page Git Product logo

face-postgre's Introduction

wakatime of coding since May 23, 2015.

From: 23 June 2024 - To: 30 June 2024

Go               8 hrs 30 mins   █████████████▒░░░░░░░░░░░   53.16 %
YAML             2 hrs 51 mins   ████▒░░░░░░░░░░░░░░░░░░░░   17.86 %
JavaScript       2 hrs 18 mins   ███▓░░░░░░░░░░░░░░░░░░░░░   14.39 %
go.mod           1 hr 10 mins    ██░░░░░░░░░░░░░░░░░░░░░░░   07.40 %
HTML             33 mins         █░░░░░░░░░░░░░░░░░░░░░░░░   03.46 %

Taking pictures on the run

Taking pictures on the run

🎵🎶🎶

I'm gettin' a little tired of your broken promises, promises
Lookin' at your pager, seein' different numbers, numbers
Call you on your cell, you're hangin' with the fellas, fellas
Hangin' with my girls, you always gettin' jealous, jealous
I was with you when you didn't have no dollars, no dollars
Hangin' at the crib, chillin' with your mama, your mama
Never fronted you, never brought the drama, the drama
Now you flip the script, player, please

face-postgre's People

Contributors

vearutop avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

face-postgre's Issues

Syntax Error

@vearutop

I keep getting the error below when I attempt to run the codes:

error

Version: ('PostgreSQL 9.6.8 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.9.3, 64-bit',)

SELECT file FROM vectors WHERE sqrt(power(CUBE(array[-0.06887340545654297,0.10233059525489807,0.10160233080387115,-0.11301713436841965,-0.14592909812927246,0.0004851529374718666,-0.07629727572202682,-0.15829594433307648,0.17802439630031586,-0.20244725048542023,0.1285582333803177,-0.0815291479229927,-0.2074122577905655,0.05181701481342316,-0.09317518025636673,0.20535025000572205,-0.12158051133155823,-0.10021547228097916,-0.16869302093982697,-0.07119856029748917,0.05046587437391281,0.02677701786160469,-0.04388655722141266,0.08232736587524414,-0.0330679714679718,-0.24993793666362762,-0.01230323314666748,-0.021156763657927513,-0.024065084755420685,-0.10250875353813171,0.07079330086708069,0.0923762321472168,-0.1568349301815033,-0.042158711701631546,-0.03067936934530735,0.1020168662071228,-0.03939816355705261,-0.14659950137138367,0.1134253591299057,-0.06773674488067627,-0.23308363556861877,-0.04753703996539116,0.07696220278739929,0.2509799897670746,0.25111308693885803,0.01212252676486969,-0.006149983033537865,-0.11321106553077698,0.16601575911045074,-0.3408501148223877,0.003647993318736553,0.03599663823843002,0.03861365467309952,0.06754124164581299,0.12345699220895767,-0.21630609035491943,0.09604985266923904,0.09064231067895889,-0.16567929089069366,0.05914430692791939,0.08075124025344849,-0.14857527613639832,0.05424246937036514,-0.10456611216068268]) <-> vec_low, 2) + power(CUBE(array[0.2896047830581665,0.03638148680329323,-0.1253138780593872,-0.08614261448383331,0.18620777130126953,-0.16353394091129303,-0.002677353098988533,0.05688006430864334,-0.08217878639698029,-0.18610218167304993,-0.31303149461746216,-0.01724396087229252,0.41267284750938416,0.2345082312822342,-0.15557996928691864,0.051614779978990555,-0.07364267110824585,-0.02181013859808445,0.04583794251084328,0.1938910037279129,0.06229330226778984,-0.03562602400779724,-0.035322897136211395,0.01683807000517845,0.22577977180480957,-0.06433368474245071,-0.006460784003138542,0.38136932253837585,0.011478189378976822,-0.11730978637933731,-0.0712127685546875,-0.011202752590179443,-0.14718139171600342,0.04159972071647644,-0.11897310614585876,-0.013145100325345993,0.01094562653452158,-0.01778699830174446,0.05643612891435623,0.11900068819522858,-0.2009134441614151,0.16640324890613556,-0.0762849748134613,0.07192431390285492,0.03656899929046631,-0.06872530281543732,-0.11258184164762497,-0.05909983068704605,0.23055006563663483,-0.2217569500207901,0.07211996614933014,0.16576902568340302,0.12509778141975403,0.14771641790866852,0.08406543731689453,0.11484887450933456,0.12347398698329926,-0.03430244326591492,-0.17360427975654602,0.002648727037012577,0.06261187791824341,-0.08835550397634506,-0.0031046289950609207,0.12539289891719818]) <-> vec_high, 2)) <= 0.6 ORDER BY sqrt(power(CUBE(array[-0.06887340545654297,0.10233059525489807,0.10160233080387115,-0.11301713436841965,-0.14592909812927246,0.0004851529374718666,-0.07629727572202682,-0.15829594433307648,0.17802439630031586,-0.20244725048542023,0.1285582333803177,-0.0815291479229927,-0.2074122577905655,0.05181701481342316,-0.09317518025636673,0.20535025000572205,-0.12158051133155823,-0.10021547228097916,-0.16869302093982697,-0.07119856029748917,0.05046587437391281,0.02677701786160469,-0.04388655722141266,0.08232736587524414,-0.0330679714679718,-0.24993793666362762,-0.01230323314666748,-0.021156763657927513,-0.024065084755420685,-0.10250875353813171,0.07079330086708069,0.0923762321472168,-0.1568349301815033,-0.042158711701631546,-0.03067936934530735,0.1020168662071228,-0.03939816355705261,-0.14659950137138367,0.1134253591299057,-0.06773674488067627,-0.23308363556861877,-0.04753703996539116,0.07696220278739929,0.2509799897670746,0.25111308693885803,0.01212252676486969,-0.006149983033537865,-0.11321106553077698,0.16601575911045074,-0.3408501148223877,0.003647993318736553,0.03599663823843002,0.03861365467309952,0.06754124164581299,0.12345699220895767,-0.21630609035491943,0.09604985266923904,0.09064231067895889,-0.16567929089069366,0.05914430692791939,0.08075124025344849,-0.14857527613639832,0.05424246937036514,-0.10456611216068268]) <-> vec_low, 2) + power(CUBE(array[0.2896047830581665,0.03638148680329323,-0.1253138780593872,-0.08614261448383331,0.18620777130126953,-0.16353394091129303,-0.002677353098988533,0.05688006430864334,-0.08217878639698029,-0.18610218167304993,-0.31303149461746216,-0.01724396087229252,0.41267284750938416,0.2345082312822342,-0.15557996928691864,0.051614779978990555,-0.07364267110824585,-0.02181013859808445,0.04583794251084328,0.1938910037279129,0.06229330226778984,-0.03562602400779724,-0.035322897136211395,0.01683807000517845,0.22577977180480957,-0.06433368474245071,-0.006460784003138542,0.38136932253837585,0.011478189378976822,-0.11730978637933731,-0.0712127685546875,-0.011202752590179443,-0.14718139171600342,0.04159972071647644,-0.11897310614585876,-0.013145100325345993,0.01094562653452158,-0.01778699830174446,0.05643612891435623,0.11900068819522858,-0.2009134441614151,0.16640324890613556,-0.0762849748134613,0.07192431390285492,0.03656899929046631,-0.06872530281543732,-0.11258184164762497,-0.05909983068704605,0.23055006563663483,-0.2217569500207901,0.07211996614933014,0.16576902568340302,0.12509778141975403,0.14771641790866852,0.08406543731689453,0.11484887450933456,0.12347398698329926,-0.03430244326591492,-0.17360427975654602,0.002648727037012577,0.06261187791824341,-0.08835550397634506,-0.0031046289950609207,0.12539289891719818]) <-> vec_high, 2)) <-> vec_high) ASC LIMIT 1

Traceback (most recent call last):
File "gen_128D_vector.py", line 63, in
cur.execute(query)
psycopg2.ProgrammingError: syntax error at or near ")"
LINE 1: ...12539289891719818]) <-> vec_high, 2)) <-> vec_high) ASC LIMI...
^

issue while executing query

[42883] ERROR: operator does not exist: cube <-> cube

Hi i am getting this error

My query is

**SELECT name FROM vectors WHERE (cube(array[-0.15382039546966553,0.01020173728466034]) <-> vec_low )
**

Problem with executing queries

Hi again,

I tried to use psycopg2 connector and found that the connection with the database was working.
But I have run into another problem. Although the program is executing without throwing any errors the queries are not executing.

def setup_db():
    db = psycopg2.connect(host='localhost', user='postgres', password='1234', dbname='test')
    cur = db.cursor()
    cur.execute("create extension if not exists cube;")
    cur.execute("drop table if exists vectors")
    cur.execute("create table vectors (id serial, file varchar, vec_low cube, vec_high cube);")
    cur.execute("create index vectors_vec_idx on vectors (vec_low, vec_high);")

I have modified the function as shown above. But when I run face-add.py I am returned with the following error

Found 1 faces in the image file him.jpg
- Face #0 found at Left: 919 Top: 348 Right: 1240 Bottom: 669
Traceback (most recent call last):
  File "face-add.py", line 47, in <module>
    cur.execute(query)
psycopg2.ProgrammingError: relation "vectors" does not exist
LINE 1: INSERT INTO vectors (file, vec_low, vec_high) VALUES ('him.jpg)

example database with webcam

import face_recognition
import cv2
import dlib
import psycopg2
import time
from datetime import datetime
from datetime import timedelta

video_capture = cv2.VideoCapture(0)

Connect database postgres

connection_db = psycopg2.connect(
"user='postgres' password='1234' host='localhost' dbname='test_face'")
db = connection_db.cursor()

while True:
# Grab a single frame of video
ret, frame = video_capture.read()

face_detector = dlib.get_frontal_face_detector()
detected_faces = face_detector(frame, 1)

# Loop through each face in this frame of video
start_time = datetime.now()
for i, face_rect in enumerate(detected_faces):
    crop = frame[face_rect.top():face_rect.bottom(), face_rect.left():face_rect.right()]
    encodings = face_recognition.face_encodings(crop)

    threshold = 0.4
    
    if len(encodings) > 0:
        query = "SELECT file FROM vectors WHERE sqrt(power(CUBE(array[{}]) <-> vec_low, 2) + power(CUBE(array[{}]) <-> vec_high, 2)) <= {} ".format(
            ','.join(str(s) for s in encodings[0][0:64]),
            ','.join(str(s) for s in encodings[0][64:128]),
            threshold,
        ) + \
            "ORDER BY sqrt((CUBE(array[{}]) <-> vec_low) + (CUBE(array[{}]) <-> vec_high)) ASC LIMIT 5".format(
            ','.join(str(s) for s in encodings[0][0:64]),
            ','.join(str(s) for s in encodings[0][64:128]),
        )
        db.execute(query)

        name = db.fetchone()

        dt = datetime.now() - start_time
        ms = (dt.days * 24 * 60 * 60 + dt.seconds) * \
            1000 + dt.microseconds / 1000.0            

        # Draw a box around the face
        cv2.rectangle(frame, (face_rect.left(), face_rect.top()), (face_rect.right(), face_rect.bottom()), (0, 0, 255), 2)
        # Draw a label with a name below the face
        cv2.rectangle(frame, (face_rect.left(), face_rect.bottom() - 35), (face_rect.right(), face_rect.bottom()), (0, 0, 255), cv2.FILLED)
        cv2.putText(frame, "Name: {}, Time {}".format(name, ms), (int(face_rect.left()), int(face_rect.bottom())-15), cv2.FONT_HERSHEY_DUPLEX, 0.5, (255, 255, 255), 1, cv2.LINE_AA)

    else:
        print("No encodings")
# Display the resulting image
cv2.imshow('Video', frame)

# Hit 'q' on the keyboard to quit!
if cv2.waitKey(1) & 0xFF == ord('q'):
    break

Release handle to the webcam

video_capture.release()
cv2.destroyAllWindows()

When i used face-find.py ,i meet some problem

python3 face-find.py 1.jpg
Found 1 faces in the image file 1.jpg

  • Face #0 found at Left: 180 Top: 263 Right: 366 Bottom: 449
    Traceback (most recent call last):
    File "face-find.py", line 47, in
    dd=db.query(query)
    File "/usr/local/lib/python3.6/site-packages/postgresql/driver/pq3.py", line 1231, in call
    return self._prepare(query)(*parameters)
    File "/usr/local/lib/python3.6/site-packages/postgresql/driver/pq3.py", line 2331, in prepare
    ps._fini()
    File "/usr/local/lib/python3.6/site-packages/postgresql/driver/pq3.py", line 1513, in _fini
    self.database._pq_complete()
    File "/usr/local/lib/python3.6/site-packages/postgresql/driver/pq3.py", line 2609, in _pq_complete
    self.typio.raise_error(x.error_message, cause = getattr(x, 'exception', None))
    File "/usr/local/lib/python3.6/site-packages/postgresql/driver/pq3.py", line 541, in raise_error
    self.raise_server_error(error_message, **kw)
    File "/usr/local/lib/python3.6/site-packages/postgresql/driver/pq3.py", line 532, in raise_server_error
    raise server_error
    postgresql.exceptions.SyntaxError: syntax error at or near ")"
    CODE: 42601
    LOCATION: File 'scan.l', line 1087, in scanner_yyerror from SERVER

issue with postgresql connector

Hi, I am trying to run your demo but db = postgresql.open('pq://user:pass@localhost:5434/db') gives error. My username is postgres, password is 1234 , db name is test. Can you help me with the connection string? I am sorry but my searches on google didn't give any appropriate result.

ThankYou

Query Queries

Hello!
Sorry to bother you for 22 years,
I use your query,
The following error occurred. I am not very familiar with PostgreSQL. Can you help me?
image
21MO@NLJHCQZSA}DCM{Z@XX

Problem with FaceFind

Hi I'm trying to integrate with psycopg2, and I have successfully added the faces into vector table.
But when I try to run the find faces, this issue showed up:

syntax error at or near ")"
LINE 1: ...08222115784883499]) <-> vec_high, 2)) <-> vec_high) ASC LIMI...

If I fix the extra bracket this shows up

operator does not exist: double precision <-> cube
LINE 1: ...0706567764,0.08222115784883499]) <-> vec_high, 2) <-> vec_hi...

do you have any idea how to fix this?
Please help
thanks

no module named postgresql found

When I try to run docker compose and later I run db.py, it gives me an error saying no module names 'postgresql' found. However I only start doing this post running docker compose. Am i doing something wron ? is there some setup that I need before running all of this ?

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.