mingyuan commited on
Commit
efe089c
1 Parent(s): a631219

change_loading_options

Browse files
Files changed (2) hide show
  1. app.py +17 -16
  2. pre-requirements.txt +2 -1
app.py CHANGED
@@ -36,27 +36,28 @@ from mogen.datasets.utils import recover_from_ric
36
  from mogen.datasets.pipelines import RetargetSkeleton
37
 
38
  import requests
 
39
 
40
  def load_large_files(relative_path):
41
  # URL to file in the Hugging Face Hub
42
  url = "https://huggingface.co/mingyuan/data_hf/blob/main/" + relative_path
43
  # Temporary download in Space
44
- file_path = "/tmp/" + relative_path.split('/')[-1]
45
-
46
- response = requests.get(url, stream=True)
47
- response.raise_for_status()
48
- total_size = int(response.headers.get("content-length", 0))
49
- with open(file_path, "wb") as file, tqdm(
50
- desc="Downloading",
51
- total=total_size,
52
- unit="B",
53
- unit_scale=True,
54
- unit_divisor=1024,
55
- ) as bar:
56
- for chunk in response.iter_content(chunk_size=8192):
57
- file.write(chunk)
58
- bar.update(len(chunk))
59
- print(f"File downloaded successfully and saved as: {file_path}")
60
  return file_path
61
 
62
  def motion_temporal_filter(motion, sigma=1):
 
36
  from mogen.datasets.pipelines import RetargetSkeleton
37
 
38
  import requests
39
+ from huggingface_hub import hf_hub_download
40
 
41
  def load_large_files(relative_path):
42
  # URL to file in the Hugging Face Hub
43
  url = "https://huggingface.co/mingyuan/data_hf/blob/main/" + relative_path
44
  # Temporary download in Space
45
+ # file_path = "/tmp/" + relative_path.split('/')[-1]
46
+ # response = requests.get(url, stream=True)
47
+ # response.raise_for_status()
48
+ # total_size = int(response.headers.get("content-length", 0))
49
+ # with open(file_path, "wb") as file, tqdm(
50
+ # desc="Downloading",
51
+ # total=total_size,
52
+ # unit="B",
53
+ # unit_scale=True,
54
+ # unit_divisor=1024,
55
+ # ) as bar:
56
+ # for chunk in response.iter_content(chunk_size=8192):
57
+ # file.write(chunk)
58
+ # bar.update(len(chunk))
59
+ # print(f"File downloaded successfully and saved as: {file_path}")
60
+ file_path = hf_hub_download(repo_id="mingyuan/data_hf", filename=relative_path)
61
  return file_path
62
 
63
  def motion_temporal_filter(motion, sigma=1):
pre-requirements.txt CHANGED
@@ -22,4 +22,5 @@ ipython
22
  librosa
23
  moviepy==1.0.3
24
  mmcv==1.7.1
25
- gradio==4.44.1
 
 
22
  librosa
23
  moviepy==1.0.3
24
  mmcv==1.7.1
25
+ gradio==4.44.1
26
+ huggingface_hub