<jupyter_start><jupyter_text>Data Wrangling and Exploratory Data Analysis  Import Necessary Libraries<jupyter_code>import numpy as np
import os, sys
import pickle

import matplotlib.pyplot as plt
%matplotlib inline

import cv2
import itertools
import time
import random

import re<jupyter_output><empty_output><jupyter_text>English Dataset This is the CEDAR dataset, which contains signatures by 55 people written in Latin script. Each person has 24 genuine and 24 forged signatures.  Load Images<jupyter_code>path = "./data/raw/CEDAR/"
# get list of all directories
dir_list = next(os.walk(path))[1]
dir_list.sort(key=int) # sort all of the directories from 1 to 55
print(dir_list)<jupyter_output>['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55']<jupyter_text>Separate Originals and Forgeries<jupyter_code># create empty lists to separate originals vs forgeries
originals = []
forgeries = []
for folder in dir_list:
    images = os.listdir(path+folder)
    images.sort()
    images = [path+folder+'/'+x for x in images]
    forgeries.append(images[:24]) # First 24 images in each folder are forgeries
    originals.append(images[24:])
len(forgeries)
# forgeries 
## print and check that all the forged images were sorted correctly
## returns a list of lists containing image paths<jupyter_output><empty_output><jupyter_text>Visualize Original and Forged Signatures<jupyter_code>originals_imgs = random.sample(originals[5], 2)
forgeries_imgs = random.sample(forgeries[5], 2)
originals_img1 = cv2.imread(originals_imgs[0], 0)
originals_img2 = cv2.imread(originals_imgs[1], 0)

forge_img1 = cv2.imread(forgeries_imgs[0], 0)
forge_img2 = cv2.imread(forgeries_imgs[1], 0)
fig, (ax1, ax2, ax3, ax4) = plt.subplots(1, 4, figsize=(10, 10))

ax1.imshow(originals_img1, cmap='gray')
ax1.axis('off')
ax1.set_title('Genuine Signature 1')

ax2.imshow(originals_img2, cmap='gray')
ax2.axis('off')
ax2.set_title('Genuine Signature 2')

ax3.imshow(forge_img1, cmap='gray')
ax3.axis('off')
ax3.set_title('Forged Signature 1')

ax4.imshow(forge_img2, cmap='gray')
ax4.axis('off')
ax4.set_title('Forged Signature 2')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16625, 'fraction_numerical': 0.07, 'mean_word_length': 6.275757575757575, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '382836', 'license': 'MIT', 'n_tokens_mistral': 1011, 'n_tokens_neox': 909, 'n_words': 244, 'path': 'notebooks/1.0-sm-signatures-data_wrangling_and_eda.ipynb', 'repo_name': 'dna-witch/SigVer', 'size': '2400'}