|
import os |
|
|
|
driver_path = "driver" |
|
folder_path = "Images" |
|
driverPath = os.path.join(os.getcwd(), driver_path) |
|
imagePath = os.path.join(os.getcwd(), folder_path) |
|
|
|
try: |
|
if len(os.listdir(driverPath)) > 1: |
|
raise Exception("Put 1 driver only") |
|
elif os.listdir(driverPath)[0] != "driver.exe": |
|
os.rename(driverPath+"/"+"driver.exe") |
|
except: |
|
pass |
|
finally: |
|
executable_path = os.path.join(driverPath, 'driver.exe') |
|
|
|
|
|
def imgList(mode=0): |
|
if mode==0: |
|
return [image.split(" ")[-1].split(".")[0] for image in os.listdir(imagePath) if image.split(".")[-1] in ["jpg","png","jpeg"]] |
|
if mode==1: |
|
return [image.split("_")[0] for image in os.listdir(imagePath) if image.split(".")[-1] in ["jpg","png","jpeg"]] |
|
if mode==2: |
|
return os.listdir(imagePath) |