Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021_123
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2021_123
2021_123
Commits
bfbccd96
Commit
bfbccd96
authored
Sep 11, 2021
by
IT18121384 Thilakarathna U.G.C.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sleep Detection(Image Labeling)
parent
9094370c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
0 deletions
+74
-0
ImageLabeling.txt
ImageLabeling.txt
+74
-0
No files found.
ImageLabeling.txt
0 → 100644
View file @
bfbccd96
Image Labelling
import tensorflow as tf
import cv2
import os
import matplotlib.pyplot as plt
import numpy as np
img_array = cv2.imread("C:/Users/Thila/AppData/Local/Programs/Python/Python39/Scripts/sleep/Test/Closed_Eyes/s0001_00097_0_0_0_0_0_01.png", cv2.IMREAD_GRAYSCALE)
plt.imshow(img_array,cmap="gray")
img_array.shape
Datadirectory = "C:/Users/Thila/AppData/Local/Programs/Python/Python39/Scripts/sleep/Eyes/"
Classes = ["Closed_Eyes","Open_Eyes"]
for category in Classes:
path = os.path.join(Datadirectory, category)
for img in os.listdir(path):
img_array = cv2.imread(os.path.join(path,img), cv2.IMREAD_GRAYSCALE)
backtorgb = cv2.cvtColor(img_array,cv2.COLOR_GRAY2RGB)
plt.imshow(img_array, cmap="gray")
plt.show()
break
break
img_size = 224
new_array= cv2.resize(backtorgb, (img_size, img_size))
plt.imshow(new_array, cmap="gray")
plt.show()
training_Data = []
def create_training_Data():
for category in Classes:
path = os.path.join(Datadirectory, category)
class_num = Classes.index(category)
for img in os.listdir(path):
try:
img_array = cv2.imread(os.path.join(path,img), cv2.IMREAD_GRAYSCALE)
backtorgb = cv2.cvtColor(img_array,cv2.COLOR_GRAY2RGB)
new_array= cv2.resize(backtorgb, (img_size,img_size))
training_Data.append([new_array,class_num])
except Exception as e:
pass
create_training_Data()
print(len(training_Data))
import random
random.shuffle(training_Data)
X = []
y = []
for features,label in training_Data:
X.append(features)
y.append(label)
X = np.array(X).reshape(-1, img_size, img_size, 3)
X.shape
X= X/255.0;
Y= np.array(y)
import pickle
pickle_out = open("X.pickle", "wb")
pickle.dump(X, pickle_out)
pickle_out.close()
pickle_out = open("y.pickle", "wb")
pickle.dump(y, pickle_out)
pickle_out.close()
pickle_in = open("X.pickle","rb")
X = pickle.load(pickle_in)
pickle_in = open("y.pickle","rb")
y = pickle.load(pickle_in)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment