The Startup
Published in

The Startup

Building a Deep Learning Flower Classifier

How I built a Web App that can classify from five different flowers based on the uploaded image.

Photo by Colter Olmstead on Unsplash

Introduction

Libraries used

tensorflow==2.2.0                       
streamlit==0.65.2
numpy==1.19.1
opencv_python==4.4.0.42
Pillow==7.2.0

The Model

Transfer Learning

base_model = keras.applications.Xception(
include_top=False,
weights="imagenet",
input_shape=IMG_SIZE, pooling="avg")

The Dataset

Directory Structure for the datasets

Generating the Train and Validation Data

Generate Dataset from directory
Found 3070 images belonging to 5 classes.
Found 600 images belonging to 5 classes.

Training the Model

my_model.compile(loss="categorical_crossentropy",
optimizer="adam",metrics=["accuracy"])
history = my_model.fit(train_data, epochs=10,
validation_data=val_data)
keras.models.save_model(model=my_model, 
filepath="flower_classifier.hdf5")

Creating the Application

Pre-processing

Running the application

$ streamlit run <APP_NAME>.py

Result

Final Look at our app

Conclusion

--

--

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +768K followers.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store