cMars8k / README.md
evans44's picture
Updated README.md to be more useful.
eb4c7d6 verified
|
Raw History Blame Contribute Delete
3.06 kB
metadata
license: cc-by-4.0
tags:
  - space
  - mars
  - craters

Hello!

cMars8k is a collection of 8,120 200x200 .jpg images of Martian craters, as well as their corresponding likelihoods of having subsurface ice at a depth of 0-1m.

A short explanation of how the dataset was derived:

  • The THEMIS IR Day Map was used to create this dataset, owing to its lightweight nature and scientific reputability.
  • Robbins & Hynek's 2020 Mars crater database was used to source the geographic coordinates of the craters' (approximate) centers.
  • NASA's SWIM Project 0-1m Ice Consistency map was used to source the likelihood of subsurface ice at the location of each crater.
  • All of these individual datasets were combined together by overlaying them on top of each other inside of QGIS, and then utilizing a python script to mass-export the images.

Data Formatting

As stated, each image is exactly 200x200 pixels and is stored as a .jpg file within cMars8k/images. The ice_likelihood value is a float64 ranging from approximately -0.375 to 1.000, with 1.000 representing an extremely high probability or confirmed presence of subsurface ice.

Accessing Data

This dataset can be accessed via:
!git clone https://huggingface.co/datasets/evans44/cMars8k
or via the Hugging Face API.

Normalization

Many CNNs prefer normalized images as opposed to RGB. The following script loads the images directly from the downloaded folder into a pandas dataframe and performs said action.
!! Note: within metadata.csv, the file_name for each image is in the format images/crater_####, and as such the images directory/folder does not need to be specified when accessing the images.

import pandas as pd
import cv2
from concurrent.futures import ThreadPoolExecutor
import os

# Load metadata
metadata = pd.read_csv("cMars8k/metadata.csv")

IMAGES_DIR = "cMars8k"  # file_name column already includes "images/" prefix

def load_and_normalize(file_name):
    path = os.path.join(IMAGES_DIR, file_name)
    img = cv2.imread(path)                       # loads as BGR, uint8, shape (200, 200, 3)
    img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)    # convert to RGB
    img = img.astype(np.float32) / 255.0          # normalize to [0, 1]
    return img

with ThreadPoolExecutor(max_workers=8) as executor:
    images = list(executor.map(load_and_normalize, metadata["file_name"]))

df_master = pd.DataFrame({                                # 3 columns:
    "file_name": metadata["file_name"],                   # file_name (over from metadata.csv)
    "image": images,                                      # image: the normalized version of the image
    "ice_prob": metadata["ice_likelihood"]                # ice_prob: probability of ice (over from metadata.csv/ice_likelihood)
})

print("Shape of df_master:")
print(df_master.shape)
print(df_master["image"].iloc[0].shape, df_master["image"].iloc[0].dtype)