Basic steps required for Computer Vision Machine Learning
Basic steps required for Computer Vision Machine Learning
Amit Tamse
2/15/20261 min read
Step 1 : Install the below packages:
!pip install tensorflow[and-cuda] scikit-learn==1.6.1 opencv-python==4.12.0.88 seaborn==0.13.2 matplotlib==3.10.0 numpy==2.0.2 pandas==2.2.2 -q
These packages are used for deep learning (TensorFlow), machine learning (scikit-learn), computer vision (OpenCV), data visualization (Seaborn, Matplotlib), numerical operations (NumPy), and data analysis (Pandas).
Step 2: Import all the important Classes from the installed packages:
import os
import random
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
import math
import cv2
# Tensorflow modules
import keras
import tensorflow as tf
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense,Dropout,Flatten,Conv2D,MaxPooling2D,BatchNormalization
from tensorflow.keras.optimizers import Adam,SGD
from sklearn import preprocessing
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix
from tensorflow.keras.models import Model
from keras.applications.vgg16 import VGG16
# Display images using OpenCV
from google.colab.patches import cv2_imshow
#Imports functions for evaluating the performance of machine learning models
from sklearn.metrics import confusion_matrix, f1_score,accuracy_score, recall_score, precision_score, classification_report
from sklearn.metrics import mean_squared_error as mse
# Ignore warnings
import warnings
warnings.filterwarnings('ignore')
These packages are used for operating system interaction, numerical computing, data manipulation and visualization, computer vision, and building, training, and evaluating deep learning models using TensorFlow/Keras and scikit-learn.
# Set the seed using keras.utils.set_random_seed. This will set:
# 1) `numpy` seed
# 2) backend random seed
# 3) `python` random seed
tf.keras.utils.set_random_seed(812)
We set the random seed to tf.keras.utils.set_random_seed(812) to ensure reproducibility of our experiments. This function sets seeds for NumPy, the TensorFlow backend, and Python's random module, meaning that if you run the code again with the same seed, you'll get the same "random" results, making the model training and evaluation consistent. The number 812 itself is an arbitrary choice; any integer could be used as a seed.
Portfolio
Hire Amit Tamse for your work!
Contact
Connect
Reach me at : amitktamse@gmail.com
+1 408 582 4075
© 2024. All rights reserved.