Beispiel #1
0
def test_load_default_model():
    machine = MachineFactory()

    model = machine.load_model()

    assert isinstance(model, CNNClassificationModel)
    assert isinstance(model, Resnet50CNNModel)
Beispiel #2
0
def test_load_model():
    machine = MachineFactory()

    model = machine.load_model(
        "pyspec.machine.model.application.Resnet50CNNModel")

    assert isinstance(model, CNNClassificationModel)
    assert isinstance(model, Resnet50CNNModel)
Beispiel #3
0
def test_load_encoder():
    machine = MachineFactory()
    encoder = machine.load_encoder()
    assert encoder.width == 500
    assert encoder.height == 500
    assert encoder.axis is False
    assert encoder.intensity_max == 1000
    assert encoder.min_mz == 0
    assert encoder.max_mz == 2000
    assert encoder.dpi == 72
def load_model():
    global clean_dirty_model
    global clean_dirty_encoder
    global graph

    share = S3Share(read_only=True)
    share.retrieve("clean_dirty", force=True)
    factory = MachineFactory()

    # get model and encoder as configured
    clean_dirty_model = factory.load_model()
    clean_dirty_encoder = factory.load_encoder()
    graph = tf.get_default_graph()
Beispiel #5
0
                    required=False,
                    type=str,
                    default=None)
parser.add_argument("--dataset",
                    help="path to your dataset",
                    required=True,
                    type=str)
parser.add_argument("--configuration",
                    help="which configuration file to use",
                    required=True,
                    type=str)
parser.add_argument("--gpu",
                    help="which gpu to use, by deault all will be utilized",
                    type=int,
                    default=-1)

args = parser.parse_args()
factory = MachineFactory(config_file=args.configuration)

model = factory.load_model(name=args.model)

if args.gpu < 0:
    factory.train(args.dataset, model=model, gpus=get_gpu_count())
else:
    os.environ['CUDA_VISIBLE_DEVICES'] = "{}".format(args.gpu)
    factory.train(args.dataset, model=model, gpus=1)

# uploading dataset to cloud storage for reuse by other software
share = S3Share()
share.submit(args.dataset)
Beispiel #6
0
    type=str)
parser.add_argument("--configuration",
                    help="which configuration file to use",
                    required=False,
                    type=str,
                    default="machine.ini")
parser.add_argument("--gpu", help="which gpu to use", type=int, default=-1)

parser.add_argument("--model",
                    help="model you would like to predict",
                    required=False,
                    type=str,
                    default=None)

args = parser.parse_args()
factory = MachineFactory(config_file=args.configuration)

model = factory.load_model(name=args.model)


def callback(file, classname, full_path: str):
    if classname == 0:
        classname = "clean"
    else:
        classname = "dirty"

    print("{} is {}".format(file, classname))
    os.makedirs("{}/{}".format("datasets/{}/sorted".format(args.dataset),
                               classname),
                exist_ok=True)
    copyfile(
Beispiel #7
0
def test_train_model():
    machine = MachineFactory()
    machine.train("datasets/clean_dirty", gpus=1)
Beispiel #8
0
def test_load_generator():
    machine = MachineFactory()
    generator = machine.load_generator()

    assert isinstance(generator, LabelGenerator)