Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

stage_01_get_data.py 1.4 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  1. import argparse
  2. import os
  3. from tqdm import tqdm
  4. import logging
  5. from src.utils.common import read_yaml_file, create_directories, copy_files
  6. logging.basicConfig(
  7. filename=os.path.join("logs", "running_logs.log"),
  8. level=logging.INFO,
  9. format="[%(asctime)s: %(levelname)s: %(module)s]: %(message)s",
  10. filemode="a",
  11. )
  12. def get_data(config_path: str) -> None:
  13. """get the image data from source to the present working directory
  14. Args:
  15. config_path (str): path to config file
  16. """
  17. config = read_yaml_file(config_path)
  18. source_data_dirs = config["source_data_dirs"]
  19. local_data_dirs = config["local_data_dirs"]
  20. N = len(source_data_dirs)
  21. for source_data_dir, local_data_dir in tqdm(
  22. zip(source_data_dirs, local_data_dirs),
  23. total=N,
  24. colour="red",
  25. desc="copying directory:",
  26. ):
  27. create_directories([local_data_dir])
  28. copy_files(source_data_dir, local_data_dir)
  29. if __name__ == "__main__":
  30. args = argparse.ArgumentParser()
  31. args.add_argument("--config", "-c", default="configs/config.yaml")
  32. parsed_args = args.parse_args()
  33. try:
  34. logging.info("\n********************")
  35. logging.info(">>>>> stage one started <<<<<")
  36. get_data(config_path=parsed_args.config)
  37. logging.info(
  38. ">>>>> stage one completed! all the data are saved in local <<<<<\n"
  39. )
  40. except Exception as e:
  41. logging.exception(e)
  42. raise e
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...