Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
covid19classification/2daysdata.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
38 lines (22 sloc)
1009 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import shutil | |
data_path = "Negative" | |
final_output = "2daynegative" | |
fnames = os.listdir(final_output) | |
categories = os.listdir(data_path) | |
#going inside each folder and subfolder manually | |
for each in categories: #positive and negative folder | |
folder_path = os.path.join(data_path, each) | |
img_names = os.listdir(folder_path) | |
for each2 in img_names: #run through each directory | |
folder2_path = os.path.join(folder_path, each2) | |
folder2dir = os.listdir(folder2_path) | |
for each3 in folder2dir: | |
folder3_path = os.path.join(folder2_path, each3) | |
imgdir = os.listdir(folder3_path) | |
for img in imgdir: #when we get to an image, retrieve only the first two images | |
img_path = os.path.join(folder3_path,img) | |
print(img_path) | |
shutil.copy(img_path, final_output) | |
break | |
break |