text_plain_output_1.png
import hashlib

import os

import pandas as pd

import numpy as np
import pandas as pd
import os
import hashlib
records = []
for name in os.listdir('../input/train/'):
    if 'mask' in name or not name.endswith('.tif'):
        continue
    patient_id, image_id = name.strip('.tif').split('_')
    with open('../input/train/' + name, 'rb') as fd:
        md5sum = hashlib.md5(fd.read()).hexdigest()
    records.append({'filename': name, 'patient_id': patient_id, 'image_id': image_id, 'md5sum': md5sum})
df = pd.DataFrame.from_records(records)

counts = df.groupby('md5sum')['filename'].count()
duplicates = counts[counts > 1]

for md5sum in duplicates.index:
    subset = df[df['md5sum'] == md5sum]
    if len(subset['patient_id'].value_counts()) > 1:
        print(subset)
        print('------')