Dataset Viewer
The dataset could not be loaded because the splits use different data file formats, which is not supported. Read more about the splits configuration. Click for more details.
Couldn't infer the same data file format for all splits. Got {NamedSplit('train'): ('text', {}), NamedSplit('test'): ('imagefolder', {})}
Error code: FileFormatMismatchBetweenSplitsError
Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.
How to use TactileNet:
Step 1: Download the dataset locally
git lfs install
git clone https://huggingface.co/datasets/MaiAhmed/TactileNet
Step 2: Install necessary packages
pip install datasets
Step 3: Load the dataset
import os
from datasets import Dataset, Image
def load_data(dataset_path):
data = []
for root, dirs, files in os.walk(dataset_path):
for file in files:
if file.endswith(".jpg"):
# Extract class name (e.g., "airplane" from the path)
class_name = os.path.basename(
os.path.dirname(root)
) # Gets "airplane" from "train/airplane/Inputs/"
img_path = os.path.join(root, file)
txt_path = os.path.join(root, file.replace(".jpg", ".txt"))
if os.path.exists(txt_path):
with open(txt_path, "r") as f:
text = f.read().strip()
data.append(
{
"image": img_path,
"text": text,
"class": class_name,
}
)
return data
# Example usage:
dataset_path = "TactileNet/train" # Replace with your dataset path
data = load_data(dataset_path)
# Convert to Hugging Face Dataset
hf_dataset = Dataset.from_list(data)
hf_dataset = hf_dataset.cast_column("image", Image()) # Auto-convert images
print(hf_dataset[0]) # Check the first sample
- Downloads last month
- 214