Last active
January 23, 2022 11:36
-
-
Save doleron/97dae8573e23d24aa941dbb8be81961a to your computer and use it in GitHub Desktop.
python format input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def format_yolov5(source): | |
# put the image in square big enough | |
col, row, _ = source.shape | |
_max = max(col, row) | |
resized = np.zeros((_max, _max, 3), np.uint8) | |
resized[0:col, 0:row] = source | |
# resize to 640x640, normalize to [0,1[ and swap Red and Blue channels | |
result = cv2.dnn.blobFromImage(resized, 1/255.0, (640, 640), swapRB=True) | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment