Academy Omen
  • Tutorials
  • About

Academy Omen

Join us on a quest for excellence with our world-class tutorials. Elevate your software engineering skills and open new doors of opportunity.

About

GitHubX (Fomerly Twitter)Youtube Channel

Company

HomeAboutContact

Contact

+012 XXXXXXXXX

peng@traleor.com

Powered By Traleor CMS (& Wagtail)

How to Build an AI Model with Tensorflow & Deploy with Django - Step by Step Guide

Date Published: 2022-06-21

Tensored Django
HomeTutorials
Peng

Peng Akebuon

Tutorial Summary

⭐ Hello World, In this video we walk you through the process of training an Artificial Intelligence model with Tensorflow precisely a Multi-image classifier. We prepare our dataset, load it, train the model and save it. The saved model is then used by our Django web app to perform predictions i.e predicts the class of an image uploaded to the website. The training of the model is done using a simple convolutional neural network which can be easily extended. After training, the model is saved and loaded by Django in order to perform predictions from our web app

📚 Materials/References

🎉 Source Code
🔗Starter files
🔗 Tensorflow Image Classifier Example
🔗 Django Beginner's Tutorial

# Preparing Dataset
# temporal storage for labels and images
data=[]
labels=[]

# Cat 0
# Get the animal directory
cats = os.listdir(os.getcwd() + "/CNN/data/cat")
for x in cats:
    """
    Loop through all the images in the directory
    1. Convert to arrays
    2. Resize the images
    3. Add image to dataset
    4. Add the label
    """
    imag=cv2.imread(os.getcwd() + "/CNN/data/cat/" + x)
    img_from_ar = Image.fromarray(imag, 'RGB')
    resized_image = img_from_ar.resize((50, 50))
    data.append(np.array(resized_image))
    labels.append(0)

# load in animals and labels
animals=np.array(data)
labels=np.array(labels)
# save
np.save("animals",animals)
np.save("labels",labels)

# Train Model
# train through 100 times
history = model.fit(x_train, y_train, epochs=100,
                    validation_data=(x_test, y_test))

# perform validation and get accuracy
test_loss, test_acc = model.evaluate(x_test,  y_test, verbose=2)

print(test_acc)

# save the model or brain
model.save("model.h5")

Let's Connect

🔗 LinkedIn
🔗 Twitter
🔗 Join Our Discord Server

🔗 Academy Omen: GitHub

artificial intelligencedjangopythontensorflow

Related Tutorials

How to Build a Software as a Service with Django

How to Build a Software as a Service with Django

Intermediate

2021-07-05

A comprehensive, step-by-step guide aimed at beginners, covering the creation of a Soft...

How to Host a Django Website for FREE - Beginner's Step by Step Tutorial

How to Host a Django Website for FREE - Beginner's Step by Step Tutorial

Beginner

2021-04-12

A Beginner's step-by-step guide showing you how to deploy or host your Django websites ...

Django Beginner's Step by Step Tutorial | Build A Portfolio with Django

Django Beginner's Step by Step Tutorial | Build A Portfolio with Django

Beginner

2021-03-23

We show you how to set up your Windows 10 computer for Django development, and build a ...