Update app.py
Browse files12345673456891011121314151617181920212223import osos.environ["CUDA_VISIBLE_DEVICES"] = "-1"
import tensorflow as tfimport cv2import imghdrimport os# Avoid OOM errors by setting GPU Memory Consumption Growthgpus = tf.config.experimental.list_physical_devices('GPU')for gpu in gpus: tf.config.experimental.set_memory_growth(gpu, True)
# Clean image filesdata_dir = 'data'image_exts = ['jpeg', 'jpg', 'bmp', 'png']
for image_class in os.listdir(data_dir): for image in os.listdir(os.path.join(data_dir, image_class)): image_path = os.path.join(data_dir, image_class, image) try: img = cv2.imread(image_path) tip = imghdr.what(image_path) if tip not in image_exts: print('Removing:', image_path) os.remove(image_path) except Exception as e: print('Issue with image:', image_path)app.py+20-4