Adding a progress bar that is more accurate and informative than the gradio one.
from tqdm import tqdm # Import tqdm
# Process each frame with tqdm
total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
for _ in tqdm(range(total_frames), desc="Processing Frames", unit="frames"):
ret, frame = cap.read()
if not ret:
break
with torch.no_grad():
outputs = predictor(frame)['instances']
results = DensePoseResultExtractor()(outputs)
cmap = cv2.COLORMAP_VIRIDIS
arr = cv2.applyColorMap(np.zeros((height, width), dtype=np.uint8), cmap)
out_frame = Visualizer(alpha=1, cmap=cmap).visualize(arr, results)
out.write(out_frame)