jhj0517 commited on
Commit
a2c5114
·
1 Parent(s): 17abb6a

Add docstring

Browse files
modules/model_downloader.py CHANGED
@@ -26,8 +26,8 @@ def load_file_from_url(
26
  filename: Optional[str] = None,
27
  ) -> str:
28
  from urllib.parse import urlparse
29
- """Download a file from `url` into `model_dir`, using the file present if possible.
30
-
31
  Returns the path to the downloaded file.
32
  """
33
  os.makedirs(model_dir, exist_ok=True)
 
26
  filename: Optional[str] = None,
27
  ) -> str:
28
  from urllib.parse import urlparse
29
+ """
30
+ Download a file from `url` into `model_dir`, using the file present if possible.
31
  Returns the path to the downloaded file.
32
  """
33
  os.makedirs(model_dir, exist_ok=True)
modules/utils.py CHANGED
@@ -7,17 +7,20 @@ from modules.constants import IMAGE_FILE_EXT
7
 
8
 
9
  def open_folder(folder_path: str):
 
10
  if os.path.exists(folder_path):
11
  os.system(f'start "" "{folder_path}"')
12
  else:
13
  print(f"The folder '{folder_path}' does not exist.")
14
 
15
 
16
- def is_image_file(filename):
 
17
  return os.path.splitext(filename.lower())[1] in IMAGE_FILE_EXT
18
 
19
 
20
  def get_image_files(image_dir: str):
 
21
  image_files = []
22
  for filename in os.listdir(image_dir):
23
  if is_image_file(filename):
@@ -28,6 +31,8 @@ def get_image_files(image_dir: str):
28
  def save_image(image: Union[np.ndarray, str],
29
  output_path: Optional[str] = None,
30
  output_dir: Optional[str] = None):
 
 
31
 
32
  if output_dir is None and output_path is None:
33
  raise ValueError("Either output_path or output_dir should be provided")
 
7
 
8
 
9
  def open_folder(folder_path: str):
10
+ """Open the folder in the file explorer"""
11
  if os.path.exists(folder_path):
12
  os.system(f'start "" "{folder_path}"')
13
  else:
14
  print(f"The folder '{folder_path}' does not exist.")
15
 
16
 
17
+ def is_image_file(filename: str):
18
+ """Check if the file is an image file"""
19
  return os.path.splitext(filename.lower())[1] in IMAGE_FILE_EXT
20
 
21
 
22
  def get_image_files(image_dir: str):
23
+ """Get all image files in the directory"""
24
  image_files = []
25
  for filename in os.listdir(image_dir):
26
  if is_image_file(filename):
 
31
  def save_image(image: Union[np.ndarray, str],
32
  output_path: Optional[str] = None,
33
  output_dir: Optional[str] = None):
34
+ """Save the image to the output path or output directory. If output directory is provided,
35
+ the image will be saved as a numbered image file in the directory."""
36
 
37
  if output_dir is None and output_path is None:
38
  raise ValueError("Either output_path or output_dir should be provided")
modules/video_utils.py CHANGED
@@ -229,6 +229,7 @@ def clean_temp_dir(temp_dir: Optional[str] = None):
229
 
230
 
231
  def clean_files_with_extension(dir_path: str, extensions: List):
 
232
  for filename in os.listdir(dir_path):
233
  if filename.lower().endswith(tuple(extensions)):
234
  file_path = os.path.join(dir_path, filename)
 
229
 
230
 
231
  def clean_files_with_extension(dir_path: str, extensions: List):
232
+ """Remove files with the given extensions from the directory."""
233
  for filename in os.listdir(dir_path):
234
  if filename.lower().endswith(tuple(extensions)):
235
  file_path = os.path.join(dir_path, filename)