# -*- coding: utf-8 -*-
import os
import numpy as np
import cv2
list_path = r"F:\project\cls\yanshen\20201209/"
g = os.walk(list_path)
test_dataset = ['%s/%s' % (i[0], j) for i in g for j in i[-1]]
for index,filename in enumerate(test_dataset):
name = f'/{index:04d}.jpg'
dir_name=os.path.dirname(filename)
os.rename(filename,dir_name+name)
Filter images:
g = os.walk(list_path)
img_files = ['%s\\%s' % (i[0], j) for i in g if i[0].endswith('JPEGImages') for j in i[-1] if
j.endswith('jpg')]
Read More:
- Methods of modifying index and columns names by dataframe in pandas
- Python — using Matplotlib to draw histogram
- How to import Python from relative path
- Python — magic identify file types
- Webpack 4 : ERROR in Entry module not found: Error: Can’t resolve ‘./src’
- Java 8 Stream – Read a file line by line
- Python data cleaning — delete failed images__ Simple version
- Dataframe groupby custom aggregate function
- Tensorflow error record: depreciation warning: elementwise
- Golang gets the list of files under the folder
- Basic use of filter
- Java – read all the files and folders in a certain directory and three methods to get the file name from the file path
- List indexes must be integers or slices, not tuple solution
- Linux shell gets the file name under the folder
- Batch modification of file names on MAC Linux rename command line
- Solve the red letter prompt “sub process / usr / bin / dpkg returned an error code (2) in Cydia
- Vtk8.0 compilation process record under vs2017 and qt5.12.1
- The use of C + + template function and lambda expression
- Python common error: if using all scalar values, you must pass an index (four solutions)