Upload root file fix_names.py
Browse files- fix_names.py +46 -0
fix_names.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import shutil
|
| 3 |
+
|
| 4 |
+
def replace_folders(base_path):
|
| 5 |
+
# ์ญ์ ํ ํด๋ ๊ฒฝ๋ก
|
| 6 |
+
faces_dir = os.path.join(base_path, "faces")
|
| 7 |
+
images_dir = os.path.join(base_path, "images")
|
| 8 |
+
cropped_faces_dir = os.path.join(base_path, "cropped_faces")
|
| 9 |
+
cropped_images_dir = os.path.join(base_path, "cropped_images")
|
| 10 |
+
|
| 11 |
+
# ๊ธฐ์กด faces, images ํด๋ ์ ๊ฑฐ
|
| 12 |
+
if os.path.exists(faces_dir):
|
| 13 |
+
shutil.rmtree(faces_dir)
|
| 14 |
+
print(f"์ญ์ ์๋ฃ: {faces_dir}")
|
| 15 |
+
if os.path.exists(images_dir):
|
| 16 |
+
shutil.rmtree(images_dir)
|
| 17 |
+
print(f"์ญ์ ์๋ฃ: {images_dir}")
|
| 18 |
+
|
| 19 |
+
# cropped_faces โ faces
|
| 20 |
+
if os.path.exists(cropped_faces_dir):
|
| 21 |
+
os.rename(cropped_faces_dir, faces_dir)
|
| 22 |
+
print(f"์ด๋ฆ ๋ณ๊ฒฝ: {cropped_faces_dir} โ {faces_dir}")
|
| 23 |
+
else:
|
| 24 |
+
print(f"๊ฒฝ๊ณ : {cropped_faces_dir} ์์")
|
| 25 |
+
|
| 26 |
+
# cropped_images โ images
|
| 27 |
+
if os.path.exists(cropped_images_dir):
|
| 28 |
+
os.rename(cropped_images_dir, images_dir)
|
| 29 |
+
print(f"์ด๋ฆ ๋ณ๊ฒฝ: {cropped_images_dir} โ {images_dir}")
|
| 30 |
+
else:
|
| 31 |
+
print(f"๊ฒฝ๊ณ : {cropped_images_dir} ์์")
|
| 32 |
+
|
| 33 |
+
def main():
|
| 34 |
+
txt_path = "/root/aist_hdf5/full_list.txt"
|
| 35 |
+
with open(txt_path, "r") as f:
|
| 36 |
+
folders = [line.strip() for line in f.readlines() if line.strip()]
|
| 37 |
+
|
| 38 |
+
for folder in folders:
|
| 39 |
+
base_path = os.path.join("/root/aist_hdf5/rec", folder)
|
| 40 |
+
if not os.path.exists(base_path):
|
| 41 |
+
print(f"ํด๋ ์์: {base_path}")
|
| 42 |
+
continue
|
| 43 |
+
replace_folders(base_path)
|
| 44 |
+
|
| 45 |
+
if __name__ == "__main__":
|
| 46 |
+
main()
|