@@ -0,0 +1,2140 @@
+import os%0Aimport numpy as np%0Aimport glob%0Afrom sklearn.model_selection import train_test_split%0Afrom shutil import copyfile%0A%0Aseed = 143%0Anp.random.seed(seed)%0A%0A%0Adef train_dev_splits_from_directories(test_percentage, max_dev):%0A    hotdogs = np.array(glob.glob('./hotdog/**/*.jpg'))%0A    non_hotdogs = np.array(glob.glob('./non-hotdog/**/*.jpg'))%0A    total_data_count = len(hotdogs) + len(non_hotdogs)%0A%0A    max_train_percentage = float(max_dev) / total_data_count%0A    test_size = min(max_train_percentage, test_percentage)%0A%0A    hotdog_train, hotdog_test, hotdog_train_label, hotdog_test_label = train_test_split(hotdogs, np.ones(hotdogs.shape),%0A                                                                                        test_size=test_size,%0A                                                                                        random_state=seed)%0A    non_hotdog_train, non_hotdog_test, non_hotdog_train_label, non_hotdog_test_label = train_test_split(non_hotdogs,%0A                                                                                                        np.zeros(%0A                                                                                                            non_hotdogs.shape),%0A                                                                                                        test_size=test_size,%0A                                                                                                        random_state=seed)%0A%0A    train_files = np.concatenate((hotdog_train, non_hotdog_train))%0A    dev_files = np.concatenate((hotdog_test, non_hotdog_test))%0A%0A    train_dir = './train/'%0A    dev_dir = './dev/'%0A    if not os.path.exists(train_dir):%0A        os.makedirs(train_dir)%0A%0A    if not os.path.exists(dev_dir):%0A        os.makedirs(dev_dir)%0A%0A    for filename in train_files:%0A        dst_filename = train_dir + %22%22.join(filename.split('/')%5B1:%5D)%0A        copyfile(filename, dst_filename)%0A%0A    for filename in dev_files:%0A        dst_filename = dev_dir + %22%22.join(filename.split('/')%5B1:%5D)%0A        copyfile(filename, dst_filename)%0A%0A%0Aif __name__ == %22__main__%22:%0A    train_dev_splits_from_directories(0.3, 1000.0)%0A

split train and dev data