# How to run image classification on image url

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-run-image-classification-on-image-url%2F20604%3E%5C
**Category:** 🤗Datasets\
**Created:** [July 20, 2022, 5:59am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-run-image-classification-on-image-url%2F20604 "2022-07-20T05:59:53Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnielsr)%5C
**Post date:** [July 21, 2022, 10:52am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-run-image-classification-on-image-url%2F20604%2F5 "2022-07-21T10:52:27Z")

</div>

Yes you can probably map them all to Pillow images and then cast to the Image feature:

```auto
from datasets import load_dataset
import requests
from PIL import Image

def to_pillow(examples):
    urls = examples['Photo']
    images = []
    for url in urls:
      image = Image.open(requests.get(url, stream=True).raw)
      images.append(image)
    
    examples['image'] = images
    
    return examples

dataset = load_dataset("TheNoob3131/mosquito-data")
dataset = dataset.map(to_pillow, batched=True)

from datasets import Image

dataset = dataset.cast_column('image', Image)

```

I’m going to cc @mariosasko here (`map` seems to very slow). Alternatively, you can do:

```auto
dataset.set_transform(to_pillow)

```

to do this on the fly.

---

_[View the full topic](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-run-image-classification-on-image-url%2F20604)._
