# How to load\_dataset from local directory?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-load-dataset-from-local-directory%2F83006%3E%5C
**Category:** 🤗Datasets\
**Created:** [April 22, 2024, 3:53am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-load-dataset-from-local-directory%2F83006 "2024-04-22T03:53:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![naomifridman](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/naomifridman/32/25197_2.png) [@naomifridman](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnaomifridman)%5C
**Post date:** [April 22, 2024, 3:53am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-load-dataset-from-local-directory%2F83006%2F1 "2024-04-22T03:53:43Z")

</div>

I failed to load\_dataset from local directory. I tried the following, what am i doing wrong ?

```auto
os.system('mkdir mydataset')
os.system('mkdir mydataset/train')
os.system('mkdir mydataset/train/dog/')
os.system('mkdir mydataset/train/cat/')
im1 = np.arange(20*20*3, dtype=np.uint8).reshape((20,20,3))
plt.imsave('mydataset/train/dog/im1.jpg', im1)
im2 = np.arange(20*20*3, dtype=np.uint8).reshape((20,20,3))
plt.imsave('mydataset/train/dog/im2.jpg', im2)
im3 = np.arange(20*20*3, dtype=np.uint8).reshape((20,20,3))
plt.imsave('mydataset/train/cat/im3.jpg', im3)
im4 = np.arange(20*20*3, dtype=np.uint8).reshape((20,20,3))
plt.imsave('mydataset/train/cat/im4.jpg', im4)
train_dataset = load_dataset("imagefolder", "mydataset")

```

In any version of load\_dataset I tried, I get the same error:

* * *

ValueError Traceback (most recent call last)  
Cell In[63], line 13  
11 im4 = np.arange(20_20_3, dtype=np.uint8).reshape((20,20,3))  
12 plt.imsave(‘mydataset/train/cat/im4.jpg’, im4)  
—\> 13 train\_dataset = load\_dataset(“imagefolder”, “mydataset”)

File ~/miniconda3/envs/pytr/lib/python3.9/site-packages/datasets/load.py:2523, in load\_dataset(path, name, data\_dir, data\_files, split, cache\_dir, features, download\_config, download\_mode, verification\_mode, ignore\_verifications, keep\_in\_memory, save\_infos, revision, token, use\_auth\_token, task, streaming, num\_proc, storage\_options, trust\_remote\_code, **config\_kwargs)  
2518 verification\_mode = VerificationMode(  
2519 (verification\_mode or VerificationMode.BASIC\_CHECKS) if not save\_infos else VerificationMode.ALL\_CHECKS  
2520 )  
2522 # Create a dataset builder  
 → 2523 builder\_instance = load\_dataset\_builder(  
2524 path=path,  
2525 name=name,  
…  
File ~/miniconda3/envs/pytr/lib/python3.9/site-packages/fsspec/utils.py:734, in glob\_translate(pat)  
732 continue  
733 elif "**" in part:  
 → 734 raise ValueError(  
735 “Invalid pattern: ‘\*\*’ can only be an entire path component”  
736 )  
737 if part:  
738 results.extend(\_translate(part, f"{not\_sep}\*", not\_sep))

ValueError: Invalid pattern: ‘\*\*’ can only be an entire path component
