Skip to content

Commit

Permalink
Merge branch 'main' into feature-triplet-loss-function
Browse files Browse the repository at this point in the history
  • Loading branch information
Devasy23 authored Oct 29, 2024
2 parents 6cfde79 + 3dc29eb commit 0058dbe
Show file tree
Hide file tree
Showing 74 changed files with 40,899 additions and 1,483 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/auto-comment-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Auto Comment on Issue
on:
issues:
types: [opened]
permissions:
issues: write
jobs:
comment:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Add Comment to Issue
run: |
COMMENT=$(cat <<EOF
{
"body": "Thank you for creating this issue! 🎉 We'll look into it as soon as possible. In the meantime, please make sure to provide all the necessary details and context. If you have any questions or additional information, feel free to add them here. Your contributions are highly appreciated! 😊\n\nYou can also check our [CONTRIBUTING.md](https://github.com/sujaltangde/JobLane/blob/main/CONTRIBUTING.md) for guidelines on contributing to this project."
"body": "Thank you for creating this issue! 🎉 We'll look into it as soon as possible. In the meantime, please make sure to provide all the necessary details and context. If you have any questions or additional information, feel free to add them here. Your contributions are highly appreciated! 😊\n\nYou can also check our [CONTRIBUTING.md](https://github.com/recodehive/Scrape-ML/blob/main/CONTRIBUTING.md) for guidelines on contributing to this project."
}
EOF
)
37 changes: 37 additions & 0 deletions .github/workflows/auto-comment-on-pr-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Auto Comment on PR Merge

on:
pull_request_target:
types: [closed]

permissions:
issues: write
pull-requests: write

jobs:
comment:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest

steps:
- name: Add Comment to Merged PR
run: |
COMMENT=$(cat <<EOF
{
"body": "🎉 Your pull request has been successfully merged! 🎉 Thank you for your contribution to our project. Your efforts are greatly appreciated. Keep up the fantastic work! 🚀"
}
EOF
)
RESPONSE=$(curl -s -o response.json -w "%{http_code}" \
-X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
-d "$COMMENT")
cat response.json
if [ "$RESPONSE" -ne 201 ]; then
echo "Failed to add comment"
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 0 additions & 1 deletion .github/workflows/changelog-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,3 @@ jobs:
# release_name: Release ${{ github.run_number }}
# draft: false
# prerelease: false

5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,7 @@ venv/
*.pyc
.vscode/
__pyc
Images/
FaceRec/static/Images/uploads/*
Images/dbImages/*
Images/Faces/*
Images/
58 changes: 11 additions & 47 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,52 +1,16 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
- repo: https://github.com/psf/black
rev: 24.10.0 # Use the latest stable version of Black
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: debug-statements
- id: double-quote-string-fixer
- id: name-tests-test
- id: requirements-txt-fixer
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.5.0
hooks:
- id: setup-cfg-fmt
- repo: https://github.com/asottile/reorder-python-imports
rev: v3.13.0
hooks:
- id: reorder-python-imports
args: [--py38-plus, --add-import, 'from __future__ import annotations']
- repo: https://github.com/asottile/add-trailing-comma
rev: v3.1.0
hooks:
- id: add-trailing-comma
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.2
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/hhatto/autopep8
rev: v2.2.0
- id: black

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: autopep8
# - repo: https://github.com/PyCQA/flake8
# rev: 7.0.0
# hooks:
# - id: flake8
# exclude: testing/
# - repo: local
# hooks:
# - id: wily
# name: wily
# entry: wily diff
# verbose: true
# language: python
# additional_dependencies: [wily]
- id: isort


- repo: https://github.com/commitizen-tools/commitizen
rev: v3.27.0
- repo: https://github.com/hhatto/autopep8
rev: v2.3.1 # Use the latest stable version of autopep8
hooks:
- id: commitizen
stages: [commit-msg]
- id: autopep8
19 changes: 19 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# .readthedocs.yaml

# Required
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.10"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# Optionally declare the Python requirements required to build your docs
python:
install:
- requirements: requirements.txt
6 changes: 3 additions & 3 deletions API/_init_.py → API/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
Fastapp.include_router(route.router)


@Fastapp.get('/')
@Fastapp.get("/")
def read_root():
return {'Hello': 'FASTAPI'}
return {"Hello": "FASTAPI"}


# function to run server of FastAPI
def run_fastapi_app():
uvicorn.run(Fastapp, host='127.0.0.1', port=8000)
uvicorn.run(Fastapp, host="127.0.0.1", port=8000)
95 changes: 83 additions & 12 deletions API/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,116 @@


class Database:
def __init__(self, uri='mongodb://localhost:27017/', db_name='ImageDB'):
def __init__(self, uri="mongodb://localhost:27017/", db_name="ImageDB"):
"""
Initialize a Database object.
Args:
uri (str): The uri of the MongoDB server. Defaults to 'mongodb://localhost:27017/'.
db_name (str): The name of the MongoDB database. Defaults to 'ImageDB'.
"""
self.client = MongoClient(uri)
self.db = self.client[db_name]

def find(self, collection, query=None):
"""
Find documents in the given collection.
Args:
collection (str): The name of the collection to search.
query (dict): The query to filter the documents by. Defaults to None.
Returns:
pymongo.cursor.Cursor: A cursor pointing to the results of the query.
"""
return self.db[collection].find(query)

def insert_one(self, collection, document):
"""
Insert a single document into the given collection.
Args:
collection (str): The name of the collection to insert into.
document (dict): The document to insert.
Returns:
pymongo.results.InsertOneResult: The result of the insertion.
"""

return self.db[collection].insert_one(document)

def find_one(self, collection, filter, projection=None):
"""
Find a single document in the given collection.
Args:
collection (str): The name of the collection to search.
filter (dict): The query to filter the documents by.
projection (dict, optional): The fields to include in the result. Defaults to None.
Returns:
dict: The document that matches the query, or None if no documents match.
"""
return self.db[collection].find_one(filter=filter, projection=projection)

def find_one_and_delete(self, collection, query):
"""
Find a single document and delete it in the given collection.
Args:
collection (str): The name of the collection to search.
query (dict): The query to filter the documents by.
Returns:
dict: The document that matches the query, or None if no documents match.
"""
return self.db[collection].find_one_and_delete(query)

def update_one(self, collection, query, update):
"""
Update a single document in the given collection.
Args:
collection (str): The name of the collection to update.
query (dict): The query to filter the documents by.
update (dict): The update to apply to the matching document.
Returns:
pymongo.results.UpdateResult: The result of the update.
"""

return self.db[collection].update_one(query, update)

# add a function for pipeline aggregation vector search
def vector_search(self, collection, embedding):
"""
Perform a vector similarity search on the given collection.
Args:
collection (str): The name of the collection to search.
embedding (list): The vector to search for.
Returns:
list: A list of documents with the closest embedding to the query vector, sorted by score.
"""

result = self.db[collection].aggregate(
[
{
'$vectorSearch': {
'index': 'vector_index',
'path': 'face_embedding',
'queryVector': embedding,
'numCandidates': 20,
'limit': 20,
"$vectorSearch": {
"index": "vector_index",
"path": "embedding",
"queryVector": embedding,
"numCandidates": 20,
"limit": 20,
},
},
{
'$project': {
'_id': 0,
'Name': 1,
'Image': 1,
'score': {'$meta': 'vectorSearchScore'},
"$project": {
"_id": 0,
"Name": 1,
"Image": 1,
"score": {"$meta": "vectorSearchScore"},
},
},
],
Expand Down
11 changes: 11 additions & 0 deletions API/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
deepface==0.0.92
fastapi==0.115.0
keras==2.15.0
matplotlib==3.8.2
numpy==2.1.2
Pillow==10.4.0
pydantic==2.9.2
pymongo==4.6.1
python-dotenv==1.0.1
tensorflow==2.15.0
uvicorn==0.31.0
Loading

0 comments on commit 0058dbe

Please sign in to comment.