File size: 784 Bytes
4e4d03e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
import pickle

# Path to your local image dataset folder
image_folder = "C:/Users/kalha/Documents/NEU 5330/Lab 1/images_dataset"  # Adjust if needed

tile_images = {}

# Iterate over all JPEG files in the folder
for filename in os.listdir(image_folder):
    if filename.lower().endswith(".jpg"):
        key = f"images_dataset/{filename}"  # key with folder prefix
        filepath = os.path.join(image_folder, filename)
        with open(filepath, "rb") as f:
            data = f.read()  # read raw bytes without decoding
        tile_images[key] = data
        print(f"Stored {key}")

# Save the dictionary of raw image bytes to a pickle file
with open("tile_images_raw.pkl", "wb") as f:
    pickle.dump(tile_images, f)

print("Saved tile images to tile_images_raw.pkl")