Example #1
0
def main():
    graphics = Graphics()

    # NUM_CYCLES = 5
    # data = build_data(NUM_CYCLES)
    file = 'train.json'
    point_data = load_json(file)

    signal_data = dft(point_data)

    graphics.epicycles = build_epicycles(graphics.screen, signal_data)

    graphics.init_callback()
Example #2
0
def show_prediction(img_path, model, topk, json, device):
    cat_to_name = load_json(json)[0]
    #print(cat_to_name)
    #print(cat_to_name["42"])
    probabilities, indices_of_flowers = predict(img_path, model, topk, device)
    #indices_of_flowers = np.array(probabilities[1][0])
    names_of_flowers = [
        cat_to_name[str(index)] for index in indices_of_flowers
    ]
    percentage = float(probabilities[0] * 100)
    percentage = format(percentage, '.2f')
    image = process_image(img_path)
    name_of_flower = cat_to_name[str(indices_of_flowers[0])]
    print(
        f"With a probability of {percentage}% this image shows a {name_of_flower}."
    )
Example #3
0
def main():
    try:
        data_sets = get_data_sets(sys.argv[1])
    except:
        print(
            "Please give the path/name of an existing directory with your training images (e.g. 'python train.py flowers')."
        )
        exit()

    train_args = get_input_args()
    cat_to_name, output_layer_size = load_json('cat_to_name.json')
    device = get_device(train_args.gpu)
    model, optimizer, criterion = create_model(device, train_args.arch, 0.2,
                                               train_args.hidden_units,
                                               train_args.learning_rate,
                                               output_layer_size)
    model = train_the_model(model, train_args.epochs, data_sets[0],
                            data_sets[1], device, optimizer, criterion)
    test_the_model(model, data_sets[2], device)
    save_checkpoint(model, train_args.arch, train_args.hidden_units,
                    data_sets[3], train_args.save_dir)
Example #4
0
        help='Install i3wmthemer\'s default configuration files')
    parser.add_argument('-l',
                        '--load',
                        type=str,
                        help='Load theme from JSON file')
    args = parser.parse_args()

    configuration = {}

    if args.config != None:
        configuration = conf.read_config(args.config)
    else:
        exit(0)

    if args.backup != None:
        backup.backup_config(args.backup, configuration)
        exit(0)

    if args.install != None:
        install.install_defaults(args.install, configuration)
        com.refresh_all(configuration['xresources'], '')
        exit(0)

    if args.load != None:
        jfile = lj.load_json(args.load)
        rx.replace_xresources(configuration, jfile)
        ri.replace_i3(configuration, jfile)
        rp.replace_polybar(configuration, jfile)
        com.refresh_all(configuration['xresources'], jfile['wallpaper'])
        exit(0)
Example #5
0
        total_type_points = city.total_type_points
        total_scene_points = city.total_scene_points

        for device_type in city.city_device_types_distribution:
            type_nums = city.city_device_types_distribution[device_type][
                '点位数量']
            row_item = [
                city_name, city_rank, device_type, type_nums,
                type_nums / total_type_points
            ]
            ws1.append(row_item)

        for device_scene in city.city_device_scenes_distribution:
            scene_nums = city.city_device_scenes_distribution[device_scene][
                '点位数量']
            row_item = [
                city_name, city_rank, device_scene, type_nums,
                scene_nums / total_scene_points
            ]
            ws3.append(row_item)

    wb.save(out_file)


if __name__ == '__main__':
    json_file = 'data.json'
    out_file = 'result.xlsx'
    cities_data = load_json(json_file)
    cities_arr, province_dict = set_data_from_arr(cities_data)
    write_excel(cities_arr, province_dict, out_file)
Example #6
0
#!/bin/env python3

#   Author  :   James Shane

import sys
sys.path.append("..")
import json
#import collections
import load_json as lj

if __name__=="__main__":

    data = lj.load_json("pal3.json")
    #data["pal"].update(done)
    data["pal"]["D"]=str(2)
    print(data)
    jfile=json.dumps(data, indent=4)
    with open('pal4.json', 'w') as outfile:
        #json.dump(jfile, outfile)
        outfile.write(jfile)
    exit(0)
Example #7
0
#!/bin/env python3

#   Author  :   James Shane

import sys
sys.path.append("..")
import load_json as lj

if __name__ == "__main__":

    html = open("pal.html", "w")
    jfile = lj.load_json("defpal.json")
    for l in jfile['pal']:
        hex_value = jfile['pal'][l]
        print(hex_value)
        html.write("""
            <div style="background: {color}; width: 500px; height: 50px; color: white;">
            {color}
            </div>
        """.format(color=hex_value))
        html.write("</div>")
    exit(0)
Example #8
0
from preprocess import Preprocess
from predict import Predict
from pose_estimation import PoseEstimation
from load_json import load_json
import cv2 as cv
import time

config = load_json('config.json')

# Initiate Classes
pose = PoseEstimation()
predict = Predict(model_weights=config['model'])

# Input Video file
cap = cv.VideoCapture('toothbrush.mp4')
pTime = 0
posePoints = []
while True:
    success, img = cap.read()
    if success is False:
        break
    # Extract Upper Body Poses
    points = pose.pose_estimation(img)
    posePoints.append(points)

    # Preprocess pose points for deep learning classification
    preprocess = Preprocess(input_p=posePoints)

    # Predict from PosePoints
    pred = predict.execute(input_p=preprocess.preprocess_input)
Example #9
0
if __name__=="__main__":

    parser = argparse.ArgumentParser(description='create-theme by James Shane')
    parser.add_argument('-c','--config', type=str, required=True, help='Load config file')
    parser.add_argument('-t','--theme', type=str, required=True, help='Theme name')
    args = parser.parse_args()

    configuration = {}
    configuration = conf.read_config( args.config)
    print (configuration['json-template'])
    install.copy_file_noconfig(configuration['json-template'],args.theme+".json")
    #print (args.config)
    #print (args.theme)

    jfile = lj.load_json(args.theme+".jpg.json")
    back=jfile['pal']['1']
    prnt.prnt( '-n', 'Background is '+back)
    fore=jfile['pal']['2']
    prnt.prnt( '-n', 'Foreground is '+fore)

    data = lj.load_json(args.theme+".json")
    data=rt.replace_theme(data,back,fore,args.theme+".jpg")

    jfile=json.dumps(data, indent=4)
    with open(args.theme+".json", 'w') as outfile:
        #json.dump(jfile, outfile)
        outfile.write(jfile)

    exit(0)
Example #10
0
    parser = argparse.ArgumentParser(description='i3wm-themer by Stavros Grigoriou')
    parser.add_argument('-c','--config', type=str, required=True, help='Load config file')
    parser.add_argument('-b','--backup', type=str, help='Backup files')
    parser.add_argument('-i','--install', type=str, help='Install i3wmthemer\'s default configuration files')
    parser.add_argument('-l','--load', type=str, help='Load theme from JSON file')
    args = parser.parse_args()

    configuration = {}

    if args.config != None :
        configuration = conf.read_config( args.config)
    else:
        exit(0)

    if args.backup != None :
        backup.backup_config( args.backup, configuration)
        exit(0)

    if args.install != None :
        install.install_defaults( args.install, configuration)
        com.refresh_all( configuration['xresources'], '')
        exit(0)

    if args.load != None:
        jfile = lj.load_json( args.load)
        rx.replace_xresources( configuration, jfile)
        ri.replace_i3( configuration, jfile)
        rp.replace_polybar( configuration, jfile)
        com.refresh_all( configuration['xresources'], jfile['wallpaper'])
        exit(0)