VfiTest / check_images.py
SuyeonJ's picture
Upload folder using huggingface_hub
8d015d4 verified
raw
history blame
1.36 kB
import os
import cv2
def process_directory(directory, output_file):
for root, dirs, files in os.walk(directory):
if not dirs:
# ๋” ์ด์ƒ ํ•˜์œ„ ๋””๋ ‰ํ† ๋ฆฌ๊ฐ€ ์—†๋Š” ๊ฒฝ์šฐ
print("Directory:", root)
# ์ด๋ฏธ์ง€ ํŒŒ์ผ ๊ฒฝ๋กœ ๊ฒ€์‚ฌ
image_found = False
for filename in files:
if filename in ["im1.png","im1.jpg"]:
image_found = True
image_path = os.path.join(root, filename)
# ์ด๋ฏธ์ง€ ์ฝ๊ธฐ
image = cv2.imread(image_path)[:, :, ::-1]
if image is not None:
print("Image:", image_path)
# ์ด๋ฏธ์ง€๋ฅผ ์ฐพ์ง€ ๋ชปํ•œ ๊ฒฝ์šฐ ๊ฒฝ๋กœ๋ฅผ ํŒŒ์ผ์— ์“ฐ๊ธฐ
if not image_found:
with open(output_file, "a") as f:
f.write(root + "\n")
if __name__ == "__main__":
# ๋””๋ ‰ํ† ๋ฆฌ ๊ฒฝ๋กœ ์ง€์ •
start_directory = "../../ins4/Triplet_250p_new/sequences"
# ๊ฒฐ๊ณผ๋ฅผ ์ €์žฅํ•  ํ…์ŠคํŠธ ํŒŒ์ผ ๊ฒฝ๋กœ ์ง€์ •
output_file = "missing_images.txt"
# ํ…์ŠคํŠธ ํŒŒ์ผ ์ดˆ๊ธฐํ™”
open(output_file, "w").close()
# ์‹œ์ž‘ ๋””๋ ‰ํ† ๋ฆฌ์—์„œ ์ˆœํšŒ ์‹œ์ž‘
process_directory(start_directory, output_file)