ImagePRO-Python 0.4.1__tar.gz → 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {imagepro_python-0.4.1/src/ImagePRO_Python.egg-info → imagepro_python-0.5.0}/PKG-INFO +2 -1
  2. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/pyproject.toml +4 -2
  3. imagepro_python-0.5.0/src/ImagePRO/human_analysis/face_analysis/face_comparison.py +60 -0
  4. {imagepro_python-0.4.1 → imagepro_python-0.5.0/src/ImagePRO_Python.egg-info}/PKG-INFO +2 -1
  5. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/src/ImagePRO_Python.egg-info/SOURCES.txt +1 -0
  6. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/src/ImagePRO_Python.egg-info/requires.txt +1 -0
  7. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/LICENSE +0 -0
  8. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/setup.cfg +0 -0
  9. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/src/ImagePRO/__init__.py +0 -0
  10. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/src/ImagePRO/human_analysis/__init__.py +0 -0
  11. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/src/ImagePRO/human_analysis/body_analysis/__init__.py +0 -0
  12. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/src/ImagePRO/human_analysis/body_analysis/body_pose_estimation.py +0 -0
  13. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/src/ImagePRO/human_analysis/body_analysis/hand_tracking.py +0 -0
  14. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/src/ImagePRO/human_analysis/face_analysis/__init__.py +0 -0
  15. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/src/ImagePRO/human_analysis/face_analysis/eye_status_analysis.py +0 -0
  16. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/src/ImagePRO/human_analysis/face_analysis/face_detection.py +0 -0
  17. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/src/ImagePRO/human_analysis/face_analysis/face_mesh_analysis.py +0 -0
  18. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/src/ImagePRO/human_analysis/face_analysis/head_pose_estimation.py +0 -0
  19. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/src/ImagePRO/object_analysis/object_detection.py +0 -0
  20. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/src/ImagePRO/pre_processing/__init__.py +0 -0
  21. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/src/ImagePRO/pre_processing/blur.py +0 -0
  22. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/src/ImagePRO/pre_processing/contrast.py +0 -0
  23. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/src/ImagePRO/pre_processing/crop.py +0 -0
  24. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/src/ImagePRO/pre_processing/dataset_generator.py +0 -0
  25. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/src/ImagePRO/pre_processing/grayscale.py +0 -0
  26. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/src/ImagePRO/pre_processing/resize.py +0 -0
  27. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/src/ImagePRO/pre_processing/rotate.py +0 -0
  28. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/src/ImagePRO/pre_processing/sharpen.py +0 -0
  29. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/src/ImagePRO/utils/__init__.py +0 -0
  30. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/src/ImagePRO/utils/io_handler.py +0 -0
  31. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/src/ImagePRO_Python.egg-info/dependency_links.txt +0 -0
  32. {imagepro_python-0.4.1 → imagepro_python-0.5.0}/src/ImagePRO_Python.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ImagePRO-Python
3
- Version: 0.4.1
3
+ Version: 0.5.0
4
4
  Summary: clean, modular, and easy-to-use Python library for image processing tasks.
5
5
  Author-email: Parsa Safaie <parsasafaie.2568@proton.me>
6
6
  License: MIT
@@ -16,4 +16,5 @@ Requires-Dist: numpy<3.0,>=1.24
16
16
  Requires-Dist: opencv-python<5.0,>=4.8
17
17
  Requires-Dist: ultralytics<9.0,>=8.2.0
18
18
  Requires-Dist: mediapipe<1.0,>=0.10.0
19
+ Requires-Dist: insightface<1.0,>=0.7
19
20
  Dynamic: license-file
@@ -7,7 +7,7 @@ where = ["src"]
7
7
 
8
8
  [project]
9
9
  name = "ImagePRO-Python"
10
- version = "0.4.1"
10
+ version = "0.5.0"
11
11
  description = "clean, modular, and easy-to-use Python library for image processing tasks."
12
12
  readme = "README.md"
13
13
  requires-python = "==3.10.*"
@@ -25,8 +25,10 @@ dependencies = [
25
25
  "numpy>=1.24,<3.0",
26
26
  "opencv-python>=4.8,<5.0",
27
27
  "ultralytics>=8.2.0,<9.0",
28
- "mediapipe>=0.10.0,<1.0",
28
+ "mediapipe>=0.10.0,<1.0",
29
+ "insightface>=0.7,<1.0",
29
30
  ]
30
31
 
32
+
31
33
  [tool.hatch.build.targets.wheel]
32
34
  packages = ["src/ImagePRO"]
@@ -0,0 +1,60 @@
1
+ from insightface.app import FaceAnalysis
2
+ import cv2
3
+ import numpy as np
4
+
5
+ def compare_faces(src_image_path_1, src_image_path_2, app=None):
6
+ """
7
+ Compare two face images using FaceAnalysis embeddings.
8
+
9
+ This function calculates the cosine similarity between the embeddings
10
+ of two detected faces to check if they belong to the same person.
11
+
12
+ Args:
13
+ src_image_path_1 (str | Path): Path to the first image.
14
+ src_image_path_2 (str | Path): Path to the second image.
15
+ app (FaceAnalysis, optional): Pre-loaded FaceAnalysis model instance.
16
+ If not provided, it will be initialized inside the function.
17
+
18
+ Returns:
19
+ bool | str:
20
+ - True : Faces match (cosine similarity > 0.5).
21
+ - False : Faces do not match.
22
+ - 'No Face Detected' : If no face is found in either image.
23
+ """
24
+ # Prepare FaceAnalysis model if not provided
25
+ if app is None:
26
+ app = FaceAnalysis(
27
+ name="buffalo_l",
28
+ providers=["CPUExecutionProvider"],
29
+ )
30
+ app.prepare(ctx_id=0) # Run on CPU
31
+
32
+ # Helper function to read an image and convert to RGB
33
+ def load_rgb(path):
34
+ img = cv2.imread(str(path))
35
+ return cv2.cvtColor(img, cv2.COLOR_BGR2RGB) if img is not None else None
36
+
37
+ # Load and preprocess both images
38
+ img1 = load_rgb(src_image_path_1)
39
+ img2 = load_rgb(src_image_path_2)
40
+
41
+ if img1 is None or img2 is None:
42
+ return 'Invalid Image Path'
43
+
44
+ # Detect faces in both images
45
+ faces1 = app.get(img1)
46
+ faces2 = app.get(img2)
47
+
48
+ # Ensure a face was detected in both images
49
+ if not faces1 or not faces2:
50
+ return 'No Face Detected'
51
+
52
+ # Get the embeddings of the first detected face in each image
53
+ emb1 = faces1[0].embedding
54
+ emb2 = faces2[0].embedding
55
+
56
+ # Compute cosine similarity between the embeddings
57
+ sim = np.dot(emb1, emb2) / (np.linalg.norm(emb1) * np.linalg.norm(emb2))
58
+
59
+ # Return match result based on threshold
60
+ return True if sim > 0.5 else False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ImagePRO-Python
3
- Version: 0.4.1
3
+ Version: 0.5.0
4
4
  Summary: clean, modular, and easy-to-use Python library for image processing tasks.
5
5
  Author-email: Parsa Safaie <parsasafaie.2568@proton.me>
6
6
  License: MIT
@@ -16,4 +16,5 @@ Requires-Dist: numpy<3.0,>=1.24
16
16
  Requires-Dist: opencv-python<5.0,>=4.8
17
17
  Requires-Dist: ultralytics<9.0,>=8.2.0
18
18
  Requires-Dist: mediapipe<1.0,>=0.10.0
19
+ Requires-Dist: insightface<1.0,>=0.7
19
20
  Dynamic: license-file
@@ -7,6 +7,7 @@ src/ImagePRO/human_analysis/body_analysis/body_pose_estimation.py
7
7
  src/ImagePRO/human_analysis/body_analysis/hand_tracking.py
8
8
  src/ImagePRO/human_analysis/face_analysis/__init__.py
9
9
  src/ImagePRO/human_analysis/face_analysis/eye_status_analysis.py
10
+ src/ImagePRO/human_analysis/face_analysis/face_comparison.py
10
11
  src/ImagePRO/human_analysis/face_analysis/face_detection.py
11
12
  src/ImagePRO/human_analysis/face_analysis/face_mesh_analysis.py
12
13
  src/ImagePRO/human_analysis/face_analysis/head_pose_estimation.py
@@ -2,3 +2,4 @@ numpy<3.0,>=1.24
2
2
  opencv-python<5.0,>=4.8
3
3
  ultralytics<9.0,>=8.2.0
4
4
  mediapipe<1.0,>=0.10.0
5
+ insightface<1.0,>=0.7
File without changes