-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow.py
32 lines (27 loc) · 1013 Bytes
/
show.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
import random
# Reference: https://thispointer.com/python-how-to-get-list-of-files-in-directory-and-sub-directories/
# For the given path, get the List of all files in the directory tree
def getListOfFiles(dirName):
# create a list of file and sub directories
# names in the given directory
listOfFile = os.listdir(dirName)
allFiles = list()
# Iterate over all the entries
for entry in listOfFile:
# Create full path
fullPath = os.path.join(dirName, entry)
# If entry is a directory then get the list of files in this directory
if os.path.isdir(fullPath):
allFiles = allFiles + getListOfFiles(fullPath)
else:
allFiles.append(fullPath)
return allFiles
all_samples = getListOfFiles("./data/")
samples = []
for i in all_samples:
if i[len(i)-4:] == ".png":
samples.append(i)
samples_show = random.sample(samples, 100)
for i in samples_show:
print("<img src=\"", i, "\" width=\"100\">", sep="")