Skip to content

Commit

Permalink
Merge pull request #36 from Face-Tagger/release
Browse files Browse the repository at this point in the history
Release Face Tagger v1.0.1
  • Loading branch information
ByteAurora authored Sep 7, 2023
2 parents 2ba4cc8 + 4c05d32 commit 39eb14e
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 31 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,18 @@ Face Tagger follows a systematic process to classify images:

To utilize the Face Tagger library, follow these steps:

1. **Define an image generator**:
1. **Load image with functions defined in utils module**:
The generator function allows you to loop through all images in a specified directory and create `ImageObject`
instances for each one.

```python
def image_generator(image_dir):
for filename in os.listdir(image_dir):
img = cv2.imread(os.path.join(image_dir, filename))
if img is not None:
yield ImageObject(filename, img)
from utils import *

image_objects = load_images_from_directory("path_to_images_directory")
```

Replace `path_to_images_directory` with the path to your image directory.

(Note: You don't necessarily need to use a generator for image_objects. You can also create ImageObject list from loaded
images in an array and pass them.)

Expand All @@ -93,6 +93,8 @@ Here is the representation of the `ImageObject` class:
and `min_similarity_face_count`.
```python
from face_tagger import FaceTagger
face_tagger = FaceTagger(
use_gpu=False,
image_resize_factor=1.0,
Expand All @@ -106,12 +108,10 @@ face_tagger = FaceTagger(
generator function to classify the images.

```python
result = face_tagger.classify_images_by_person(image_objects=image_generator("path_to_images_directory"))
result = face_tagger.classify_images_by_person(image_objects=image_objects)
print(result)
```

Replace `path_to_images_directory` with the path to your image directory.

---

With these steps, you can effectively utilize the Face Tagger library to classify images based on the individuals they
Expand Down
62 changes: 60 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "face_tagger"
version = "1.0.0"
version = "1.0.1"
authors = [
{ name="Bae SungJoon", email="clcc001@naver.com" },
{ name="Yoon JongBeom", email="home99032@naver.com" },
Expand All @@ -22,4 +22,62 @@ classifiers = [

[project.urls]
"Homepage" = "https://github.com/Face-Tagger"
"Bug Tracker" = "https://github.com/Face-Tagger/facetagger-lib/issues"
"Bug Tracker" = "https://github.com/Face-Tagger/facetagger-lib/issues"

[project.dependencies]
absl-py = "1.4.0"
astunparse = "1.6.3"
cachetools = "5.3.1"
certifi = "2023.7.22"
charset-normalizer = "3.2.0"
Cython = "0.29.36"
facenet-pytorch = "2.5.3"
filelock = "3.12.3"
flatbuffers = "23.5.26"
gast = "0.4.0"
google-auth = "2.22.0"
google-auth-oauthlib = "1.0.0"
google-pasta = "0.2.0"
grpcio = "1.57.0"
h5py = "3.9.0"
hdbscan = "0.8.33"
idna = "3.4"
Jinja2 = "3.1.2"
joblib = "1.3.2"
keras = "2.13.1"
libclang = "16.0.6"
Markdown = "3.4.4"
MarkupSafe = "2.1.3"
mpmath = "1.3.0"
mtcnn = "0.1.1"
networkx = "3.1"
numpy = "1.24.3"
oauthlib = "3.2.2"
opencv-python = "4.8.0.74"
opt-einsum = "3.3.0"
packaging = "23.1"
Pillow = "10.0.0"
protobuf = "4.24.2"
pyasn1 = "0.5.0"
pyasn1-modules = "0.3.0"
requests = "2.31.0"
requests-oauthlib = "1.3.1"
rsa = "4.9"
scikit-learn = "1.3.0"
scipy = "1.11.2"
six = "1.16.0"
sympy = "1.12"
tensorboard = "2.13.0"
tensorboard-data-server = "0.7.1"
tensorflow = "2.13.0"
tensorflow-estimator = "2.13.0"
tensorflow-cpu = "2.13.0"
tensorflow-io-gcs-filesystem = "0.31.0"
termcolor = "2.3.0"
threadpoolctl = "3.2.0"
torch = "2.0.1"
torchvision = "0.15.2"
typing_extensions = "4.5.0"
urllib3 = "1.26.16"
Werkzeug = "2.3.7"
wrapt = "1.15.0"
20 changes: 0 additions & 20 deletions setup.py

This file was deleted.

26 changes: 26 additions & 0 deletions src/face_tagger/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import os

import cv2
import numpy as np
from PIL import Image

from src.face_tagger.models import ImageObject


def resize_image(image, width, height):
"""
Expand Down Expand Up @@ -33,3 +37,25 @@ def bytes_to_cvimage(byte_stream):
"""

return cv2.imdecode(np.frombuffer(byte_stream, np.uint8), cv2.IMREAD_COLOR)


def load_images_from_directory(images_path):
"""
Generate image objects from the given directory.
:param images_path: Directory containing images.
:return: ImageObject generator.
"""
for filename in os.listdir(images_path):
image_data = cv2.imread(os.path.join(images_path, filename))
if image_data is not None:
yield ImageObject(filename, image_data)


def load_image(image_path):
"""
Load image from the given path.
:param image_path: Path to the image.
:return: ImageObject.
"""
image_data = cv2.imread(image_path)
return ImageObject(image_path, image_data)

0 comments on commit 39eb14e

Please sign in to comment.