import os
import argparse
import glob

import skimage.color as skcolor
import skimage.io as skio
import skimage.filters as skfilters
import skimage.feature as skfeature
import numpy as np
import matplotlib.pyplot as plt

import warnings
warnings.filterwarnings("ignore")

from tqdm import tqdm

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Pepe cleanser')
    parser.add_argument('--img-dir', required=True, type=str)
    parser.add_argument('--out-dir', required=True, type=str)
    args = parser.parse_args()

    files = glob.glob(os.path.join(args.img_dir, '*.png')) + \
        glob.glob(os.path.join(args.img_dir, '*.jpg'))

    for i in tqdm(range(len(files))):
        f = files[i]
        f_ext = f.split('/')[-1].replace(' ', '').split('.')[-1]

        # Get image and convert to grayscale
        img = skio.imread(f)
        gray = skcolor.rgb2gray(img)

        # Get mask to get true rare pepes
        thres = skfilters.threshold_otsu(gray)
        mask = gray >= thres

        # Canny
        edges = skfeature.canny(gray)
        edges = edges * 255

        skio.imsave(os.path.join(args.out_dir, '{}.{}'.format(i, f_ext)), edges)

@@ -724,20 +724,23 @@
        f
-_ext
+ilename
  = f.spl
@@ -754,40 +754,8 @@
 %5B-1%5D
-.replace(' ', '').split('.')%5B-1%5D
 %0A%0A  
@@ -1120,11 +1120,8 @@
  '%7B%7D
-.%7B%7D
 '.fo
@@ -1129,16 +1129,16 @@
 mat(
-i, f_ext
+filename
 )), 

clean to original filename