Skip to content

Commit

Permalink
removed facedetection cause errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabrock94 committed Sep 12, 2024
1 parent 4a19d43 commit 23b9dab
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 37 deletions.
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
author = 'Giulio Gabrieli'

# The short X.Y version
version = '0.0.8.6'
version = '0.0.8.7'
# The full version, including alpha/beta/rc tags
release = '0.0.8.6'
release = '0.0.8.7'


# -- General configuration ---------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion pyaesthetics.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: pyaesthetics
Version: 0.0.8.6
Version: 0.0.8.7
Summary: Images aesthetic analysis
Home-page: https://github.com/Gabrock94/pyaesthetics
Author: Giulio Gabrieli
Expand Down
2 changes: 1 addition & 1 deletion pyaesthetics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from . import visualcomplexity

# This is used to print out the package version
__version__ = '0.0.8.6' #Version Control
__version__ = '0.0.8.7' #Version Control

print("Thank you for using pyaesthetics. If you use it in your work, please cite:")
print("Gabrieli, G., Bornstein, M. H., Setoh, P., & Esposito, G. (2023). Machine learning estimation of users’ implicit and explicit aesthetic judgments of web-pages. Behaviour & Information Technology, 42(4), 392-402.")
Binary file modified pyaesthetics/__pycache__/analysis.cpython-310.pyc
Binary file not shown.
Binary file modified pyaesthetics/__pycache__/facedetection.cpython-310.pyc
Binary file not shown.
6 changes: 3 additions & 3 deletions pyaesthetics/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ def analyze_image(pathToImg, method='fast', resize=True, newSize=(600, 400), min
resultdict["Colorfulness_HSV"] = colorfulness.colorfulness_hsv(imageColor)
resultdict["Colorfulness_RGB"] = colorfulness.colorfulness_rgb(imageColor)
resultdict["FacesCv2"] = facedetection.detect_faces_cv2(imageColor)
resultdict["FacesFd"] = facedetection.detect_faces(pathToImg)
# resultdict["FacesFd"] = facedetection.detect_faces(pathToImg)
resultdict["Number_of_Faces_Cv2"] = len(resultdict["FacesCv2"])
resultdict["Number_of_Faces_fd"] = len(resultdict["FacesFd"])
# resultdict["Number_of_Faces_fd"] = len(resultdict["FacesFd"])
resultdict["Colors"] = colordetection.get_colors_w3c(imageColor, ncolors=140)
A = spacebaseddecomposition.get_areas(imageColor_O)
Adict = spacebaseddecomposition.text2image_ratio(A)
Expand Down Expand Up @@ -180,7 +180,7 @@ def analyze_image(pathToImg, method='fast', resize=True, newSize=(600, 400), min
sample_img = data_folder + "face1.png"

# Analyze the sample image using the 'complete' method
results = analyze_image(sample_img, method='fast')
results = analyze_image(sample_img, method='complete')
# Print the analysis results
print(results)

59 changes: 30 additions & 29 deletions pyaesthetics/facedetection.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,38 +54,39 @@ def detect_faces_cv2(img, plot=False):
# Return the list of detected faces
return faces

def detect_faces(imgpath, plot=False, model='hog'):
""" This function uses face-recognition to detect faces in a picture.
By default it uses the hog method. cnn method can be passed as model parameter.
# TODO: Wait for patch
# def detect_faces(imgpath, plot=False, model='hog'):
# """ This function uses face-recognition to detect faces in a picture.
# By default it uses the hog method. cnn method can be passed as model parameter.

:param img: path to the image to analyze
:type img: string
:param plot: whether to plot or not the results
:type plot: bool
:param model: which model to use for the detection of faces (hog or cnn). Default is 'hog'.
:type model: string
:return: list of detected faces as rectangles
:rtype: list
"""
# :param img: path to the image to analyze
# :type img: string
# :param plot: whether to plot or not the results
# :type plot: bool
# :param model: which model to use for the detection of faces (hog or cnn). Default is 'hog'.
# :type model: string
# :return: list of detected faces as rectangles
# :rtype: list
# """

# Convert the image to grayscale as Haar cascades work better on grayscale images
image = face_recognition.load_image_file(imgpath)
faces = face_recognition.face_locations(image, model=model)
# If plot is True, draw rectangles around detected faces and display the image
if plot:
for top, right, bottom, left in faces:
cv2.rectangle(image, (left, top), (right, bottom), (255, 0, 0), 2)
plt.imshow(image)
# # Convert the image to grayscale as Haar cascades work better on grayscale images
# image = face_recognition.load_image_file(imgpath)
# faces = face_recognition.face_locations(image, model=model)
# # If plot is True, draw rectangles around detected faces and display the image
# if plot:
# for top, right, bottom, left in faces:
# cv2.rectangle(image, (left, top), (right, bottom), (255, 0, 0), 2)
# plt.imshow(image)

# if plot:
# for top, right, bottom, left in faces:
# # You can access the actual face itself like this:
# face_image = image[top:bottom, left:right]
# pil_image = Image.fromarray(face_image)
# pil_image.show()
# # if plot:
# # for top, right, bottom, left in faces:
# # # You can access the actual face itself like this:
# # face_image = image[top:bottom, left:right]
# # pil_image = Image.fromarray(face_image)
# # pil_image.show()

# Return the list of detected faces
return faces
# # Return the list of detected faces
# return faces

###############################################################################
# #
Expand Down Expand Up @@ -116,7 +117,7 @@ def detect_faces(imgpath, plot=False, model='hog'):
print("Number of faces in the picture is:", len(faces))

# Detect faces in the image and plot the results
faces = detect_faces(sample_img, plot=True)
# faces = detect_faces(sample_img, plot=True)

# Print the number of faces detected
print("Number of faces in the picture is:", len(faces))
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyaesthetics"
version = "0.0.8.6"
version = "0.0.8.7"
description = "A python package to estimate visual features about the aesthetic appearance of still images."
authors = ["Giulio Gabrieli <[email protected]>"]
license = "GPL-3.0"
Expand Down

0 comments on commit 23b9dab

Please sign in to comment.