Pages
<aside>
Home | Model Architechture | Model Training | Datasets | Data Preprocessing | Libraries | Training Analysis | Full Code Breakdown
</aside>
Import Segment
<aside>
import os
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import matplotlib.pyplot as plt
import seaborn as sns
import requests
import gradio as gr
from io import BytesIO
from PIL import Image
from sklearn import preprocessing
from sklearn.metrics import classification_report, confusion_matrix
from torchvision import datasets, transforms
</aside>
Explaination
<aside>
1. os
- Provides functionality to interact with the operating system, such as file and directory handling.
2. torch
- Core library of PyTorch, used for building and training machine learning models. It provides tensors and related operations for deep learning.
3. torch.nn
- Contains modules to define and work with neural network layers, such as
Linear, Conv2d, and LSTM.
4. torch.nn.functional
- Offers a functional interface to PyTorch's operations, providing stateless implementations of activation functions, loss functions, etc.
5. torch.optim
- Provides optimization algorithms like SGD, Adam, and RMSprop, used to update model parameters during training.
6. matplotlib.pyplot
- Used for creating static, interactive, and animated visualizations in Python, such as line plots and histograms.
7. seaborn
- Built on top of
matplotlib, it simplifies data visualization by providing high-level interface for attractive and informative statistical graphics.
8. requests
- Enables sending HTTP requests to fetch data or interact with web APIs, commonly used to download files or retrieve information from the internet.
9. gradio
- A library for creating user-friendly web-based interfaces for machine learning models, making them easily accessible.
10. io.BytesIO
- Provides an in-memory binary stream, commonly used for working with image data fetched from the internet or APIs.
11. PIL.Image
- Part of the Python Imaging Library (Pillow), used for opening, manipulating, and saving image files.
12. sklearn.preprocessing
- Provides utilities for data preprocessing, such as scaling, encoding, and normalizing features.
13. sklearn.metrics.classification_report
- Generates a detailed performance summary of classification models, including precision, recall, and F1-score.
14. sklearn.metrics.confusion_matrix
- Computes the confusion matrix, a table used to evaluate the performance of a classification model by comparing predicted and true labels.
15. torchvision.datasets
- Provides popular datasets for computer vision, such as CIFAR-10, MNIST, and ImageNet, along with functionality to load them.
16. torchvision.transforms
- Provides data augmentation and preprocessing techniques for images, such as resizing, flipping, normalization, and conversion to tensors.
</aside>