Conversation
| ss = "" | ||
| for sentence in sentences: | ||
| ss += sentence + "\n" | ||
| ss = "".join(sentence + "\n" for sentence in sentences) |
There was a problem hiding this comment.
Function TextDetectorGUI.update refactored with the following changes:
- Use str.join() instead of for loop (
use-join)
| filename = os.path.join("./known_faces/", name + ".jpg") | ||
| filename = os.path.join("./known_faces/", f"{name}.jpg") | ||
| if os.path.exists(filename): | ||
| return tk.messagebox.showerror( | ||
| "Error", "A face with this name already exists." | ||
| ) | ||
| # Show a pop-up message | ||
| resp = tk.messagebox.askokcancel( | ||
| if resp := tk.messagebox.askokcancel( | ||
| "Cheese", "Smile for the camera! Click OK to click and image." | ||
| ) | ||
| if resp: | ||
| ): |
There was a problem hiding this comment.
Function SaveFaceGUI.save_face refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression) - Use f-string instead of string concatenation (
use-fstring-for-concatenation)
This removes the following comments ( why? ):
# Show a pop-up message
| data_dir + "/shape_predictor_68_face_landmarks.dat" | ||
| f"{data_dir}/shape_predictor_68_face_landmarks.dat" | ||
| ) | ||
| face_recognition_model = dlib.face_recognition_model_v1( | ||
| data_dir + "/dlib_face_recognition_resnet_model_v1.dat" | ||
| f"{data_dir}/dlib_face_recognition_resnet_model_v1.dat" |
There was a problem hiding this comment.
Lines 13-16 refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation)
| return person_names[min_index] + " ({0:.2f})".format(min_value) | ||
| if min_value < 0.65: | ||
| return person_names[min_index] + "?" + " ({0:.2f})".format(min_value) | ||
| return f"{person_names[min_index]}?" + " ({0:.2f})".format(min_value) |
There was a problem hiding this comment.
Function find_match refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| def recognize_faces_in_frame(frame): | ||
| faceClassifier = cv2.CascadeClassifier( | ||
| data_dir + "/haarcascade_frontalface_default.xml" | ||
| f"{data_dir}/haarcascade_frontalface_default.xml" |
There was a problem hiding this comment.
Function recognize_faces_in_frame refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation) - Use named expression to simplify assignment and conditional (
use-named-expression)
| data = [] | ||
| image = Image.fromarray(img) | ||
| image = image.resize((30, 30)) | ||
| data.append(np.array(image)) | ||
| data = [np.array(image)] |
There was a problem hiding this comment.
Function image_processing refactored with the following changes:
- Move assignment closer to its usage within a block (
move-assign-in-block) - Merge append into list declaration (
merge-list-append)
| sentences = [" ".join(s) for s in sentences] | ||
|
|
||
| return sentences | ||
| return [" ".join(s) for s in sentences] |
There was a problem hiding this comment.
Function group_words_to_sentences refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
Branch
mainrefactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
mainbranch, then run:Help us improve this pull request!