Open MoraAlex opened 1 year ago
That code works for me, hope this help!
`
from io import BytesIO import time import cv2 input_dir = '/content/folder' model_action = '' images = [input_dir + "/" +i for i in os.listdir(inputdir) if i.endswith(('jpeg', 'png', 'jpg',"PNG","JPEG","JPG"))] print(images) = [resize(path, 1920, save_image=True) for path in images] # Resize Images to 1920 as the max dimension's size else it'll blow the GPU / CPU memory
for path in images: with open(path, 'rb') as f: image_bytes = BytesIO(f.read())
start = time.time() input_img, height, width, height_even, width_even = pre_process(image_bytes) preds = predict(input_img)
result = post_process(preds, height, width, height_even, width_even) img_ext = path.split('.')[-1] out_img = path.replace("." + img_ext,"_maxim." + img_ext)
cv2.imwrite(out_img, result) elapsed = time.time() - start minutes, seconds = divmod(elapsed, 60) # convert to minutes and remaining secondsv print("Time elapsed " + str(minutes) + "minutes and "+ str(seconds)) `
In this cell https://colab.research.google.com/drive/1SjIBkPlBJrGFdIBqx7Lggcb-1H86Vq1h#scrollTo=Fcp68HNFf2Fy&line=3&uniqifier=1 when I change
weight_drive_path
to a model trained by MAXIM-3S I get the error in this cell https://colab.research.google.com/drive/1SjIBkPlBJrGFdIBqx7Lggcb-1H86Vq1h#scrollTo=Q1T544sZan4d&line=20&uniqifier=1 This is the error: