Beispiel #1
0
    parser.add_argument(
        "-f",
        "--file",
        help="submit JSON file; default file architecture.json",
        type=str)
    parser.add_argument("-w",
                        "--weights",
                        help="print weights during learning",
                        action="store_true")
    args = parser.parse_args()
    if args.weights:
        print_weights = True
    if args.file:
        json_file = args.file
    json_parser = JsonParser(json_file)
    json_parser.parse_json()
    train_df = pd.read_csv(json_parser.input_train_file_path)
    test_df = pd.read_csv(json_parser.input_test_file_path)

    type_of_assigment = json_parser.type
    p_train = None
    p_test = None
    output_layer = None
    if type_of_assigment == "regression":
        p_train = RegressionProvider(train_df,
                                     batch_size=json_parser.batch_size)
        p_test = RegressionProvider(test_df, batch_size=json_parser.batch_size)
        output_layer = "linear"
    elif type_of_assigment == "classification":
        p_train = ClassifierProvider(train_df,
                                     batch_size=json_parser.batch_size)
Beispiel #2
0
def main(args):

    parser = argparse.ArgumentParser()
    parser.add_argument("-a",
                        nargs=1,
                        action="store",
                        dest="json_file_name",
                        default=["empty"])
    parser.add_argument("-o",
                        nargs=1,
                        action="store",
                        dest="image_name",
                        default=["empty"])
    parser.add_argument("--output",
                        nargs=1,
                        action="store",
                        dest="image_name",
                        default=["empty"])
    parsed_args = parser.parse_args(args)

    image_name = parsed_args.image_name[0]
    json_file_name = parsed_args.json_file_name[0]

    if json_file_name == "empty":
        print(
            "\n Welcome to my shape drawer :)\n"
            " you can use following options:\n\n"
            "  -a <json-file-name> : path to json file describing the shape or shapes\n"
            "  -o | --output <image-name.png> : allows to save your drawing\n\n"
            " working examples:\n\n"
            " python main.py -a data.json\n"
            " python main.py -a image.json -o star.png\n")
        exit(0)

    json_parser = JsonParser()
    screen, palette, figures = json_parser.parse_json(json_file_name)
    database = DataBase()

    for figure in figures:

        figure_name = figure.get('type')

        if figure_name in database.figures:

            if figure_name == 'circle':

                shape = CircleDrawer(screen, palette, figure, image_name)
                shape.draw_circle()

            elif figure_name in ['square', 'rectangle']:

                shape = RectangleDrawer(screen, palette, figure, image_name)
                shape.draw_rectangle()

            elif figure_name == 'point':

                shape = PointDrawer(screen, palette, figure, image_name)
                shape.draw_point()

            elif figure_name == 'polygon':

                shape = PolygonDrawer(screen, palette, figure, image_name)
                shape.draw_polygon()

        else:
            print("Unrecognized figure: ", figure_name)