gurucharan-marthi / Face-Mask-Detection

In this, I am attaching my code for building a CNN model to detect if a person is wearing face mask or not using the webcam of their PC.
99 stars 92 forks source link

face mask detection perameter #3

Open clownpreet22 opened 4 years ago

clownpreet22 commented 4 years ago

what would be the perameter of this fun def split_data(SOURCE, TRAINING, TESTING, SPLIT_SIZE): dataset = []

for unitData in os.listdir(SOURCE):
    data = SOURCE + unitData
    if(os.path.getsize(data) > 0):
        dataset.append(unitData)
    else:
        print('Skipped ' + unitData)
        print('Invalid file i.e zero size')

train_set_length = int(len(dataset) * SPLIT_SIZE)
test_set_length = int(len(dataset) - train_set_length)
shuffled_set = random.sample(dataset, len(dataset))
train_set = dataset[0:train_set_length]
test_set = dataset[-test_set_length:]

for unitData in train_set:
    temp_train_set = SOURCE + unitData
    final_train_set = TRAINING + unitData
    copyfile(temp_train_set, final_train_set)

for unitData in test_set:
    temp_test_set = SOURCE + unitData
    final_test_set = TESTING + unitData
    copyfile(temp_test_set, final_test_set)

YES_SOURCE_DIR = "dest_folder/val/yes/" TRAINING_YES_DIR = "dest_folder/train/yes/" TESTING_YES_DIR = "dest_folder/test/yes/" NO_SOURCE_DIR = "dest_folder/val/no/" TRAINING_NO_DIR = "dest_folder/val/no/" TESTING_NO_DIR = "dest_folder/test/no/" split_size = .8 split_data(YES_SOURCE_DIR, TRAINING_YES_DIR, TESTING_YES_DIR, split_size) split_data(NO_SOURCE_DIR, TRAINING_NO_DIR, TESTING_NO_DIR, split_size) location of dataset

RAVIKIRAN-DHULIPALA commented 4 years ago

U r sending the parameter but which environment u r using If u r using jupyter notebook u can pass the local machine folders

But if u r using the Google colab it cannot access the local machine folders u have to upload it to the cloud.

On Thu, 2 Jul, 2020, 7:32 pm clownpreet22, notifications@github.com wrote:

what would be the perameter of this fun def split_data(SOURCE, TRAINING, TESTING, SPLIT_SIZE): dataset = []

for unitData in os.listdir(SOURCE): data = SOURCE + unitData if(os.path.getsize(data) > 0): dataset.append(unitData) else: print('Skipped ' + unitData) print('Invalid file i.e zero size')

train_set_length = int(len(dataset) * SPLIT_SIZE) test_set_length = int(len(dataset) - train_set_length) shuffled_set = random.sample(dataset, len(dataset)) train_set = dataset[0:train_set_length] test_set = dataset[-test_set_length:]

for unitData in train_set: temp_train_set = SOURCE + unitData final_train_set = TRAINING + unitData copyfile(temp_train_set, final_train_set)

for unitData in test_set: temp_test_set = SOURCE + unitData final_test_set = TESTING + unitData copyfile(temp_test_set, final_test_set)

YES_SOURCE_DIR = "dest_folder/val/yes/" TRAINING_YES_DIR = "dest_folder/train/yes/" TESTING_YES_DIR = "dest_folder/test/yes/" NO_SOURCE_DIR = "dest_folder/val/no/" TRAINING_NO_DIR = "dest_folder/val/no/" TESTING_NO_DIR = "dest_folder/test/no/" split_size = .8 split_data(YES_SOURCE_DIR, TRAINING_YES_DIR, TESTING_YES_DIR, split_size) split_data(NO_SOURCE_DIR, TRAINING_NO_DIR, TESTING_NO_DIR, split_size) [image: location of dataset] https://user-images.githubusercontent.com/42198801/86368406-c2f45780-bc9a-11ea-8b0d-1dcef380a2ae.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIAR4NWSLZY6CAPBAEIC2Y3RZSHQ3ANCNFSM4OO5NI2Q .

clownpreet22 commented 4 years ago

Im using jupyter notebook but i don't understand what will be the code

On Thu, 2 Jul 2020, 8:13 pm Ravikiran Dhulipala, notifications@github.com wrote:

U r sending the parameter but which environment u r using If u r using jupyter notebook u can pass the local machine folders

But if u r using the Google colab it cannot access the local machine folders u have to upload it to the cloud.

On Thu, 2 Jul, 2020, 7:32 pm clownpreet22, notifications@github.com wrote:

what would be the perameter of this fun def split_data(SOURCE, TRAINING, TESTING, SPLIT_SIZE): dataset = []

for unitData in os.listdir(SOURCE): data = SOURCE + unitData if(os.path.getsize(data) > 0): dataset.append(unitData) else: print('Skipped ' + unitData) print('Invalid file i.e zero size')

train_set_length = int(len(dataset) * SPLIT_SIZE) test_set_length = int(len(dataset) - train_set_length) shuffled_set = random.sample(dataset, len(dataset)) train_set = dataset[0:train_set_length] test_set = dataset[-test_set_length:]

for unitData in train_set: temp_train_set = SOURCE + unitData final_train_set = TRAINING + unitData copyfile(temp_train_set, final_train_set)

for unitData in test_set: temp_test_set = SOURCE + unitData final_test_set = TESTING + unitData copyfile(temp_test_set, final_test_set)

YES_SOURCE_DIR = "dest_folder/val/yes/" TRAINING_YES_DIR = "dest_folder/train/yes/" TESTING_YES_DIR = "dest_folder/test/yes/" NO_SOURCE_DIR = "dest_folder/val/no/" TRAINING_NO_DIR = "dest_folder/val/no/" TESTING_NO_DIR = "dest_folder/test/no/" split_size = .8 split_data(YES_SOURCE_DIR, TRAINING_YES_DIR, TESTING_YES_DIR, split_size) split_data(NO_SOURCE_DIR, TRAINING_NO_DIR, TESTING_NO_DIR, split_size) [image: location of dataset] < https://user-images.githubusercontent.com/42198801/86368406-c2f45780-bc9a-11ea-8b0d-1dcef380a2ae.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AIAR4NWSLZY6CAPBAEIC2Y3RZSHQ3ANCNFSM4OO5NI2Q

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653047936, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKB6OEN7FBIVSNOYNROFHMDRZSMI7ANCNFSM4OO5NI2Q .

RAVIKIRAN-DHULIPALA commented 4 years ago

The parameters passed to function are the source file ie., yes or no files Training dataset folder ,testing dataset folder ,and the size in which the dataset has to be splitted

On Thu, 2 Jul 2020 at 9:18 PM, clownpreet22 notifications@github.com wrote:

Im using jupyter notebook but i don't understand what will be the code

On Thu, 2 Jul 2020, 8:13 pm Ravikiran Dhulipala, <notifications@github.com

wrote:

U r sending the parameter but which environment u r using If u r using jupyter notebook u can pass the local machine folders

But if u r using the Google colab it cannot access the local machine folders u have to upload it to the cloud.

On Thu, 2 Jul, 2020, 7:32 pm clownpreet22, notifications@github.com wrote:

what would be the perameter of this fun def split_data(SOURCE, TRAINING, TESTING, SPLIT_SIZE): dataset = []

for unitData in os.listdir(SOURCE): data = SOURCE + unitData if(os.path.getsize(data) > 0): dataset.append(unitData) else: print('Skipped ' + unitData) print('Invalid file i.e zero size')

train_set_length = int(len(dataset) * SPLIT_SIZE) test_set_length = int(len(dataset) - train_set_length) shuffled_set = random.sample(dataset, len(dataset)) train_set = dataset[0:train_set_length] test_set = dataset[-test_set_length:]

for unitData in train_set: temp_train_set = SOURCE + unitData final_train_set = TRAINING + unitData copyfile(temp_train_set, final_train_set)

for unitData in test_set: temp_test_set = SOURCE + unitData final_test_set = TESTING + unitData copyfile(temp_test_set, final_test_set)

YES_SOURCE_DIR = "dest_folder/val/yes/" TRAINING_YES_DIR = "dest_folder/train/yes/" TESTING_YES_DIR = "dest_folder/test/yes/" NO_SOURCE_DIR = "dest_folder/val/no/" TRAINING_NO_DIR = "dest_folder/val/no/" TESTING_NO_DIR = "dest_folder/test/no/" split_size = .8 split_data(YES_SOURCE_DIR, TRAINING_YES_DIR, TESTING_YES_DIR, split_size) split_data(NO_SOURCE_DIR, TRAINING_NO_DIR, TESTING_NO_DIR, split_size) [image: location of dataset] <

https://user-images.githubusercontent.com/42198801/86368406-c2f45780-bc9a-11ea-8b0d-1dcef380a2ae.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AIAR4NWSLZY6CAPBAEIC2Y3RZSHQ3ANCNFSM4OO5NI2Q

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub < https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653047936 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AKB6OEN7FBIVSNOYNROFHMDRZSMI7ANCNFSM4OO5NI2Q

.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653084463, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIAR4NVZLY6LVCGB3B3Q5L3RZST4HANCNFSM4OO5NI2Q .

clownpreet22 commented 4 years ago

Thank you so much

On Thu, 2 Jul 2020, 9:21 pm Ravikiran Dhulipala, notifications@github.com wrote:

The parameters passed to function are the source file ie., yes or no files Training dataset folder ,testing dataset folder ,and the size in which the dataset has to be splitted

On Thu, 2 Jul 2020 at 9:18 PM, clownpreet22 notifications@github.com wrote:

Im using jupyter notebook but i don't understand what will be the code

On Thu, 2 Jul 2020, 8:13 pm Ravikiran Dhulipala, < notifications@github.com

wrote:

U r sending the parameter but which environment u r using If u r using jupyter notebook u can pass the local machine folders

But if u r using the Google colab it cannot access the local machine folders u have to upload it to the cloud.

On Thu, 2 Jul, 2020, 7:32 pm clownpreet22, notifications@github.com wrote:

what would be the perameter of this fun def split_data(SOURCE, TRAINING, TESTING, SPLIT_SIZE): dataset = []

for unitData in os.listdir(SOURCE): data = SOURCE + unitData if(os.path.getsize(data) > 0): dataset.append(unitData) else: print('Skipped ' + unitData) print('Invalid file i.e zero size')

train_set_length = int(len(dataset) * SPLIT_SIZE) test_set_length = int(len(dataset) - train_set_length) shuffled_set = random.sample(dataset, len(dataset)) train_set = dataset[0:train_set_length] test_set = dataset[-test_set_length:]

for unitData in train_set: temp_train_set = SOURCE + unitData final_train_set = TRAINING + unitData copyfile(temp_train_set, final_train_set)

for unitData in test_set: temp_test_set = SOURCE + unitData final_test_set = TESTING + unitData copyfile(temp_test_set, final_test_set)

YES_SOURCE_DIR = "dest_folder/val/yes/" TRAINING_YES_DIR = "dest_folder/train/yes/" TESTING_YES_DIR = "dest_folder/test/yes/" NO_SOURCE_DIR = "dest_folder/val/no/" TRAINING_NO_DIR = "dest_folder/val/no/" TESTING_NO_DIR = "dest_folder/test/no/" split_size = .8 split_data(YES_SOURCE_DIR, TRAINING_YES_DIR, TESTING_YES_DIR, split_size) split_data(NO_SOURCE_DIR, TRAINING_NO_DIR, TESTING_NO_DIR, split_size) [image: location of dataset] <

https://user-images.githubusercontent.com/42198801/86368406-c2f45780-bc9a-11ea-8b0d-1dcef380a2ae.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AIAR4NWSLZY6CAPBAEIC2Y3RZSHQ3ANCNFSM4OO5NI2Q

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <

https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653047936

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AKB6OEN7FBIVSNOYNROFHMDRZSMI7ANCNFSM4OO5NI2Q

.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub < https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653084463 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AIAR4NVZLY6LVCGB3B3Q5L3RZST4HANCNFSM4OO5NI2Q

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653086772, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKB6OEJD5PVX6HMCI474RW3RZSUIRANCNFSM4OO5NI2Q .

clownpreet22 commented 4 years ago

Sir while i run history it runs till some epochs and then stops why this happened

On Thu 2 Jul, 2020, 9:49 PM Patel Preet, preetmpatel22@gmail.com wrote:

Thank you so much

On Thu, 2 Jul 2020, 9:21 pm Ravikiran Dhulipala, notifications@github.com wrote:

The parameters passed to function are the source file ie., yes or no files Training dataset folder ,testing dataset folder ,and the size in which the dataset has to be splitted

On Thu, 2 Jul 2020 at 9:18 PM, clownpreet22 notifications@github.com wrote:

Im using jupyter notebook but i don't understand what will be the code

On Thu, 2 Jul 2020, 8:13 pm Ravikiran Dhulipala, < notifications@github.com

wrote:

U r sending the parameter but which environment u r using If u r using jupyter notebook u can pass the local machine folders

But if u r using the Google colab it cannot access the local machine folders u have to upload it to the cloud.

On Thu, 2 Jul, 2020, 7:32 pm clownpreet22, notifications@github.com wrote:

what would be the perameter of this fun def split_data(SOURCE, TRAINING, TESTING, SPLIT_SIZE): dataset = []

for unitData in os.listdir(SOURCE): data = SOURCE + unitData if(os.path.getsize(data) > 0): dataset.append(unitData) else: print('Skipped ' + unitData) print('Invalid file i.e zero size')

train_set_length = int(len(dataset) * SPLIT_SIZE) test_set_length = int(len(dataset) - train_set_length) shuffled_set = random.sample(dataset, len(dataset)) train_set = dataset[0:train_set_length] test_set = dataset[-test_set_length:]

for unitData in train_set: temp_train_set = SOURCE + unitData final_train_set = TRAINING + unitData copyfile(temp_train_set, final_train_set)

for unitData in test_set: temp_test_set = SOURCE + unitData final_test_set = TESTING + unitData copyfile(temp_test_set, final_test_set)

YES_SOURCE_DIR = "dest_folder/val/yes/" TRAINING_YES_DIR = "dest_folder/train/yes/" TESTING_YES_DIR = "dest_folder/test/yes/" NO_SOURCE_DIR = "dest_folder/val/no/" TRAINING_NO_DIR = "dest_folder/val/no/" TESTING_NO_DIR = "dest_folder/test/no/" split_size = .8 split_data(YES_SOURCE_DIR, TRAINING_YES_DIR, TESTING_YES_DIR, split_size) split_data(NO_SOURCE_DIR, TRAINING_NO_DIR, TESTING_NO_DIR, split_size) [image: location of dataset] <

https://user-images.githubusercontent.com/42198801/86368406-c2f45780-bc9a-11ea-8b0d-1dcef380a2ae.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AIAR4NWSLZY6CAPBAEIC2Y3RZSHQ3ANCNFSM4OO5NI2Q

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <

https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653047936

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AKB6OEN7FBIVSNOYNROFHMDRZSMI7ANCNFSM4OO5NI2Q

.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub < https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653084463 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AIAR4NVZLY6LVCGB3B3Q5L3RZST4HANCNFSM4OO5NI2Q

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653086772, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKB6OEJD5PVX6HMCI474RW3RZSUIRANCNFSM4OO5NI2Q .

RAVIKIRAN-DHULIPALA commented 4 years ago

If u have high end local machine u can run all the epochs. I want to mention one thing that u cannot train Machine learning models accurately on local machine Unless u have high end configurations try it in cloud env

On Thu, 2 Jul 2020 at 9:54 PM, clownpreet22 notifications@github.com wrote:

Sir while i run history it runs till some epochs and then stops why this happened

On Thu 2 Jul, 2020, 9:49 PM Patel Preet, preetmpatel22@gmail.com wrote:

Thank you so much

On Thu, 2 Jul 2020, 9:21 pm Ravikiran Dhulipala, < notifications@github.com> wrote:

The parameters passed to function are the source file ie., yes or no files Training dataset folder ,testing dataset folder ,and the size in which the dataset has to be splitted

On Thu, 2 Jul 2020 at 9:18 PM, clownpreet22 notifications@github.com wrote:

Im using jupyter notebook but i don't understand what will be the code

On Thu, 2 Jul 2020, 8:13 pm Ravikiran Dhulipala, < notifications@github.com

wrote:

U r sending the parameter but which environment u r using If u r using jupyter notebook u can pass the local machine folders

But if u r using the Google colab it cannot access the local machine folders u have to upload it to the cloud.

On Thu, 2 Jul, 2020, 7:32 pm clownpreet22, < notifications@github.com> wrote:

what would be the perameter of this fun def split_data(SOURCE, TRAINING, TESTING, SPLIT_SIZE): dataset = []

for unitData in os.listdir(SOURCE): data = SOURCE + unitData if(os.path.getsize(data) > 0): dataset.append(unitData) else: print('Skipped ' + unitData) print('Invalid file i.e zero size')

train_set_length = int(len(dataset) * SPLIT_SIZE) test_set_length = int(len(dataset) - train_set_length) shuffled_set = random.sample(dataset, len(dataset)) train_set = dataset[0:train_set_length] test_set = dataset[-test_set_length:]

for unitData in train_set: temp_train_set = SOURCE + unitData final_train_set = TRAINING + unitData copyfile(temp_train_set, final_train_set)

for unitData in test_set: temp_test_set = SOURCE + unitData final_test_set = TESTING + unitData copyfile(temp_test_set, final_test_set)

YES_SOURCE_DIR = "dest_folder/val/yes/" TRAINING_YES_DIR = "dest_folder/train/yes/" TESTING_YES_DIR = "dest_folder/test/yes/" NO_SOURCE_DIR = "dest_folder/val/no/" TRAINING_NO_DIR = "dest_folder/val/no/" TESTING_NO_DIR = "dest_folder/test/no/" split_size = .8 split_data(YES_SOURCE_DIR, TRAINING_YES_DIR, TESTING_YES_DIR, split_size) split_data(NO_SOURCE_DIR, TRAINING_NO_DIR, TESTING_NO_DIR, split_size) [image: location of dataset] <

https://user-images.githubusercontent.com/42198801/86368406-c2f45780-bc9a-11ea-8b0d-1dcef380a2ae.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AIAR4NWSLZY6CAPBAEIC2Y3RZSHQ3ANCNFSM4OO5NI2Q

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <

https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653047936

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AKB6OEN7FBIVSNOYNROFHMDRZSMI7ANCNFSM4OO5NI2Q

.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub <

https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653084463

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AIAR4NVZLY6LVCGB3B3Q5L3RZST4HANCNFSM4OO5NI2Q

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub < https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653086772 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AKB6OEJD5PVX6HMCI474RW3RZSUIRANCNFSM4OO5NI2Q

.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653104451, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIAR4NWGQKAEAPNUNH24MKDRZSYCXANCNFSM4OO5NI2Q .

clownpreet22 commented 4 years ago

Thank u so much sir Your idea helps me a lot Code completely run on colab platform

Just it shows small error pls help me out from this

On Thu 2 Jul, 2020, 9:57 PM Ravikiran Dhulipala, notifications@github.com wrote:

If u have high end local machine u can run all the epochs. I want to mention one thing that u cannot train Machine learning models accurately on local machine Unless u have high end configurations try it in cloud env

On Thu, 2 Jul 2020 at 9:54 PM, clownpreet22 notifications@github.com wrote:

Sir while i run history it runs till some epochs and then stops why this happened

On Thu 2 Jul, 2020, 9:49 PM Patel Preet, preetmpatel22@gmail.com wrote:

Thank you so much

On Thu, 2 Jul 2020, 9:21 pm Ravikiran Dhulipala, < notifications@github.com> wrote:

The parameters passed to function are the source file ie., yes or no files Training dataset folder ,testing dataset folder ,and the size in which the dataset has to be splitted

On Thu, 2 Jul 2020 at 9:18 PM, clownpreet22 <notifications@github.com

wrote:

Im using jupyter notebook but i don't understand what will be the code

On Thu, 2 Jul 2020, 8:13 pm Ravikiran Dhulipala, < notifications@github.com

wrote:

U r sending the parameter but which environment u r using If u r using jupyter notebook u can pass the local machine folders

But if u r using the Google colab it cannot access the local machine folders u have to upload it to the cloud.

On Thu, 2 Jul, 2020, 7:32 pm clownpreet22, < notifications@github.com> wrote:

what would be the perameter of this fun def split_data(SOURCE, TRAINING, TESTING, SPLIT_SIZE): dataset = []

for unitData in os.listdir(SOURCE): data = SOURCE + unitData if(os.path.getsize(data) > 0): dataset.append(unitData) else: print('Skipped ' + unitData) print('Invalid file i.e zero size')

train_set_length = int(len(dataset) * SPLIT_SIZE) test_set_length = int(len(dataset) - train_set_length) shuffled_set = random.sample(dataset, len(dataset)) train_set = dataset[0:train_set_length] test_set = dataset[-test_set_length:]

for unitData in train_set: temp_train_set = SOURCE + unitData final_train_set = TRAINING + unitData copyfile(temp_train_set, final_train_set)

for unitData in test_set: temp_test_set = SOURCE + unitData final_test_set = TESTING + unitData copyfile(temp_test_set, final_test_set)

YES_SOURCE_DIR = "dest_folder/val/yes/" TRAINING_YES_DIR = "dest_folder/train/yes/" TESTING_YES_DIR = "dest_folder/test/yes/" NO_SOURCE_DIR = "dest_folder/val/no/" TRAINING_NO_DIR = "dest_folder/val/no/" TESTING_NO_DIR = "dest_folder/test/no/" split_size = .8 split_data(YES_SOURCE_DIR, TRAINING_YES_DIR, TESTING_YES_DIR, split_size) split_data(NO_SOURCE_DIR, TRAINING_NO_DIR, TESTING_NO_DIR, split_size) [image: location of dataset] <

https://user-images.githubusercontent.com/42198801/86368406-c2f45780-bc9a-11ea-8b0d-1dcef380a2ae.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3 , or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AIAR4NWSLZY6CAPBAEIC2Y3RZSHQ3ANCNFSM4OO5NI2Q

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <

https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653047936

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AKB6OEN7FBIVSNOYNROFHMDRZSMI7ANCNFSM4OO5NI2Q

.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub <

https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653084463

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AIAR4NVZLY6LVCGB3B3Q5L3RZST4HANCNFSM4OO5NI2Q

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <

https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653086772

,

or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AKB6OEJD5PVX6HMCI474RW3RZSUIRANCNFSM4OO5NI2Q

.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub < https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653104451 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AIAR4NWGQKAEAPNUNH24MKDRZSYCXANCNFSM4OO5NI2Q

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653106264, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKB6OEJQIA2VCWYPMK7BNHLRZSYQRANCNFSM4OO5NI2Q .

RAVIKIRAN-DHULIPALA commented 4 years ago

Can u show me that error so that I can help u

On Fri, 3 Jul, 2020, 12:38 am clownpreet22, notifications@github.com wrote:

Thank u so much sir Your idea helps me a lot Code completely run on colab platform

Just it shows small error pls help me out from this

On Thu 2 Jul, 2020, 9:57 PM Ravikiran Dhulipala, <notifications@github.com

wrote:

If u have high end local machine u can run all the epochs. I want to mention one thing that u cannot train Machine learning models accurately on local machine Unless u have high end configurations try it in cloud env

On Thu, 2 Jul 2020 at 9:54 PM, clownpreet22 notifications@github.com wrote:

Sir while i run history it runs till some epochs and then stops why this happened

On Thu 2 Jul, 2020, 9:49 PM Patel Preet, preetmpatel22@gmail.com wrote:

Thank you so much

On Thu, 2 Jul 2020, 9:21 pm Ravikiran Dhulipala, < notifications@github.com> wrote:

The parameters passed to function are the source file ie., yes or no files Training dataset folder ,testing dataset folder ,and the size in which the dataset has to be splitted

On Thu, 2 Jul 2020 at 9:18 PM, clownpreet22 < notifications@github.com

wrote:

Im using jupyter notebook but i don't understand what will be the code

On Thu, 2 Jul 2020, 8:13 pm Ravikiran Dhulipala, < notifications@github.com

wrote:

U r sending the parameter but which environment u r using If u r using jupyter notebook u can pass the local machine folders

But if u r using the Google colab it cannot access the local machine folders u have to upload it to the cloud.

On Thu, 2 Jul, 2020, 7:32 pm clownpreet22, < notifications@github.com> wrote:

what would be the perameter of this fun def split_data(SOURCE, TRAINING, TESTING, SPLIT_SIZE): dataset = []

for unitData in os.listdir(SOURCE): data = SOURCE + unitData if(os.path.getsize(data) > 0): dataset.append(unitData) else: print('Skipped ' + unitData) print('Invalid file i.e zero size')

train_set_length = int(len(dataset) * SPLIT_SIZE) test_set_length = int(len(dataset) - train_set_length) shuffled_set = random.sample(dataset, len(dataset)) train_set = dataset[0:train_set_length] test_set = dataset[-test_set_length:]

for unitData in train_set: temp_train_set = SOURCE + unitData final_train_set = TRAINING + unitData copyfile(temp_train_set, final_train_set)

for unitData in test_set: temp_test_set = SOURCE + unitData final_test_set = TESTING + unitData copyfile(temp_test_set, final_test_set)

YES_SOURCE_DIR = "dest_folder/val/yes/" TRAINING_YES_DIR = "dest_folder/train/yes/" TESTING_YES_DIR = "dest_folder/test/yes/" NO_SOURCE_DIR = "dest_folder/val/no/" TRAINING_NO_DIR = "dest_folder/val/no/" TESTING_NO_DIR = "dest_folder/test/no/" split_size = .8 split_data(YES_SOURCE_DIR, TRAINING_YES_DIR, TESTING_YES_DIR, split_size) split_data(NO_SOURCE_DIR, TRAINING_NO_DIR, TESTING_NO_DIR, split_size) [image: location of dataset] <

https://user-images.githubusercontent.com/42198801/86368406-c2f45780-bc9a-11ea-8b0d-1dcef380a2ae.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub < https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3 , or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AIAR4NWSLZY6CAPBAEIC2Y3RZSHQ3ANCNFSM4OO5NI2Q

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <

https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653047936

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AKB6OEN7FBIVSNOYNROFHMDRZSMI7ANCNFSM4OO5NI2Q

.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub <

https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653084463

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AIAR4NVZLY6LVCGB3B3Q5L3RZST4HANCNFSM4OO5NI2Q

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <

https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653086772

,

or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AKB6OEJD5PVX6HMCI474RW3RZSUIRANCNFSM4OO5NI2Q

.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub <

https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653104451

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AIAR4NWGQKAEAPNUNH24MKDRZSYCXANCNFSM4OO5NI2Q

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub < https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653106264 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AKB6OEJQIA2VCWYPMK7BNHLRZSYQRANCNFSM4OO5NI2Q

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653175504, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIAR4NWZKTBASPFCSRCKDZDRZTLJ5ANCNFSM4OO5NI2Q .

clownpreet22 commented 4 years ago

Sure Sir, here is the code img and error img attached

On Fri, Jul 3, 2020 at 8:39 AM Ravikiran Dhulipala notifications@github.com wrote:

Can u show me that error so that I can help u

On Fri, 3 Jul, 2020, 12:38 am clownpreet22, notifications@github.com wrote:

Thank u so much sir Your idea helps me a lot Code completely run on colab platform

Just it shows small error pls help me out from this

On Thu 2 Jul, 2020, 9:57 PM Ravikiran Dhulipala, < notifications@github.com

wrote:

If u have high end local machine u can run all the epochs. I want to mention one thing that u cannot train Machine learning models accurately on local machine Unless u have high end configurations try it in cloud env

On Thu, 2 Jul 2020 at 9:54 PM, clownpreet22 notifications@github.com wrote:

Sir while i run history it runs till some epochs and then stops why this happened

On Thu 2 Jul, 2020, 9:49 PM Patel Preet, preetmpatel22@gmail.com wrote:

Thank you so much

On Thu, 2 Jul 2020, 9:21 pm Ravikiran Dhulipala, < notifications@github.com> wrote:

The parameters passed to function are the source file ie., yes or no files Training dataset folder ,testing dataset folder ,and the size in which the dataset has to be splitted

On Thu, 2 Jul 2020 at 9:18 PM, clownpreet22 < notifications@github.com

wrote:

Im using jupyter notebook but i don't understand what will be the code

On Thu, 2 Jul 2020, 8:13 pm Ravikiran Dhulipala, < notifications@github.com

wrote:

U r sending the parameter but which environment u r using If u r using jupyter notebook u can pass the local machine folders

But if u r using the Google colab it cannot access the local machine folders u have to upload it to the cloud.

On Thu, 2 Jul, 2020, 7:32 pm clownpreet22, < notifications@github.com> wrote:

what would be the perameter of this fun def split_data(SOURCE, TRAINING, TESTING, SPLIT_SIZE): dataset = []

for unitData in os.listdir(SOURCE): data = SOURCE + unitData if(os.path.getsize(data) > 0): dataset.append(unitData) else: print('Skipped ' + unitData) print('Invalid file i.e zero size')

train_set_length = int(len(dataset) * SPLIT_SIZE) test_set_length = int(len(dataset) - train_set_length) shuffled_set = random.sample(dataset, len(dataset)) train_set = dataset[0:train_set_length] test_set = dataset[-test_set_length:]

for unitData in train_set: temp_train_set = SOURCE + unitData final_train_set = TRAINING + unitData copyfile(temp_train_set, final_train_set)

for unitData in test_set: temp_test_set = SOURCE + unitData final_test_set = TESTING + unitData copyfile(temp_test_set, final_test_set)

YES_SOURCE_DIR = "dest_folder/val/yes/" TRAINING_YES_DIR = "dest_folder/train/yes/" TESTING_YES_DIR = "dest_folder/test/yes/" NO_SOURCE_DIR = "dest_folder/val/no/" TRAINING_NO_DIR = "dest_folder/val/no/" TESTING_NO_DIR = "dest_folder/test/no/" split_size = .8 split_data(YES_SOURCE_DIR, TRAINING_YES_DIR, TESTING_YES_DIR, split_size) split_data(NO_SOURCE_DIR, TRAINING_NO_DIR, TESTING_NO_DIR, split_size) [image: location of dataset] <

https://user-images.githubusercontent.com/42198801/86368406-c2f45780-bc9a-11ea-8b0d-1dcef380a2ae.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub < https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3 , or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AIAR4NWSLZY6CAPBAEIC2Y3RZSHQ3ANCNFSM4OO5NI2Q

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <

https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653047936

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AKB6OEN7FBIVSNOYNROFHMDRZSMI7ANCNFSM4OO5NI2Q

.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub <

https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653084463

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AIAR4NVZLY6LVCGB3B3Q5L3RZST4HANCNFSM4OO5NI2Q

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <

https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653086772

,

or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AKB6OEJD5PVX6HMCI474RW3RZSUIRANCNFSM4OO5NI2Q

.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub <

https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653104451

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AIAR4NWGQKAEAPNUNH24MKDRZSYCXANCNFSM4OO5NI2Q

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <

https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653106264

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AKB6OEJQIA2VCWYPMK7BNHLRZSYQRANCNFSM4OO5NI2Q

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653175504 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AIAR4NWZKTBASPFCSRCKDZDRZTLJ5ANCNFSM4OO5NI2Q

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653314815, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKB6OEPNBQJ6EFMSF7VA4BDRZVDVBANCNFSM4OO5NI2Q .

RAVIKIRAN-DHULIPALA commented 4 years ago

I'm sorry I couldn't find any images

clownpreet22 commented 4 years ago

let me share a code and error as a text

CODE

labels_dict={0:'without_mask',1:'with_mask'} color_dict={0:(0,0,255),1:(0,255,0)}

size = 4 webcam = cv2.VideoCapture(0) #Use camera 0

We load the xml file

classifier = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')

while True: (rval, im) = webcam.read() im=cv2.flip(im,1,1) #Flip to act as a mirror

# Resize the image to speed up detection
mini = cv2.resize(im, ( im.shape[1] // size, im.shape[0] // size))

# detect MultiScale / faces
faces = classifier.detectMultiScale(mini)

# Draw rectangles around each face
for f in faces:
    (x, y, w, h) = [v * size for v in f] #Scale the shapesize backup
    #Save just the rectangle faces in SubRecFaces
    face_img = im[y:y+h, x:x+w]
    resized=cv2.resize(face_img,(150,150))
    normalized=resized/255.0
    reshaped=np.reshape(normalized,(1,150,150,3))
    reshaped = np.vstack([reshaped])
    result=model.predict(reshaped)
    #print(result)

    label=np.argmax(result,axis=1)[0]

    cv2.rectangle(im,(x,y),(x+w,y+h),color_dict[label],2)
    cv2.rectangle(im,(x,y-40),(x+w,y),color_dict[label],-1)
    cv2.putText(im, labels_dict[label], (x, y-10

),cv2.FONT_HERSHEY_SIMPLEX,0.8,(255,255,255),2)

# Show the image
cv2.imshow('LIVE',   im)
key = cv2.waitKey(10)
# if Esc key is press then break out of the loop
if key == 27: #The Esc key
    break

Stop video

webcam.release()

Close all started windows

cv2.destroyAllWindows()

ERROR


AttributeError Traceback (most recent call last)

in () 13 14 # Resize the image to speed up detection---> 15 mini = cv2.resize(im, ( im.shape[1] // size, im.shape[0] // size)) 16 17 # detect MultiScale / faces AttributeError: 'NoneType' object has no attribute 'shape' On Fri, Jul 3, 2020 at 9:36 AM Ravikiran Dhulipala wrote: > I'm sorry I couldn't find any images > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > , > or unsubscribe > > . >
RAVIKIRAN-DHULIPALA commented 4 years ago

Just make sure that #flip to act as mirror variable is actually getting the values and it is a numpy variable Actually only the numpy variables will only have the shape function to it

Just make sure that

On Fri, 3 Jul, 2020, 9:40 am clownpreet22, notifications@github.com wrote:

let me share a code and error as a text

CODE

labels_dict={0:'without_mask',1:'with_mask'} color_dict={0:(0,0,255),1:(0,255,0)}

size = 4 webcam = cv2.VideoCapture(0) #Use camera 0

We load the xml file

classifier = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')

while True: (rval, im) = webcam.read() im=cv2.flip(im,1,1) #Flip to act as a mirror

Resize the image to speed up detection

mini = cv2.resize(im, ( im.shape[1] // size, im.shape[0] // size))

detect MultiScale / faces

faces = classifier.detectMultiScale(mini)

Draw rectangles around each face

for f in faces: (x, y, w, h) = [v * size for v in f] #Scale the shapesize backup

Save just the rectangle faces in SubRecFaces

face_img = im[y:y+h, x:x+w] resized=cv2.resize(face_img,(150,150)) normalized=resized/255.0 reshaped=np.reshape(normalized,(1,150,150,3)) reshaped = np.vstack([reshaped]) result=model.predict(reshaped)

print(result)

label=np.argmax(result,axis=1)[0]

cv2.rectangle(im,(x,y),(x+w,y+h),color_dict[label],2) cv2.rectangle(im,(x,y-40),(x+w,y),color_dict[label],-1) cv2.putText(im, labels_dict[label], (x, y-10 ),cv2.FONT_HERSHEY_SIMPLEX,0.8,(255,255,255),2)

Show the image

cv2.imshow('LIVE', im) key = cv2.waitKey(10)

if Esc key is press then break out of the loop

if key == 27: #The Esc key break

Stop video

webcam.release()

Close all started windows

cv2.destroyAllWindows()

ERROR


AttributeError Traceback (most recent call last)

in () 13 14 # Resize the image to speed up detection---> 15 mini = cv2.resize(im, ( im.shape[1] // size, im.shape[0] // size)) 16 17 # detect MultiScale / faces AttributeError: 'NoneType' object has no attribute 'shape' On Fri, Jul 3, 2020 at 9:36 AM Ravikiran Dhulipala < notifications@github.com> wrote: > I'm sorry I couldn't find any images > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > < https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653332874 >, > or unsubscribe > < https://github.com/notifications/unsubscribe-auth/AKB6OENLPDB63ZKKRCADEZTRZVKLZANCNFSM4OO5NI2Q > > . > — You are receiving this because you commented. Reply to this email directly, view it on GitHub , or unsubscribe .
clownpreet22 commented 4 years ago

where i have to change pls tell what would i put to run code successfully actually i am not aware about this line of code too mch

pls tell me the like where i need to chnage and what change that is?

On Fri, Jul 3, 2020 at 9:46 AM Ravikiran Dhulipala notifications@github.com wrote:

Just make sure that #flip to act as mirror variable is actually getting the values and it is a numpy variable Actually only the numpy variables will only have the shape function to it

Just make sure that

On Fri, 3 Jul, 2020, 9:40 am clownpreet22, notifications@github.com wrote:

let me share a code and error as a text

CODE

labels_dict={0:'without_mask',1:'with_mask'} color_dict={0:(0,0,255),1:(0,255,0)}

size = 4 webcam = cv2.VideoCapture(0) #Use camera 0

We load the xml file

classifier = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')

while True: (rval, im) = webcam.read() im=cv2.flip(im,1,1) #Flip to act as a mirror

Resize the image to speed up detection

mini = cv2.resize(im, ( im.shape[1] // size, im.shape[0] // size))

detect MultiScale / faces

faces = classifier.detectMultiScale(mini)

Draw rectangles around each face

for f in faces: (x, y, w, h) = [v * size for v in f] #Scale the shapesize backup

Save just the rectangle faces in SubRecFaces

face_img = im[y:y+h, x:x+w] resized=cv2.resize(face_img,(150,150)) normalized=resized/255.0 reshaped=np.reshape(normalized,(1,150,150,3)) reshaped = np.vstack([reshaped]) result=model.predict(reshaped)

print(result)

label=np.argmax(result,axis=1)[0]

cv2.rectangle(im,(x,y),(x+w,y+h),color_dict[label],2) cv2.rectangle(im,(x,y-40),(x+w,y),color_dict[label],-1) cv2.putText(im, labels_dict[label], (x, y-10 ),cv2.FONT_HERSHEY_SIMPLEX,0.8,(255,255,255),2)

Show the image

cv2.imshow('LIVE', im) key = cv2.waitKey(10)

if Esc key is press then break out of the loop

if key == 27: #The Esc key break

Stop video

webcam.release()

Close all started windows

cv2.destroyAllWindows()

ERROR


AttributeError Traceback (most recent call last)

in () 13 14 # Resize the image to speed up detection---> 15 mini = cv2.resize(im, ( im.shape[1] // size, im.shape[0] // size)) 16 17 # detect MultiScale / faces AttributeError: 'NoneType' object has no attribute 'shape' On Fri, Jul 3, 2020 at 9:36 AM Ravikiran Dhulipala < notifications@github.com> wrote: > I'm sorry I couldn't find any images > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > < https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653332874 >, > or unsubscribe > < https://github.com/notifications/unsubscribe-auth/AKB6OENLPDB63ZKKRCADEZTRZVKLZANCNFSM4OO5NI2Q > > . > — You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653334015 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AIAR4NX4OSH374CVDJHEZADRZVK2TANCNFSM4OO5NI2Q .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mk-gurucharan/Face-Mask-Detection/issues/3#issuecomment-653335837, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKB6OELWFA47ZEAURM7C6KTRZVLRDANCNFSM4OO5NI2Q .

vinayakpandi commented 3 years ago

@clownpreet22 - Were you able to resolve the shape issue...if so could you please guide me?