# Add image examples using Gradio "API mode"

**URL:** <https://discuss.huggingface.co/t/add-image-examples-using-gradio-api-mode/21175>\
**Category:** 🔒 Gradio\
**Created:** [August 2, 2022, 10:27pm UTC](https://discuss.huggingface.co/t/add-image-examples-using-gradio-api-mode/21175 "2022-08-02T22:27:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alkzar90](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/alkzar90/32/30144_2.png) [@alkzar90](https://discuss.huggingface.co/u/alkzar90)\
**Post date:** [August 2, 2022, 10:27pm UTC](https://discuss.huggingface.co/t/add-image-examples-using-gradio-api-mode/21175/1 "2022-08-02T22:27:52Z")

</div>

Hi!

I am playing with an [App](https://huggingface.co/spaces/alkzar90/croupier-creature-app) that loads a model from the Hugging Face hub, but I find problems when I add some image examples to the app during the building. I tried uploading the images to the repository and downloading them from another place, but the error continued.

Is there some behaviour to process image example when using Gradio in [API mode](https://github.com/gradio-app/gradio/wiki/How-data-gets-processed-in-a-Gradio-Interface) that can trigger the error?

Best,  
Cristóbal

```auto
--2022-08-02 22:11:04-- https://huggingface.co/alkzar90/croupier-creature-classifier/resolve/main/examples/crusader_peco_peco.png
Resolving huggingface.co (huggingface.co)... 52.2.34.29, 34.231.117.252, 2600:1f18:147f:e850:d57d:d46a:df34:61ee, ...
Connecting to huggingface.co (huggingface.co)|52.2.34.29|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3648 (3.6K) [image/png]
Saving to: ‘crusader_peco_peco.png’

     0K ... 100% 168M=0s

2022-08-02 22:11:04 (168 MB/s) - ‘crusader_peco_peco.png’ saved [3648/3648]

--2022-08-02 22:11:05-- https://huggingface.co/alkzar90/croupier-creature-classifier/resolve/main/examples/goblin_wow.png
Resolving huggingface.co (huggingface.co)... 52.2.34.29, 34.231.117.252, 2600:1f18:147f:e850:d57d:d46a:df34:61ee, ...
Connecting to huggingface.co (huggingface.co)|52.2.34.29|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 109057 (107K) [image/png]
Saving to: ‘goblin_wow.png’

     0K .......... .......... .......... .......... .......... 46% 51.1M 0s
    50K .......... .......... .......... .......... .......... 93% 81.0M 0s
   100K ...... 100% 21.4M=0.002s

2022-08-02 22:11:05 (56.0 MB/s) - ‘goblin_wow.png’ saved [109057/109057]

Fetching model from: https://huggingface.co/alkzar90/croupier-creature-classifier
/home/user/.local/lib/python3.8/site-packages/gradio/interface.py:313: UserWarning: Currently, only the 'default' theme is supported.
  warnings.warn("Currently, only the 'default' theme is supported.")
Caching examples at: '/home/user/app/gradio_cached_examples/51/log.csv'
Traceback (most recent call last):
  File "app.py", line 7, in <module>
    iface = gr.Interface.load('alkzar90/croupier-creature-classifier',
  File "/home/user/.local/lib/python3.8/site-packages/gradio/interface.py", line 108, in load
    return super().load(name=name, src=src, api_key=api_key, alias=alias, **kwargs)
  File "/home/user/.local/lib/python3.8/site-packages/gradio/blocks.py", line 744, in load
    return external.load_blocks_from_repo(name, src, api_key, alias, **kwargs)
  File "/home/user/.local/lib/python3.8/site-packages/gradio/external.py", line 40, in load_blocks_from_repo
    blocks: gradio.Blocks = factory_methods[src](name, api_key, alias, **kwargs)
  File "/home/user/.local/lib/python3.8/site-packages/gradio/external.py", line 294, in get_models_interface
    interface = gradio.Interface(**kwargs)
  File "/home/user/.local/lib/python3.8/site-packages/gradio/interface.py", line 599, in __init__
    self.examples_handler = Examples(
  File "/home/user/.local/lib/python3.8/site-packages/gradio/examples.py", line 154, in __init__
    self.cache_interface_examples()
  File "/home/user/.local/lib/python3.8/site-packages/gradio/examples.py", line 189, in cache_interface_examples
    raise e
  File "/home/user/.local/lib/python3.8/site-packages/gradio/examples.py", line 185, in cache_interface_examples
    prediction = self.process_example(example_id)
  File "/home/user/.local/lib/python3.8/site-packages/gradio/examples.py", line 205, in process_example
    predictions = self.fn(*processed_input)
  File "/home/user/.local/lib/python3.8/site-packages/gradio/external.py", line 259, in query_huggingface_api
    data = pipeline["preprocess"](*params)
  File "/home/user/.local/lib/python3.8/site-packages/gradio/external.py", line 131, in <lambda>
    i.split(",")[1]
IndexError: list index out of range

```

---

<div class="post-metadata">

**Author:** ![freddyaboulton](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/freddyaboulton/32/32732_2.png) [@freddyaboulton](https://discuss.huggingface.co/u/freddyaboulton)\
**Post date:** [August 2, 2022, 11:01pm UTC](https://discuss.huggingface.co/t/add-image-examples-using-gradio-api-mode/21175/2 "2022-08-02T23:01:17Z")

</div>

Hi @alkzar90,

Can you please try with cache\_examples=False?

I think this is the same problem as this issue ([https://github.com/gradio-app/gradio/issues/1643](https://github.com/gradio-app/gradio/issues/1643)). Good news is that I’m planning on fixing the underlying issue by the end of the week!

---

<div class="post-metadata">

**Author:** ![freddyaboulton](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/freddyaboulton/32/32732_2.png) [@freddyaboulton](https://discuss.huggingface.co/u/freddyaboulton)\
**Post date:** [August 2, 2022, 11:10pm UTC](https://discuss.huggingface.co/t/add-image-examples-using-gradio-api-mode/21175/3 "2022-08-02T23:10:04Z")

</div>

Also, you can store the example images in the repo with git as opposed to pulling them in the app file.

---

<div class="post-metadata">

**Author:** ![alkzar90](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/alkzar90/32/30144_2.png) [@alkzar90](https://discuss.huggingface.co/u/alkzar90)\
**Post date:** [August 3, 2022, 4:07am UTC](https://discuss.huggingface.co/t/add-image-examples-using-gradio-api-mode/21175/4 "2022-08-03T04:07:46Z")

</div>

Hi @freddyaboulton,

it works with `cache_examples=False`, thanks for the suggestion!  
Now I will move the images into the repo instead of downloading them from the app file, it was. a desperate move trying to fix the problem hahaha,

Best!
