ryanjcooper / EMNIST

A project designed to explore CNN and the effectiveness of RCNN on classifying the EMNIST dataset.
MIT License
95 stars 37 forks source link

Use numpy to rotate images #7

Closed crazzle closed 6 years ago

crazzle commented 6 years ago

Transposing images is faster when using numpy.fliplr + rot90

ryanjcooper commented 6 years ago

I have tested the pull request and I encountered a numpy error: ValueError: Input must be >= 2-d.

In reshape(img) the initial image is shaped as (784,) not (28,28). The return is also expected as (784,).

This process could be streamlined to avoid multiple reshapes by reshaping when the data is loaded into memory.

I will merge this if you can resolve the error in reshape() or optimize the reshapes so an operation like this can occur.

crazzle commented 6 years ago

You are right, it is working now. As proposed I reshape the data in the beginning to (max_, height, width, 1). Also renamed reshape to rotate to differentiate from np.reshape :)

ryanjcooper commented 6 years ago

Thanks for the optimization @crazzle. On my machine, the preprocessing now takes 17.44 sec compared to the previous 112.72 sec.

Great suggestion!

crazzle commented 6 years ago

You are welcome :)!