MCPcopy Create free account
hub / github.com/PowerHouseMan/ComfyUI-AdvancedLivePortrait / get_device

Function get_device

nodes.py:30–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28
29cur_device = None
30def get_device():
31 global cur_device
32 if cur_device == None:
33 if torch.cuda.is_available():
34 cur_device = torch.device('cuda')
35 print("Uses CUDA device.")
36 elif torch.backends.mps.is_available():
37 cur_device = torch.device('mps')
38 print("Uses MPS device.")
39 else:
40 cur_device = torch.device('cpu')
41 print("Uses CPU device.")
42 return cur_device
43
44def tensor2pil(image):
45 return Image.fromarray(np.clip(255. * image.cpu().numpy().squeeze(), 0, 255).astype(np.uint8))

Callers 3

load_modelMethod · 0.85
prepare_src_imageMethod · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected