Ejemplo n.º 1
0
    def __init__(self, mode=None, config_path=None, *args, **kwargs):
        if config_path is None:
            config_path = utils.Path(inspect.getfile(
                self.__class__)).with_name('config.yaml')

        if mode is None:
            self.processor = Processor()
        elif config_path.exists():
            config = utils.load_yaml(config_path)
            self.processor = utils.create_instance(config[mode], *args,
                                                   **kwargs)
        else:
            raise FileNotFoundError('{} not found.'.format(config_path))
Ejemplo n.º 2
0
 def on_notepad(self, filepath):
     utils.spawnProcess('notepad "%s"' % utils.Path(filepath).asNative())
Ejemplo n.º 3
0
import utils

# Filter future deprecation warnings
utils.filterwarnings('ignore')

root = utils.Path("../ip102_v1.1")
model_dir = utils.Path("models/pest")

detector = utils.PestDetector(root=root, model_dir=model_dir)

# Preparing data and model with an optional quantization
detector.getdata(bs=32, num_workers=1, noise=False, blur=False, basic=True)
detector.createmodel(quantize=True)

# Training model
detector.train(epochs=10, firstrun=True, min_lr=None, interpret=False)
detector.train(epochs=20,
               firstrun=False,
               min_lr=utils.asklr(),
               interpret=False)

# Pruning model and finetuning further
detector.loadmodel(path=model_dir / "recentbest")
detector.prunemodel(amount=0.5)
detector.findlr()
detector.train(epochs=20, firstrun=False, min_lr=utils.asklr(), interpret=True)

# Finish quantization
detector.quantize()

# Save model for mobile deployment using torchscript
Ejemplo n.º 4
0
def initialize_paths(game):
    paths = []
    for path in utils.possible_paths:
        paths.append(utils.Path(path, game))
    return paths