Update app.py
Browse files
app.py
CHANGED
@@ -23,19 +23,19 @@ def delete_jpg_files():
|
|
23 |
|
24 |
# Lọc file JPG
|
25 |
jpg_files = [file for file in files if file.endswith('.jpg') and '/' not in file]
|
26 |
-
print("Chờ 1 giờ trước khi tiếp tục...")
|
27 |
-
time.sleep(3600) # Chờ 1 giờ
|
28 |
-
api.delete_file(repo_id=REPO_ID, path_in_repo=jpg_files, repo_type="dataset")
|
29 |
-
print(f"Đã xóa file: {jpg_files}") # In ra console
|
30 |
# Xóa file theo từng lô
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
return "Xóa thành công."
|
40 |
|
41 |
# --- Hàm tải file từ Hugging Face ---
|
|
|
23 |
|
24 |
# Lọc file JPG
|
25 |
jpg_files = [file for file in files if file.endswith('.jpg') and '/' not in file]
|
26 |
+
#print("Chờ 1 giờ trước khi tiếp tục...")
|
27 |
+
#time.sleep(3600) # Chờ 1 giờ
|
28 |
+
#api.delete_file(repo_id=REPO_ID, path_in_repo=jpg_files, repo_type="dataset")
|
29 |
+
#print(f"Đã xóa file: {jpg_files}") # In ra console
|
30 |
# Xóa file theo từng lô
|
31 |
+
for i in range(0, len(jpg_files), 99):
|
32 |
+
batch = jpg_files[i:i + 99] # Lấy 99 file một lần
|
33 |
+
for file in batch:
|
34 |
+
api.delete_file(repo_id=REPO_ID, path_in_repo=file, repo_type="dataset")
|
35 |
+
print(f"Đã xóa file: {file}") # In ra console
|
36 |
+
if i + 99 < len(jpg_files): # Nếu còn file để xóa
|
37 |
+
print("Chờ 1 giờ trước khi tiếp tục...")
|
38 |
+
time.sleep(3600) # Chờ 1 giờ
|
39 |
return "Xóa thành công."
|
40 |
|
41 |
# --- Hàm tải file từ Hugging Face ---
|