Source code for scannerpy.common
import numpy as np
import enum
from collections import defaultdict
[docs]class ScannerException(Exception):
pass
[docs]class DeviceType(enum.Enum):
""" Enum for specifying where an Op should run. """
CPU = 0
GPU = 1
[docs] @staticmethod
def to_proto(protobufs, device):
if device == DeviceType.CPU:
return protobufs.CPU
elif device == DeviceType.GPU:
return protobufs.GPU
else:
raise ScannerException('Invalid device type')
[docs]class DeviceHandle(object):
def __init__(self, device, device_id):
self.device = device
self.device_id = device_id
# Class purely for type annotaiton
[docs]class FrameType(object):
pass
BlobType = bytes
[docs]class ColumnType(enum.Enum):
""" Enum for specifying what the type of a column is. """
Blob = 0
Video = 1
[docs] @staticmethod
def to_proto(protobufs, ty):
if ty == ColumnType.Blob:
return protobufs.Other
elif ty == ColumnType.Video:
return protobufs.Video
else:
raise ScannerException('Invalid column type')