# I am trying to import a image dataset from kaggle

**URL:** https://discourse.julialang.org/t/i-am-trying-to-import-a-image-dataset-from-kaggle/78476
**Category:** New to Julia
**Tags:** question
**Created:** [March 25, 2022, 5:28pm UTC](https://discourse.julialang.org/t/i-am-trying-to-import-a-image-dataset-from-kaggle/78476 "2022-03-25T17:28:23Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![zed\_unseened](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zed_unseened/32/34778_2.png) [@zed\_unseened](https://discourse.julialang.org/u/zed_unseened)
#### Post date: [March 25, 2022, 5:28pm UTC](https://discourse.julialang.org/t/i-am-trying-to-import-a-image-dataset-from-kaggle/78476/1 "2022-03-25T17:28:23Z")

</div>

here is also the link to the dataset:

> **[Chest X-Ray Images (Pneumonia)](https://www.kaggle.com/paultimothymooney/chest-Xray-pneumonia)**
>
> 5,863 images, 2 categories

I am trying to create an image classifier using an AlexNet Architecture  
This is the way I tried to import the data set but I am encountering problems

```julia
using Markdown
using InteractiveUtils
using Pkg

Pkg.activate("Project.toml")
Pkg.add("Flux")

#load data
trainData = "../src/dataset/chest_xray/train/"
testData = "../src/dataset/chest_xray/test/"
validationData = "../src/dataset/chest_xray/val/"

trainNormal = "../src/dataset/chest_xray/train/NORMAL/"
TrainPneumonia = "../src/dataset/chest_xray/train/PNEUMONIA/"

length(trainNormal)

```

---

<div class="post-metadata">

### Author: ![albheim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albheim/32/34660_2.png) [@albheim](https://discourse.julialang.org/u/albheim)
#### Post date: [March 27, 2022, 11:52am UTC](https://discourse.julialang.org/t/i-am-trying-to-import-a-image-dataset-from-kaggle/78476/2 "2022-03-27T11:52:17Z")

</div>

Pretty scarce information here.

What are you expecting this to do? What problems are you encountering?

---

<div class="post-metadata">

### Author: ![Rasmus\_Hoier](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rasmus_hoier/32/24036_2.png) [@Rasmus\_Hoier](https://discourse.julialang.org/u/Rasmus_Hoier)
#### Post date: [March 27, 2022, 12:19pm UTC](https://discourse.julialang.org/t/i-am-trying-to-import-a-image-dataset-from-kaggle/78476/3 "2022-03-27T12:19:12Z")

</div>

Hi,  
Currently you are just creating strings containing the paths to the images.  
To load them you could use the Images package

```julia
using Images, ImageInTerminal
imgdir = "test/NORMAL"
imgpaths = readdir(imgdir, join=true)
imgpaths = imgpaths[2:end] # On my machine element 1 is the path to a .DSstore file, so I am omitting that. 
imgs = load.(imgpaths)

```

You can view one of the images in the terminal (thanks to ImageInTerminal) by typing  
`imgs[1]`  
For training a neural network you probably want to work with Float32 arrays rather than grayscale images  
`imgsFloat32 = convert.(Matrix{Float32}, imgs)`  
but it might require a lot of memory to run this line on the entire train set at once.

Note that your images appear to have different sizes. Maybe you would need to get them resized to a common size before training.

---

<div class="post-metadata">

### Author: ![zed\_unseened](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zed_unseened/32/34778_2.png) [@zed\_unseened](https://discourse.julialang.org/u/zed_unseened)
#### Post date: [March 27, 2022, 7:34pm UTC](https://discourse.julialang.org/t/i-am-trying-to-import-a-image-dataset-from-kaggle/78476/4 "2022-03-27T19:34:29Z")

</div>

The problem is i am not loading the images correctly so i was just asking what the correct why was to do it basically

---

<div class="post-metadata">

### Author: ![zed\_unseened](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zed_unseened/32/34778_2.png) [@zed\_unseened](https://discourse.julialang.org/u/zed_unseened)
#### Post date: [March 27, 2022, 7:34pm UTC](https://discourse.julialang.org/t/i-am-trying-to-import-a-image-dataset-from-kaggle/78476/5 "2022-03-27T19:34:55Z")

</div>

Thanks, I will give this a try.
