Update app.py
Browse files
app.py
CHANGED
@@ -5,6 +5,15 @@ import shutil
|
|
5 |
import gradio as gr
|
6 |
import time
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
def process_and_zip_folders(huggingface_dataset_url, output_dir):
|
9 |
# URLγγγͺγγΈγγͺIDγζ½εΊ
|
10 |
if huggingface_dataset_url.startswith("https://huggingface.co/"):
|
@@ -19,6 +28,9 @@ def process_and_zip_folders(huggingface_dataset_url, output_dir):
|
|
19 |
dataset_path = None
|
20 |
for attempt in range(retry_attempts):
|
21 |
try:
|
|
|
|
|
|
|
22 |
dataset_path = snapshot_download(repo_id, repo_type="dataset", force_download=True)
|
23 |
break # ζεγγε ΄εγ―γ«γΌγγη΅δΊ
|
24 |
except OSError as e:
|
@@ -63,6 +75,9 @@ def process_and_zip_folders(huggingface_dataset_url, output_dir):
|
|
63 |
|
64 |
def gradio_interface():
|
65 |
def start_process(huggingface_url, output_directory):
|
|
|
|
|
|
|
66 |
zip_files = process_and_zip_folders(huggingface_url, output_directory)
|
67 |
return zip_files
|
68 |
|
|
|
5 |
import gradio as gr
|
6 |
import time
|
7 |
|
8 |
+
def clear_cache():
|
9 |
+
"""Hugging Faceγγ£γγ·γ₯γει€γγι’ζ°γ"""
|
10 |
+
cache_dir = os.path.expanduser("~/.cache/huggingface")
|
11 |
+
if os.path.exists(cache_dir):
|
12 |
+
print(f"Clearing cache at: {cache_dir}")
|
13 |
+
shutil.rmtree(cache_dir)
|
14 |
+
else:
|
15 |
+
print("No cache found to clear.")
|
16 |
+
|
17 |
def process_and_zip_folders(huggingface_dataset_url, output_dir):
|
18 |
# URLγγγͺγγΈγγͺIDγζ½εΊ
|
19 |
if huggingface_dataset_url.startswith("https://huggingface.co/"):
|
|
|
28 |
dataset_path = None
|
29 |
for attempt in range(retry_attempts):
|
30 |
try:
|
31 |
+
if attempt > 0:
|
32 |
+
print(f"Retrying... (Attempt {attempt + 1})")
|
33 |
+
clear_cache() # γγ£γγ·γ₯ει€
|
34 |
dataset_path = snapshot_download(repo_id, repo_type="dataset", force_download=True)
|
35 |
break # ζεγγε ΄εγ―γ«γΌγγη΅δΊ
|
36 |
except OSError as e:
|
|
|
75 |
|
76 |
def gradio_interface():
|
77 |
def start_process(huggingface_url, output_directory):
|
78 |
+
# εΊεγγ£γ¬γ―γγͺγεε¨γγͺγε ΄εγ―δ½ζ
|
79 |
+
if not os.path.exists(output_directory):
|
80 |
+
os.makedirs(output_directory, exist_ok=True)
|
81 |
zip_files = process_and_zip_folders(huggingface_url, output_directory)
|
82 |
return zip_files
|
83 |
|