Spaces:
Sleeping
Sleeping
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") | |