<jupyter_start><jupyter_text>Data load<jupyter_code>INPUT_CHANNELS = 3
OUTPUT_CHANNELS = 2
BATCH_SIZE = 8
SIZE = [224, 224]
train_path = '/data/tuSimple/train_set/'
test_path = '/data/tuSimple/test_set/'
MODEL_PATH = './model_best.pth'
train_dataset = tuSimpleDataset(train_path, size=SIZE)
test_dataset = tuSimpleDataset(test_path, size=SIZE, trans=False)
train_dataloader = DataLoader(dataset=train_dataset, batch_size=BATCH_SIZE, shuffle=True, num_workers=8)
test_dataloader = DataLoader(dataset=test_dataset, batch_size=BATCH_SIZE, num_workers=8)
imgs, label_imgs = next(iter(train_dataloader))
idx = np.random.randint(0, BATCH_SIZE-1)
lane_coordinate = np.where(label_imgs[idx] == 1)
plt.scatter(lane_coordinate[1], lane_coordinate[0])
idxT = np.transpose(lane_coordinate)<jupyter_output><empty_output><jupyter_text>DBSCAN<jupyter_code>db = DBSCAN(eps=2).fit(idxT)
core_samples_mask = np.zeros_like(db.labels_, dtype=bool)
core_samples_mask[db.core_sample_indices_] = True
labels = db.labels_

set(labels)
unique_labels = set(labels)
colors = [plt.cm.Spectral(each) for each in np.linspace(0, 1, len(unique_labels))]
xys = []
for k, col in zip(unique_labels, colors):
    if k == -1:
        # Black used for noise.
        col = [0, 0, 0, 1]
    class_member_mask = (labels == k)
    
    xy = idxT[class_member_mask & core_samples_mask]
    xy2 = np.vstack((xy[:,1], xy[:,0])).T
    xys.append(xy2)
    
    plt.plot(xy[:, 1], xy[:, 0], 'o', markerfacecolor=tuple(col),
             markeredgecolor='k', markersize=10)
    
    xy = idxT[class_member_mask & ~core_samples_mask]
    plt.plot(xy[:, 1], xy[:, 0], 'x', markerfacecolor=tuple(col),
             markeredgecolor='k', markersize=6)
img = np.transpose(imgs[idx].cpu().numpy(), (1,2,0))
out_label = img.copy()
for xy, col in zip(xys, colors):
    cv2.polylines(out_label, np.int32([xy]), isClosed=False, color=tuple(col), thickness=5)

plt.figure(dpi=200)
plt.gray()
plt.subplot(131);plt.imshow(out_label)
plt.subplot(132);plt.imshow(img)
plt.subplot(133);plt.imshow(label_imgs[idx].cpu().numpy())<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15726577437858508, 'fraction_numerical': 0.02581261950286807, 'mean_word_length': 5.708333333333333, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '236460', 'license': 'MIT', 'n_tokens_mistral': 864, 'n_tokens_neox': 824, 'n_words': 133, 'path': 'notebooks/lane_cluster.ipynb', 'repo_name': 'Cxiada/Baidu-Lane-Detection-', 'size': '2092'}