import cv2 import os import tensorflow as tf model1 = tf.keras.models.load_model('VDSR.keras', custom_objects={'VDSR': VDSR}) # load each model directory='Unreadable Scanned QR Codes' readable=0 unreadable=0 for filename in os.listdir(directory): file_path = os.path.join(directory, filename) if os.path.isfile(file_path): test_image = cv2.imread(file_path,cv2.IMREAD_GRAYSCALE) test_image = test_image.astype('float32') / 255.0 test_image = np.expand_dims(test_image, axis=-1) # (224, 224) -> (224, 224, 1) test_image = np.expand_dims(test_image, axis=0) # Predict predicted_image = model1.predict(test_image,verbose=0) predicted_image = np.clip(predicted_image[0], 0, 1) # Sonucu 0-1 arası değerlere çek predicted_image_uint8 = (predicted_image * 255).astype(np.uint8) detector = cv2.QRCodeDetector() try: data, points, _ = detector.detectAndDecode(predicted_image_uint8) if data: readable=readable+1 else: unreadable=unreadable+1 except: unreadable=unreadable+1 if okunmayan>0: print(readable,okunmayan, (readable/(unreadable+readable))*100) # Print score