tqdm 사용법
vscode 창을 열고, tqdm 임포트 수행
실행시키려는 코드의 for문이나 enumerate에 감싸주는 것으로 tqdm을 사용하면 됨.
예를 들어 내 코드는 아래와 같음.
for videoname in trainvideo:
train_video_path = os.path.joint(train_folder_path, videoname)
train_image_list = sorted(os.listdir(train_video_path))
이를 아래와 같이, in 뒤의 train_video를 감싸주듯이 수행하면 됨.
for videoname in tqdm(train_video,desc="processing video", mininterval=0.01):
time.sleep(0.1)
# 파일 경로
train_video_path = os.path.join(train_folder_path, videoname)
train_image_list = sorted(os.listdir(train_video_path))
#print(train_image_list)
그럼 아래와 같이 수행 상황이 나옴.
tqdm 속에 사용할 수 있는 변수 값은 다음과 같다.
desc => 진행상황의 이름을 지정하는 변수
miniinterval => 업데이트 주기
Here's the information you provided, translated into English:
Using tqdm
Open the VSCode window and import tqdm. You can employ tqdm by wrapping it around a for loop or enumerate within your code.
For instance, your code looks like this:
pythonCopy code
for videoname in trainvideo: train_video_path = os.path.join(train_folder_path, videoname) train_image_list = sorted(os.listdir(train_video_path))
To use tqdm, wrap it around trainvideo as follows:
for videoname in tqdm(trainvideo, desc='Processing Status', mininterval=0.5): train_video_path = os.path.join(train_folder_path, videoname) train_image_list = sorted(os.listdir(train_video_path)) # ... Rest of your code
By doing this, you'll see the progress status displayed. Within tqdm, you can use the following variables:
- desc => Specifies the name of the progress status.
- mininterval => Determines the update interval.
댓글