Demo Experiment on Research Paper named: PhysGAN : Generating Physical-World-Resilient Adversarial Examples for Autonomous Driving.
Section 1: Understanding words RESILIENT AND ADVERSARIAL
The term “resilient” generally refers to the ability of a person, system, organization, or community to adapt, recover, and bounce back from difficult circumstances, challenges, or adversity. Resilience is often associated with qualities such as flexibility, strength, toughness, and perseverance.
In psychology, resilience is often defined as the capacity to cope with stress, trauma, and adversity in a healthy and adaptive way, rather than being overwhelmed or defeated by these experiences. Resilience can be developed through a combination of individual traits such as optimism, problem-solving skills, and social support, as well as environmental factors such as stable relationships, safe living conditions, and access to resources.
In the context of systems and organizations, resilience refers to the ability to withstand and recover from disruptions, crises, and shocks. This can involve measures such as contingency planning, redundancy, and risk management, as well as a culture of learning and continuous improvement.
Adversarial — In machine learning, adversarial refers to the situation where an adversary (i.e., attacker) deliberately tries to manipulate the model’s input to cause incorrect or misleading predictions. Adversarial attacks can be launched on various types of machine learning models, including deep neural networks, decision trees, and support vector machines.
Adversarial attacks can take different forms, such as adding small perturbations to the input data, modifying or removing specific features, or crafting entirely new examples that are designed to fool the model. The goal of adversarial attacks is to expose the weaknesses of the model and improve its robustness and accuracy in real-world scenarios. Adversarial training is a common technique used to defend against such attacks by training the model on adversarial examples along with the regular data.
Section 2: Understanding Dataset.py
Click here to view code / This is a Python code for a custom dataset called Udacity40G
which is a part of the Udacity Self-Driving Car Nanodegree program. The dataset contains images captured from a car's front camera, and corresponding steering angles at each timestamp. The purpose of this dataset is to train a neural network to predict steering angles based on the input image.
The dataset class inherits from the torch.utils.data.Dataset
class and overrides two methods, __len__()
and __getitem__()
. The __len__()
method returns the number of samples in the dataset, which is the number of images in the t
(type) directory. The __getitem__()
method returns a tuple of the image and corresponding steering angle for a given index. It first finds the closest steering angle to the timestamp of the image using the self.steering_data
dataframe. Then it reads the image from the file path, applies some transformations to the image, and returns it along with the steering angle.
The transformations applied to the image include resizing it to (150, 200), cropping the top 66 pixels and the bottom 20 pixels, and converting it to a PyTorch tensor using the ToTensor()
function from torchvision.transforms
. This preprocessing is common for many self-driving car datasets to reduce the input size and focus on the most relevant part of the image, which is the road ahead.
Overall, this code provides a convenient way to load the Udacity 40G dataset for training a neural network to predict steering angles based on input images.
There Error I got while running the Data.py was due to the absence of modules that needs to be installed locally on the machine below are the commands necessary to install the Modules(Packages).
- pip install numpy
- pip install pandas
- pip install matplotlib
For installing pytorch click here and read the information to configure it to your requirements.
Section 3: Understanding Steering.py
The code seems to be implementing a neural network model for predicting steering angles in autonomous driving.
It defines a class called Dave2
which is a convolutional neural network consisting of a series of convolutional layers followed by fully connected layers. The Steering
class is defined, which initializes three instances of Dave2
model: model_left
, model_center
, and model_right
.
The __call__
method of the Steering
class takes three arguments l
, c
, and r
, which correspond to the input images from the left, center, and right cameras, respectively. It then returns the average of the predicted steering angles from the three models.
The train
method of the Steering
class trains each of the three models using the Udacity40G
dataset. The test
method tests the three models on the dataset and computes the mean squared error between the predicted and true steering angles.
The save_model
and load_model
functions from the utils
module are used to save and load the trained models. The trained models are saved to the steering_models
directory.
Errors:
The error message suggests that there is an issue with the input parameter ‘t’ in the Udacity40G constructor. The value of ‘t’ is expected to be either ‘center’, ‘left’ or ‘right’ but it seems that the provided value is ‘left’, which is not a valid option.
To resolve this issue, you can check the value of ‘t’ that you are passing to the Udacity40G constructor and make sure that it is either ‘center’, ‘left’ or ‘right’. If you are sure that the value is correct, then you can check the Udacity40G dataset to ensure that it supports the type of data that you are trying to access.
The error message indicates that the code is raising a ValueError
with the message "udacity 40G dataset dose not have type 'left'", which occurs in the dataset.py
file on line 20. So you should check the __init__
method of the Udacity40G
class in dataset.py
to see why the type
argument is not being recognized as a valid type for the dataset.
Based on the error message, it seems that the dataset class is expecting a valid type for the Udacity 40G dataset, but it is receiving an invalid type ‘left’. To fix the code, you should check the valid types for the Udacity 40G dataset and use one of them in the call to _train
function.
You can check the valid types for the Udacity 40G dataset by looking at the Udacity40G
class definition in the dataset.py
file. For example, if the valid types are 'center', 'left' and 'right', you can modify the call to _train
function as follows:
_train(self.model_left, Udacity40G(t=’center’), ‘center’)
_train(self.model_left, Udacity40G(t=’left’), ‘left’)
_train(self.model_left, Udacity40G(t=’right’), ‘right’)
- The following errors I got was due to absence of data set that I couldn’t load in my local machine. I am mentioning the important links to download the Data set the Dataset is a video captured of a CAR Drive footage of the front Dashboard for somewhat 12 hr sunny climate.
- Important Link to Download The DATA SET
Section 4: Understanding Utils.py
This is a Python module that provides three functions:
save_model(model, path)
: This function saves the state dictionary of a PyTorch model to a file at the givenpath
.load_model(model, path)
: This function loads the state dictionary of a PyTorch model from a file at the givenpath
and loads it into the model.setup_logger(logger, level=logging.DEBUG, filename=None)
: This function sets up a logger object with the specified logging level (default islogging.DEBUG
) and an optional output file (iffilename
is notNone
). The logger will output log messages to the console and/or file depending on the setup.