Skip to content
This repository has been archived by the owner on Jan 5, 2025. It is now read-only.

Commit

Permalink
Merge pull request #6 from slashtechno/publish-to-pypi
Browse files Browse the repository at this point in the history
Prepare to publish to PyPi
  • Loading branch information
slashtechno authored Oct 22, 2023
2 parents 4f8e26b + 259cc8f commit 3235bb6
Show file tree
Hide file tree
Showing 15 changed files with 433 additions and 288 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package

on:
release:
types: [published]

permissions:
contents: read

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_PROJECT_API_TOKEN }}
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
config/
using_yolov8.ipynb
yolov8n.pt
.venv/
*venv/
__pycache__/
faces/*
!faces/.gitkeep
!faces/.gitkeep
dist/
test.txt
8 changes: 5 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
"version": "0.2.0",
"configurations": [
{
"name": "Python: Module",
// "name": "Python: Module",
"name": "Debug Wyzely Detect",
"type": "python",
"request": "launch",
"module": "set_detect_notify",
"justMyCode": true
"module": "wyzely_detect",
// "justMyCode": true
"justMyCode": false
}
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"files.eol": "\n"
}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ COPY . .

RUN poetry install

ENTRYPOINT ["poetry", "run", "python", "-m", "set_detect_notify"]
ENTRYPOINT ["poetry", "run", "python", "-m", "wyzely_detect"]
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Set, Detect, Notify
Recognize faces/objects in (Wyze Cam) footage and send notifications to your phone (or other devices)
# Wyzely Detect
Recognize faces/objects in a video stream (from a webcam or a security camera) and send notifications to your devices

### Features
- Recognize objects
Expand All @@ -13,21 +13,22 @@ Recognize faces/objects in (Wyze Cam) footage and send notifications to your pho
## Prerequisites
### Poetry/Python
- Camera, either a webcam or a Wyze Cam
- All RTSP feeds _should_ work, however.
- Python
- Poetry
### Docker
- All RTSP feeds _should_ work, however.
- Python 3.10 or 3.11
- Poetry
### Docker
- A Wyze Cam
- Any other RTSP feed _should_ work, as mentioned above
- Python
- Poetry
- Any other RTSP feed _should_ work, as mentioned above
- Docker
- Docker Compose


## What's not required
- A Wyze subscription

## Usage
## Usage
### Installation
1. Clone this repo with `git clone https://github.com/slashtechno/wyze-face-recognition.git`
1. Clone this repo with `git clone https://github.com/slashtechno/wyzely-detect`
2. `cd` into the cloned repository
3. Then, either install with [Poetry](https://python-poetry.org/) or run with Docker

Expand All @@ -37,7 +38,7 @@ Recognize faces/objects in (Wyze Cam) footage and send notifications to your pho

#### Poetry
1. `poetry install`
2. `poetry run -- set-detect-notify`
2. `poetry run -- wyzely-detect`
### Configuration
The following are some basic CLI options. Most flags have environment variable equivalents which can be helpful when using Docker.

Expand Down
62 changes: 58 additions & 4 deletions deepface-test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@
"# cv2.imwrite(str(uuid_path), frame)\n",
"# dfs = DeepFace.find(img_path=str(uuid_path), db_path = \"faces\")\n",
"# Don't throw an error if no face is detected (enforce_detection=False)\n",
"dfs = DeepFace.find(frame, db_path = \"faces\", enforce_detection=False)\n",
"dfs = DeepFace.find(frame, db_path = \"faces\", enforce_detection=False, silent=False, model_name=\"ArcFace\", detector_backend=\"opencv\")\n",
"# Get the identity of the person\n",
"for i, pd_dataframe in enumerate(dfs):\n",
" # Sort the dataframe by confidence\n",
" # inplace=True means that the dataframe is modified so we don't need to assign it to a new variable\n",
" pd_dataframe.sort_values(by=['VGG-Face_cosine'], inplace=True, ascending=False)\n",
" # pd_dataframe.sort_values(by=['model_name=\"ArcFace\", detector_backend=\"opencv\")'], inplace=True, ascending=False)\n",
" print(f'On dataframe {i}')\n",
" print(pd_dataframe)\n",
" # Get the most likely identity\n",
" # print(f'Most likely identity: {pd_dataframe.iloc[0][\"identity\"]}')\n",
" # We could use Path to get the parent directory of the image to use as the identity\n",
" print(f'Most likely identity: {Path(pd_dataframe.iloc[0][\"identity\"]).parent.name}')\n",
" # Get the most likely identity's confidence\n",
" print(f'Confidence: {pd_dataframe.iloc[0][\"VGG-Face_cosine\"]}')\n",
" print(f'Confidence: {pd_dataframe.iloc[0][\"ArcFace_cosine\"]}')\n",
"\n",
"# uuid_path.unlink()"
]
Expand All @@ -67,7 +67,61 @@
"metadata": {},
"outputs": [],
"source": [
"DeepFace.stream(db_path=\"faces\")"
"DeepFace.stream(db_path=\"faces\", model_name=\"ArcFace\", detector_backend=\"opencv\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Stream normal frame by frame"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from deepface import DeepFace\n",
"import cv2\n",
"from pathlib import Path\n",
"import uuid\n",
"import pandas as pd\n",
"\n",
"def main():\n",
" cap = cv2.VideoCapture(0)\n",
" while True:\n",
" ret, frame = cap.read()\n",
" dfs = DeepFace.find(frame, db_path = \"faces\", enforce_detection=False, silent=False, model_name=\"ArcFace\", detector_backend=\"opencv\")\n",
" for i, pd_dataframe in enumerate(dfs):\n",
" print(f'On dataframe {i}')\n",
" print(pd_dataframe)\n",
" print(f'Most likely identity: {Path(pd_dataframe.iloc[0][\"identity\"]).parent.name}')\n",
" print(f'Confidence: {pd_dataframe.iloc[0][\"ArcFace_cosine\"]}')\n",
" cv2.imshow(\"frame\", frame)\n",
" if cv2.waitKey(1) & 0xFF == ord(\"q\"):\n",
" break\n",
" cap.release()\n",
" cv2.destroyAllWindows()\n",
" \n",
"\n",
"\n",
"main()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Other functions\n"
]
}
],
Expand Down
15 changes: 6 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ networks:
all:
services:
bridge:
container_name: bridge-wyze
container_name: bridge-wyzely-detect
restart: unless-stopped
image: mrlt8/wyze-bridge:latest
# I think we can remove the ports, since we're using the network
Expand All @@ -18,12 +18,9 @@ services:
- WYZE_PASSWORD=${WYZE_PASSWORD} # Replace with wyze password
networks:
all:
# aliases:
# - bridge
# - wyze-bridge
ntfy:
image: binwiederhier/ntfy
container_name: ntfy-wyze
container_name: ntfy-wyzely-detect
command:
- serve
environment:
Expand All @@ -36,10 +33,10 @@ services:
restart: unless-stopped
networks:
all:
facial_recognition:
container_name: face-recognition-wyze
wyzely-detect:
container_name: wyzely-detect
restart: unless-stopped
# image: ghcr.io/slashtechno/wyze_face_recognition:latest
# image: ghcr.io/slashtechno/wyzely-detect:latest
build:
context: .
dockerfile: Dockerfile
Expand All @@ -50,7 +47,7 @@ services:
environment:
- URL=rtsp://bridge:8554/cv
- NO_DISPLAY=true
- NTFY_URL=http://ntfy:80/set-detect-notify
- NTFY_URL=http://ntfy:80/wyzely-detect
depends_on:
- bridge

Expand Down
Loading

0 comments on commit 3235bb6

Please sign in to comment.