MCPcopy
hub / github.com/open-mmlab/mmtracking / initialize

Method initialize

tools/torchserve/mmtrack_handler.py:18–33  ·  view source on GitHub ↗
(self, context)

Source from the content-addressed store, hash-verified

16class MMtrackHandler(BaseHandler):
17
18 def initialize(self, context):
19 properties = context.system_properties
20 self.map_location = 'cuda' if torch.cuda.is_available() else 'cpu'
21 self.device = torch.device(self.map_location + ':' +
22 str(properties.get('gpu_id')) if torch.cuda.
23 is_available() else self.map_location)
24 self.manifest = context.manifest
25
26 model_dir = properties.get('model_dir')
27 serialized_file = self.manifest['model']['serializedFile']
28 checkpoint = os.path.join(model_dir, serialized_file)
29 self.config_file = os.path.join(model_dir, 'config.py')
30
31 self.model = init_model(self.config_file, checkpoint, self.device)
32 self.score_thr = 0.5
33 self.initialized = True
34
35 def preprocess(self, data):
36 videos = []

Callers

nothing calls this directly

Calls 2

init_modelFunction · 0.90
getMethod · 0.80

Tested by

no test coverage detected