# MNIST dataframe build with my own images

**URL:** <https://discourse.julialang.org/t/mnist-dataframe-build-with-my-own-images/35567>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [March 5, 2020, 10:02am UTC](https://discourse.julialang.org/t/mnist-dataframe-build-with-my-own-images/35567 "2020-03-05T10:02:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mihai-Constantinescu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mihai-constantinescu/32/8664_2.png) [@Mihai-Constantinescu](https://discourse.julialang.org/u/Mihai-Constantinescu)\
**Post date:** [March 5, 2020, 10:02am UTC](https://discourse.julialang.org/t/mnist-dataframe-build-with-my-own-images/35567/1 "2020-03-05T10:02:59Z")

</div>

Hello,

I’m looking to build a MNIST type database with my own images in order to train a One-Class CNN. I have the images processed in Julia (Gray, 28x28), I know the label of each one, but I don’t know how to build the database.  
Any idea, please?

Best regards,  
Mihai

---

<div class="post-metadata">

**Author:** ![Iulian.Cioarca](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iulian.cioarca/32/30166_2.png) [@Iulian.Cioarca](https://discourse.julialang.org/u/Iulian.Cioarca)\
**Post date:** [March 5, 2020, 1:51pm UTC](https://discourse.julialang.org/t/mnist-dataframe-build-with-my-own-images/35567/2 "2020-03-05T13:51:47Z")

</div>

Hello and welcome!

Do you want to follow the exact MNIST format? I worked with Knet framework, so I will base my example on that  
I suggest the intro in the example here:  
[https://github.com/denizyuret/Knet.jl/blob/master/tutorial/50.cnn.ipynb](https://github.com/denizyuret/Knet.jl/blob/master/tutorial/50.cnn.ipynb)  
`dtrn` and `dtst` are special Knet Types containing the multidimensional array of images: 28 x 28 x 1 x nimages and the vector of labels: usually integers. (and some other stuff like batch size etc…)  
For example:

```julia
xtrn = fill(Float32(0),w,h,nr_channels,nr_images) # here you push images
ytrn = fill(UInt8(0),nr_files)# here you push labels

```

after this you can simply call:  
`dtrn = Knet.minibatch(xtrn, ytrn, batchsize; shuffle=true, xtype=xtype, o...)`

Do that also for test dataset and your’re good to go.

I think I can come with a more complete example for you a little later if you need more info.

Have fun!

---

<div class="post-metadata">

**Author:** ![Mihai-Constantinescu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mihai-constantinescu/32/8664_2.png) [@Mihai-Constantinescu](https://discourse.julialang.org/u/Mihai-Constantinescu)\
**Post date:** [March 5, 2020, 3:32pm UTC](https://discourse.julialang.org/t/mnist-dataframe-build-with-my-own-images/35567/3 "2020-03-05T15:32:01Z")

</div>

Hi Iulian,

Thank you for support. As you may know, Ambrosia weed is a very undesired plant, who cause trouble to a lot of people. I’m involved in a project of detecting that plant from aerial images taken by drone flying at medium to high altitude. I have prepared the training set and, based on your suggestion, I’ll migrate it into a database form, ready to be processed in Julia ML.

Best regards,  
Mihai
