jhj0517 commited on
Commit
2c19a19
1 Parent(s): a3f3782

Add device log

Browse files
Files changed (2) hide show
  1. app.py +5 -0
  2. modules/logger_util.py +6 -0
app.py CHANGED
@@ -5,6 +5,7 @@ from typing import List, Dict, Optional, Union
5
  import os
6
  import yaml
7
 
 
8
  from modules.html_constants import (HEADER, DEFAULT_THEME, CSS)
9
  from modules.sam_inference import SamInference
10
  from modules.model_downloader import DEFAULT_MODEL_TYPE
@@ -15,6 +16,9 @@ from modules.constants import (AUTOMATIC_MODE, BOX_PROMPT_MODE, PIXELIZE_FILTER,
15
  from modules.video_utils import get_frames_from_dir
16
 
17
 
 
 
 
18
  class App:
19
  def __init__(self,
20
  args: argparse.Namespace):
@@ -27,6 +31,7 @@ class App:
27
  model_dir=self.args.model_dir,
28
  output_dir=self.args.output_dir
29
  )
 
30
  self.image_modes = [AUTOMATIC_MODE, BOX_PROMPT_MODE]
31
  self.default_mode = BOX_PROMPT_MODE
32
  self.filter_modes = [PIXELIZE_FILTER, COLOR_FILTER]
 
5
  import os
6
  import yaml
7
 
8
+ from modules.logger_util import get_logger
9
  from modules.html_constants import (HEADER, DEFAULT_THEME, CSS)
10
  from modules.sam_inference import SamInference
11
  from modules.model_downloader import DEFAULT_MODEL_TYPE
 
16
  from modules.video_utils import get_frames_from_dir
17
 
18
 
19
+ logger = get_logger()
20
+
21
+
22
  class App:
23
  def __init__(self,
24
  args: argparse.Namespace):
 
31
  model_dir=self.args.model_dir,
32
  output_dir=self.args.output_dir
33
  )
34
+ logger.info(f'device "{self.sam_inf.device}" is detected')
35
  self.image_modes = [AUTOMATIC_MODE, BOX_PROMPT_MODE]
36
  self.default_mode = BOX_PROMPT_MODE
37
  self.filter_modes = [PIXELIZE_FILTER, COLOR_FILTER]
modules/logger_util.py CHANGED
@@ -8,5 +8,11 @@ def get_logger(name: Optional[str] = None, level: str = "INFO") -> logging.Logge
8
  logger = logging.getLogger(name)
9
  logger.setLevel(level.upper())
10
 
 
 
 
 
 
 
11
  return logger
12
 
 
8
  logger = logging.getLogger(name)
9
  logger.setLevel(level.upper())
10
 
11
+ if not logger.handlers:
12
+ handler = logging.StreamHandler()
13
+ handler.setLevel(level.upper())
14
+
15
+ logger.addHandler(handler)
16
+
17
  return logger
18