-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored master branch #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to GitHub API limits, only the first 60 comments can be shown.
|
|
||
| for eachPrediction, eachProbability in zip(predictions, probabilities): | ||
| print(eachPrediction + " : " + eachProbability) No newline at end of file | ||
| print(f"{eachPrediction} : {eachProbability}") No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 15-15 refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation)
| predictions, probabilities = prediction.predictImage(os.path.join(execution_path, "1.jpg"), result_count=5 ) | ||
| for eachPrediction, eachProbability in zip(predictions, probabilities): | ||
| print(eachPrediction + " : " + eachProbability) No newline at end of file | ||
| print(f"{eachPrediction} : {eachProbability}") No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 13-13 refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation)
| all_images_array = [] | ||
|
|
||
| all_files = os.listdir(execution_path) | ||
| for each_file in all_files: | ||
| if(each_file.endswith(".jpg") or each_file.endswith(".png")): | ||
| all_images_array.append(each_file) | ||
| all_images_array = [ | ||
| each_file | ||
| for each_file in all_files | ||
| if (each_file.endswith(".jpg") or each_file.endswith(".png")) | ||
| ] | ||
|
|
||
| results_array = multiple_prediction.predictMultipleImages(all_images_array, result_count_per_image=5) | ||
|
|
||
| for each_result in results_array: | ||
| predictions, percentage_probabilities = each_result["predictions"], each_result["percentage_probabilities"] | ||
| for index in range(len(predictions)): | ||
| print(predictions[index] + " : " + percentage_probabilities[index]) | ||
| print(f"{predictions[index]} : {percentage_probabilities[index]}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 11-23 refactored with the following changes:
- Move assignment closer to its usage within a block (
move-assign-in-block) - Convert for loop into list comprehension (
list-comprehension) - Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation)
| if(self.__modelLoaded == False): | ||
| if (self.__modelLoaded == False): | ||
| raise ValueError("You must call the loadModel() function before making object detection.") | ||
| elif(self.__modelLoaded == True): | ||
| elif self.__modelLoaded == True: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function ObjectDetection.detectObjectsFromImage refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation) - Merge nested if conditions (
merge-nested-ifs) - Merge dictionary assignment with declaration [×2] (
merge-dict-assign) - Remove unnecessary calls to
str()from formatted values in f-strings (remove-str-from-fstring) - Merge else clause's nested if statement into elif (
merge-else-if-into-elif) - Simplify conditional into switch-like form [×19] (
switch)
| elif (self.__modelLoaded == True): | ||
| elif self.__modelLoaded == True: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function ObjectDetection.detectCustomObjectsFromImage refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation) - Merge nested if conditions (
merge-nested-ifs) - Merge dictionary assignment with declaration [×2] (
merge-dict-assign) - Remove unnecessary calls to
str()from formatted values in f-strings (remove-str-from-fstring) - Merge else clause's nested if statement into elif (
merge-else-if-into-elif) - Simplify conditional into switch-like form [×19] (
switch)
| else: | ||
| axis = 1 | ||
|
|
||
| axis = 3 if keras.backend.image_data_format() == "channels_last" else 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function TimeDistributedResNet refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp) - Swap if/else branches (
swap-if-else-branches) - Remove unnecessary else after guard condition (
remove-unnecessary-else)
| # set bias to -log((1 - p)/p) for foregound | ||
| result = np.ones(shape, dtype=dtype) * -math.log((1 - self.probability) / self.probability) | ||
|
|
||
| return result | ||
| return np.ones(shape, dtype=dtype) * -math.log( | ||
| (1 - self.probability) / self.probability | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function PriorProbability.__call__ refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
This removes the following comments ( why? ):
# set bias to -log((1 - p)/p) for foregound
| pred_boxes = keras.backend.stack([pred_boxes_x1, pred_boxes_y1, pred_boxes_x2, pred_boxes_y2], axis=2) | ||
|
|
||
| return pred_boxes | ||
| return keras.backend.stack( | ||
| [pred_boxes_x1, pred_boxes_y1, pred_boxes_x2, pred_boxes_y2], axis=2 | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function bbox_transform_inv refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| from .tensorflow_backend import * | ||
| else: | ||
| raise ValueError("Unknown backend: " + str(_BACKEND)) | ||
| raise ValueError(f"Unknown backend: {str(_BACKEND)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 19-19 refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| if None not in input_shape[1:]: | ||
| total = np.prod(input_shape[1:3]) * self.num_anchors | ||
| return (input_shape[0], total, 4) | ||
| else: | ||
| if None in input_shape[1:]: | ||
| return (input_shape[0], None, 4) | ||
| total = np.prod(input_shape[1:3]) * self.num_anchors | ||
| return (input_shape[0], total, 4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Anchors.compute_output_shape refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches) - Remove unnecessary else after guard condition (
remove-unnecessary-else)
Branch
masterrefactored 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
masterbranch, then run:Help us improve this pull request!