Skip to content

Intel one api #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 71 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,84 @@
# intel-oneAPI

#### Team Name -
#### Problem Statement -
#### Team Leader Email -
#### Team Name - Scoops Troops
#### Problem Statement - Object Detection in Autonomous Vehicles.
#### Team Leader Email -[email protected]

## A Brief of the Prototype:
This section must include UML Daigrms and prototype description

**Our object detection prototype is an early version or concept implementation of the object detection system. It serves as a demonstration or initial implementation to showcase the feasibility and functionality of an object detection solution. Object Detection plays the most important role in Autonomous vehicles. Our idea is to add a system that detects the objects even in the blind spots of our vehicle using radiation. Detecting vehicles in blindspots: Most of the time accidents occur because of not knowing about the vehicles in our blindspots, this solution used LiDAR point clouds to alert our system about the vehicles in our blindspots.
Our prototype aims to detect and localize objects within an image or video stream and also takes radiations as input. Objects to detect includes pedestrians, vehicles, or specific objects of interest. Our prototype uses tensorflow model, which is a pre-trained model . We'll train the model with our new dataset to detect object.
Our prototype uses LiDAR sensor with it laser light radiations to detect objects in the blind spot.**

**DATA ACQUISITION**:
All the necessary data is collected from various sensors including LiDAR, camera and RADAR. A dataset is created using all the aggregated data to work with.

**LANE DETECTION**:
In this part of our prototype, Codes and procedures done for Lane Detection is provided. We use Intel libraries like OpenCV, OneDNN etc,.

Importing Libraries : Install all the necessary libraies such as Numpy , Open CV, Matplotlib , Tensorflow , Scikit learn , Scikit image , one DNN that are optimized with Intel.

Selecting a Pre-trained Model : We are going to use the pre-trained model OpenCV to detect lanes.
Intel OpenCV, also known as the Intel Open Source Computer Vision Library, is a powerful and widely used open-source library for computer vision and image processing tasks. It is an optimized version of the popular OpenCV library, tailored specifically for Intel hardware platforms.

Understanding the Model : Familiarize yourself with the architecture and specifications of the pretrained object detection model you intend to use. Understand the input format expected by the model, the number and types of output classes, and any specific requirements or constraints.

Load the Pre-trained Model : This involves downloading the pretrained model's weights and loading them into the corresponding model architecture.

Coding : It is a pretrained model , So write program codes to perform Lane detection

Optimization of the Model using OneDNN : Load the code file into the Intel OneDNN Architecture .By Providing them with the right coordinates that we used in the code, the OneDNN optimizes our model for more accurate ojutputs.

Evaluation : After writing the program code, codes are tested using a sample video.
Upload the video to the text editor and Run the code to get the output.

**OBJECT DETECTION**:
Object Detection is totally executed using LiDAR along with other Intel toolkits such as Intel IPP (Integrated Performance Primitives).
Using LiDAR we can detect the object with the help of lasers from LiDAR . You get a 2D graph of the outline of the object that has been detected by LiDAR.
LiDAR by itself performs Data aquisition , Object Detection and Visualization. LiDAR also calculates the distance at which the object is present from our vehicle with the value of the speed that the laser light takes to bounce back.

## Tech Stack:
List Down all technologies used to Build the prototype **Clearly mentioning Intel® AI Analytics Toolkits, it's libraries and the SYCL/DCP++ Libraries used**

**Programming Languages**: Python.
**Machine Learning Frameworks**:TensorFlow, Numpy ,MAtplotlib, Scikit learn, scikit image is used for building and training machine
learning models.
**Computer Vision Libraries**: Libraries such as OpenCV can be used for image
processing and computer vision tasks.
**OneAPI Toolkit**: Intel OpenCV , Intel oneAPI Deep Neural Network Library (oneDNN), Intel OneAPI Base toolkit , Intel IPP (Integrated Performance Primitives).
**Development Tools**: Intel Devcloud, version control systems such as Git, VS code 2005 .
**Testing Tools**: Unit testing frameworks such as PyTest will be used for testing
the prototype's functionality.
**Visualization Tool**s: Visualization tools such as Matplotlib and Tensorflow is used.

## Step-by-Step Code Execution Instructions:
This Section must contain set of instructions required to clone and run the prototype, so that it can be tested and deeply analysed
1. Install all the necessary libraries such as opencv, numpy, matplotlib, u scikit learn, scikit image using the install command
2. Import all the installed libraries using the import command.
3. Create a function named 'detect_lanes' that has the following attributes :
- The `detect_lanes` function takes a frame (image) as input and performs lane detection on it.
- It begins by converting the frame to grayscale using `cv2.cvtColor`.
- The grayscale image is then blurred using a Gaussian filter (`cv2.GaussianBlur`) to reduce noise.
- Edges are detected in the blurred image using the Canny edge detection algorithm (`cv2.Canny`).
- A region of interest (ROI) is defined using vertices to focus on the area where the lanes are expected. The vertices are specified as a list of points.
- A mask is created by filling the ROI polygon with white pixels (`cv2.fillPoly`).
- The masked edges are obtained by applying the mask using a bitwise AND operation (`cv2.bitwise_and`).
- The Hough line transformation (`cv2.HoughLinesP`) is used to detect lines in the masked edges. The parameters control the accuracy and sensitivity of the line detection.
- Detected lines are drawn on a blank image (`line_image`) using `cv2.line`.
- The detected lane lines are overlaid on the original frame using `cv2.addWeighted` to create the `lane_image`.
- The `lane_image` is returned as the output of the function.
4. Perform Video Processing by following steps:
- Upload the video to the text editor.
- The code then sets up a video capture object (`cap`) to read frames from a video file.
- A loop is started to process each frame of the video.
- The loop reads a frame from the video using `cap.read()`.
- If the frame is successfully read (`ret` is True), the `detect_lanes` function is called to process the frame and obtain the processed frame with lane markings.
- The processed frame is displayed in a window named "Lane Detection" using `cv2.imshow`.
- If the 'q' key is pressed, the loop is terminated.
- After the loop ends or the 'q' key is pressed, the video capture is released (`cap.release()`) and all windows are closed (`cv2.destroyAllWindows()`).

## What I Learned:
Write about the biggest learning you had while developing the prototype

We learned how to make the maximum use of Intel OneAPI toolkits and to use it on various problem statements as they possess Unified Programming Model, High Performance and Optimization, Extensive Software Ecosystem, Heterogeneous Hardware Support, Scalability and Portability, Developer Productivity, Broad Industry Support. We got familiarized with Intel OneAPI libraries. We learned that using Intel OneDNN for optimization gives a better accuracy than any other methods . We also learned how to run our program codes in GPU with the help of oneAPI toolkits. We learned how to work on Intel Devcloud. We also learned many other technologies and libraries that are integrated with Intel. With got familiarity with all the libraries we used. We got to know more about the different types of sensors that could be integrated with our program to perform object and lane detection.
Apart from that , We also learned to work as a team and collaborate with experts and professionals for efficiency.
257 changes: 257 additions & 0 deletions cgp.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Collecting opencv-pythonNote: you may need to restart the kernel to use updated packages.\n",
"\n",
" Downloading opencv_python-4.7.0.72-cp37-abi3-win_amd64.whl (38.2 MB)\n",
" -------------------------------------- 38.2/38.2 MB 906.7 kB/s eta 0:00:00\n",
"Collecting numpy\n",
" Downloading numpy-1.24.3-cp311-cp311-win_amd64.whl (14.8 MB)\n",
" ---------------------------------------- 14.8/14.8 MB 1.3 MB/s eta 0:00:00\n",
"Installing collected packages: numpy, opencv-python\n",
"Successfully installed numpy-1.24.3 opencv-python-4.7.0.72\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\n",
"[notice] A new release of pip available: 22.3.1 -> 23.1.2\n",
"[notice] To update, run: python.exe -m pip install --upgrade pip\n"
]
}
],
"source": [
"pip install opencv-python numpy"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Note: you may need to restart the kernel to use updated packages.Collecting matplotlib\n",
" Downloading matplotlib-3.7.1-cp311-cp311-win_amd64.whl (7.6 MB)\n",
" ---------------------------------------- 7.6/7.6 MB 783.7 kB/s eta 0:00:00\n",
"Collecting contourpy>=1.0.1\n",
" Downloading contourpy-1.0.7-cp311-cp311-win_amd64.whl (162 kB)\n",
" -------------------------------------- 163.0/163.0 kB 1.4 MB/s eta 0:00:00\n",
"Collecting cycler>=0.10\n",
" Downloading cycler-0.11.0-py3-none-any.whl (6.4 kB)\n",
"Collecting fonttools>=4.22.0\n",
" Downloading fonttools-4.39.4-py3-none-any.whl (1.0 MB)\n",
" ---------------------------------------- 1.0/1.0 MB 1.1 MB/s eta 0:00:00\n",
"Collecting kiwisolver>=1.0.1\n",
" Downloading kiwisolver-1.4.4-cp311-cp311-win_amd64.whl (55 kB)\n",
" -------------------------------------- 55.4/55.4 kB 728.3 kB/s eta 0:00:00\n",
"Requirement already satisfied: numpy>=1.20 in c:\\users\\antoj\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from matplotlib) (1.24.3)\n",
"Requirement already satisfied: packaging>=20.0 in c:\\users\\antoj\\appdata\\roaming\\python\\python311\\site-packages (from matplotlib) (23.1)\n",
"Collecting pillow>=6.2.0\n",
" Downloading Pillow-9.5.0-cp311-cp311-win_amd64.whl (2.5 MB)\n",
" ---------------------------------------- 2.5/2.5 MB 909.6 kB/s eta 0:00:00\n",
"Collecting pyparsing>=2.3.1\n",
" Downloading pyparsing-3.0.9-py3-none-any.whl (98 kB)\n",
" -------------------------------------- 98.3/98.3 kB 512.2 kB/s eta 0:00:00\n",
"Requirement already satisfied: python-dateutil>=2.7 in c:\\users\\antoj\\appdata\\roaming\\python\\python311\\site-packages (from matplotlib) (2.8.2)\n",
"Requirement already satisfied: six>=1.5 in c:\\users\\antoj\\appdata\\roaming\\python\\python311\\site-packages (from python-dateutil>=2.7->matplotlib) (1.16.0)\n",
"Installing collected packages: pyparsing, pillow, kiwisolver, fonttools, cycler, contourpy, matplotlib\n",
"Successfully installed contourpy-1.0.7 cycler-0.11.0 fonttools-4.39.4 kiwisolver-1.4.4 matplotlib-3.7.1 pillow-9.5.0 pyparsing-3.0.9\n",
"\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\n",
"[notice] A new release of pip available: 22.3.1 -> 23.1.2\n",
"[notice] To update, run: python.exe -m pip install --upgrade pip\n"
]
}
],
"source": [
"pip install matplotlib"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Collecting scikit-learn\n",
" Downloading scikit_learn-1.2.2-cp311-cp311-win_amd64.whl (8.3 MB)\n",
" ---------------------------------------- 8.3/8.3 MB 850.3 kB/s eta 0:00:00\n",
"Requirement already satisfied: numpy>=1.17.3 in c:\\users\\antoj\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from scikit-learn) (1.24.3)\n",
"Collecting scipy>=1.3.2\n",
" Downloading scipy-1.10.1-cp311-cp311-win_amd64.whl (42.2 MB)\n",
" -------------------------------------- 42.2/42.2 MB 754.1 kB/s eta 0:00:00\n",
"Collecting joblib>=1.1.1\n",
" Downloading joblib-1.2.0-py3-none-any.whl (297 kB)\n",
" ------------------------------------ 298.0/298.0 kB 219.3 kB/s eta 0:00:00\n",
"Collecting threadpoolctl>=2.0.0\n",
" Downloading threadpoolctl-3.1.0-py3-none-any.whl (14 kB)\n",
"Installing collected packages: threadpoolctl, scipy, joblib, scikit-learn\n",
"Successfully installed joblib-1.2.0 scikit-learn-1.2.2 scipy-1.10.1 threadpoolctl-3.1.0\n",
"Note: you may need to restart the kernel to use updated packages.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\n",
"[notice] A new release of pip available: 22.3.1 -> 23.1.2\n",
"[notice] To update, run: python.exe -m pip install --upgrade pip\n"
]
}
],
"source": [
"pip install -U scikit-learn\n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Collecting scikit-image\n",
" Downloading scikit_image-0.21.0-cp311-cp311-win_amd64.whl (22.8 MB)\n",
" -------------------------------------- 22.8/22.8 MB 626.5 kB/s eta 0:00:00\n",
"Requirement already satisfied: numpy>=1.21.1 in c:\\users\\antoj\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from scikit-image) (1.24.3)\n",
"Requirement already satisfied: scipy>=1.8 in c:\\users\\antoj\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from scikit-image) (1.10.1)\n",
"Collecting networkx>=2.8\n",
" Downloading networkx-3.1-py3-none-any.whl (2.1 MB)\n",
" ---------------------------------------- 2.1/2.1 MB 411.1 kB/s eta 0:00:00\n",
"Requirement already satisfied: pillow>=9.0.1 in c:\\users\\antoj\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from scikit-image) (9.5.0)\n",
"Collecting imageio>=2.27\n",
" Downloading imageio-2.30.0-py3-none-any.whl (312 kB)\n",
" ------------------------------------ 312.7/312.7 kB 379.5 kB/s eta 0:00:00\n",
"Collecting tifffile>=2022.8.12\n",
" Downloading tifffile-2023.4.12-py3-none-any.whl (219 kB)\n",
" ------------------------------------ 219.4/219.4 kB 352.1 kB/s eta 0:00:00\n",
"Collecting PyWavelets>=1.1.1\n",
" Downloading PyWavelets-1.4.1-cp311-cp311-win_amd64.whl (4.2 MB)\n",
" ---------------------------------------- 4.2/4.2 MB 463.6 kB/s eta 0:00:00\n",
"Requirement already satisfied: packaging>=21 in c:\\users\\antoj\\appdata\\roaming\\python\\python311\\site-packages (from scikit-image) (23.1)\n",
"Collecting lazy_loader>=0.2\n",
" Downloading lazy_loader-0.2-py3-none-any.whl (8.6 kB)\n",
"Installing collected packages: tifffile, PyWavelets, networkx, lazy_loader, imageio, scikit-image\n",
"Successfully installed PyWavelets-1.4.1 imageio-2.30.0 lazy_loader-0.2 networkx-3.1 scikit-image-0.21.0 tifffile-2023.4.12\n",
"Note: you may need to restart the kernel to use updated packages.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\n",
"[notice] A new release of pip available: 22.3.1 -> 23.1.2\n",
"[notice] To update, run: python.exe -m pip install --upgrade pip\n"
]
}
],
"source": [
"pip install scikit-image"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"import cv2\n",
"import numpy as np\n",
"\n",
"def detect_lanes(frame):\n",
" gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)\n",
"\n",
" blurred = cv2.GaussianBlur(gray, (5, 5), 0)\n",
"\n",
" edges = cv2.Canny(blurred, 50, 150)\n",
"\n",
" height, width = frame.shape[:2]\n",
" roi_vertices = [\n",
" (0, height),\n",
" (width // 2, height // 2),\n",
" (width, height)\n",
" ]\n",
" mask = np.zeros_like(edges)\n",
" cv2.fillPoly(mask, np.int32([roi_vertices]), 255)\n",
" masked_edges = cv2.bitwise_and(edges, mask)\n",
"\n",
" lines = cv2.HoughLinesP(masked_edges, rho=1, theta=np.pi/180, threshold=50, minLineLength=100, maxLineGap=50)\n",
"\n",
" line_image = np.zeros_like(frame)\n",
" if lines is not None:\n",
" for line in lines:\n",
" x1, y1, x2, y2 = line[0]\n",
" cv2.line(line_image, (x1, y1), (x2, y2), (0, 0, 255), 3)\n",
"\n",
" lane_image = cv2.addWeighted(frame, 0.8, line_image, 1, 0)\n",
"\n",
" return lane_image\n",
"\n",
"cap = cv2.VideoCapture('C:/Users/antoj/OneDrive/Desktop/intelvid/lanevid.mp4')\n",
"\n",
"while cap.isOpened():\n",
" ret, frame = cap.read()\n",
" if not ret:\n",
" break\n",
"\n",
" processed_frame = detect_lanes(frame)\n",
"\n",
" cv2.imshow('Lane Detection', processed_frame)\n",
"\n",
" if cv2.waitKey(1) & 0xFF == ord('q'):\n",
" break\n",
"\n",
"cap.release()\n",
"cv2.destroyAllWindows()\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
Binary file added intel one api.pdf
Binary file not shown.
Loading