# App cannot access uploaded files

**URL:** <https://discuss.huggingface.co/t/app-cannot-access-uploaded-files/110562>\
**Category:** Spaces\
**Created:** [October 7, 2024, 8:15am UTC](https://discuss.huggingface.co/t/app-cannot-access-uploaded-files/110562 "2024-10-07T08:15:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pablogps](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/pablogps/32/32528_2.png) [@Pablogps](https://discuss.huggingface.co/u/Pablogps)\
**Post date:** [October 7, 2024, 8:15am UTC](https://discuss.huggingface.co/t/app-cannot-access-uploaded-files/110562/1 "2024-10-07T08:15:53Z")

</div>

Hi! I am trying to create a super-basic Space as an example for my students. In fact, I already have such a Space from last year, but I tried replicating it just in case and I am having trouble with uploaded images.

Relevant info:

- I am working from the HF front, as my students have limited experience.
- I am uploading images using the “+ Add File” button. Files are, by default, at root level (same as app.py).
- If I set “examples” as an empty list then the Space works just fine.
- I also tried using a list of lists in “examples”, as suggested by GPT.
- Error message (when using only one image): “`ValueError: File /home/user/app/french.jpg is not in the upload folder and cannot be accessed.`”

This is the Space in question (currently not working, but you should be able to look at the files):

> **[Pablogps/castles at main](https://huggingface.co/spaces/Pablogps/castles/tree/main)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

For extra convenience, here you have the code directly:

```auto
import gradio as gr
from fastai.vision.all import *
from huggingface_hub import from_pretrained_fastai

learn = from_pretrained_fastai("Pablogps/gradio-test-24")
labels = learn.dls.vocab

def predict(img):
    img = PILImage.create(img)
    pred, pred_idx, probs = learn.predict(img)
    return {labels[i]: float(probs[i]) for i in range(len(labels))}

title = "Bad castle predictor"
description = "A bad model that tries to identify the type of castle."
examples = ['spanish.jpg', 'french.jpg', 'japanese.jpg']

gr.Interface(
    fn=predict,
    inputs=gr.Image(),
    outputs=gr.Label(num_top_classes=3),
    title=title,
    description=description,
    examples=examples,
).launch()
iface.launch()

```

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [October 7, 2024, 10:16am UTC](https://discuss.huggingface.co/t/app-cannot-access-uploaded-files/110562/2 "2024-10-07T10:16:25Z")

</div>

Before the code error, some of the uploaded files don’t have file extensions and are misnamed, like “spanish”.  
Also, you only need to do launch() once.

```py
).launch()
iface.launch()

```

to

```py
).launch()

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/hellohellohello/original/2X/d/de4155eb4aa4108ecb32a1389d7cc37ae69f88b7.png) [@system](https://discuss.huggingface.co/u/system)\
**Post date:** [October 8, 2024, 7:54am UTC](https://discuss.huggingface.co/t/app-cannot-access-uploaded-files/110562/3 "2024-10-08T07:54:08Z")

</div>

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
