예제 #1
0
    def run(self):
        # 计数器初始化
        count = 0
        # 读取配置
        data = read_config.read()
        cap, ok, frame, length = read_frame.cam_init(self.address)
        # 背景减除器初始化
        fgbg = frame_background.background_init()
        tracker_list = []
        detect_list = []
        result_list = []
        while True:
            ret, frame = cap.read()
            if ret:
                rgbImage = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
                h, w, ch = rgbImage.shape
                bytesPerLine = ch * w
                convertToQtFormat = QImage(rgbImage.data, w, h, bytesPerLine, QImage.Format_RGB888)
                p = convertToQtFormat.scaled(640, 480, Qt.KeepAspectRatio)
                self.changePixmap.emit(p)
                if self.method:
                # https://stackoverflow.com/a/55468544/6622587
                    step = 10
                    diff = frame_background.process(fgbg, frame, count, step)
                    if diff is not 0:
                        # 当前帧的目标检测
                        detect_list, detected_img, contour = frame_detection.detectobj(diff, frame)
                        new_detect_list = frame_tracker.list_compare(detect_list, result_list)
                        Added_tracker_list = frame_tracker.init_tracker(frame, new_detect_list)
                        tracker_list += Added_tracker_list
                        tracked_img, result_list = frame_tracker.update_tracker(frame, tracker_list)

                        frame = detected_img
                        rgbImage = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
                        h, w, ch = rgbImage.shape
                        bytesPerLine = ch * w
                        convertToQtFormat = QImage(rgbImage.data, w, h, bytesPerLine, QImage.Format_RGB888)
                        p = convertToQtFormat.scaled(640, 480, Qt.KeepAspectRatio)
                        self.detected.emit(p)

                        frame = tracked_img
                        rgbImage = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
                        h, w, ch = rgbImage.shape
                        bytesPerLine = ch * w
                        convertToQtFormat = QImage(rgbImage.data, w, h, bytesPerLine, QImage.Format_RGB888)
                        p = convertToQtFormat.scaled(640, 480, Qt.KeepAspectRatio)
                        self.tracked.emit(p)
예제 #2
0
def aciLogIn(apic=None):
    """Log in to ACI."""

    # Get the credentials
    config = read_config.read()

    # If an existing session wasn't supplied, make a new session
    if not isinstance(apic, Node):
        try:
            apic = Node(config['ACI APIC']['url'])
        except MetaError as err:
            # This implies that the meta hasn't been downloaded yet
            raise Exception("The ACI Meta information hasn't been "\
                "downloaded from the controller. To fix this, run:"\
                "\nrmetagen.py -u admin 10.43.40.11") from err

    log.info('APIC Login: {}'.format(
        apic.methods.Login(config['ACI APIC']['username'],
                           config['ACI APIC']['password']).POST()))
    return apic
예제 #3
0
#!/usr/bin/env python
'''Documentation to be written'''
# '%(folder_url)sjob/%(short_name)s/nextbuildnumber/submit

import read_config
import sys
import requests
import json

#####################
# Checking the configuration
#####################
cfg = read_config.read()
if cfg:
    j_url = cfg['jenkins_url']
    user = cfg['user']
    token = cfg['token']
else:
    print('Missing some mandatory parameters')
    sys.exit(1)


def set_b_num(url, num):
    print(num)
    r = requests.post(url, auth=(user, token), data={'nextBuildNumber': num})
    print(json.loads(r.text)['nextBuildNumber'])


def learn_b_num(url):
    r = requests.get(url, auth=(user, token))
    return json.loads(r.text)['nextBuildNumber']
예제 #4
0
import score_py3
import drawing
#%% Input Arguments
parser = argparse.ArgumentParser(
    description=
    'Experiment10(VGG16): Train the model for diagnosing the heart disease by the ECG.'
)
parser.add_argument(
    '-c',
    '--config',
    type=str,
    default='./Config/config.ini',
    metavar='str',
    help="the path of configure file (default: './Config/config.ini')")
Args = parser.parse_args()  # the Arguments
Args = read_config.read(Args)  # read configure file
#%% Main Function
if __name__ == '__main__':
    #%% ########## Read Data ##########
    print('read data')
    ECG_data, ECG_label = read_data.extract_data(
        read_data.read_data(Args))  # read data
    #%% ########## Data Processing ##########
    ECG_data = data_process.cut_out(ECG_data,
                                    Args.len)  # cut out the ECG signals
    ECG_data = data_process.axis_change(ECG_data)  # change the axis
    ECG_label = data_process.label_from_0(ECG_label)  # label from 0
    # split data
    train_x, test_x, train_y, test_y = data_process.train_test_split(
        ECG_data, ECG_label, trainratio=Args.trainratio, random_state=0)
    # change to Tensor
예제 #5
0
파일: gui.py 프로젝트: Narrowroad/DeployACI
    def __init__(self, *args, **kwargs):
        print('Loading GUI')
        super().__init__('ACI Application Deployment')

        config = read_config.read()

        #Definition of the forms fields
        self._txt_name    = ControlText('Application Name (No Spaces)')
        self._auto_ip = ControlCheckBox('Automatically select IPs', default=True)
        self._txt_ip    = ControlText('First Prod Subnet (for Seeded IP generation) (X.X.X.X/Y)')
        self._txt_ip.enabled = False
        self._subnet_size = ControlText('Subnet Size (CIDR)', default='28')
        self._author    = ControlText('Change Implementer', default=config['DEFAULT VALUES']['Your_name'])
        self._requestor    = ControlText('Change Requestor')
        self._change    = ControlText('Change Number')
        self._reserve_in_ipam = ControlCheckBox('Reserve in IPAM', default=True)
        self._append = ControlCheckBox('Append to Existing Service (Overwrite Possible)', default=False)
        self._cc_env = ControlCombo('Environment')
        self._cc_env.add_item('(DEV) - DeployACI Lab', 'deployaci_lab')

        # Populate the environment list from actual tenants
        for tenant in getUsableTenants():
            if tenant == 'deployaci_lab':
                continue
            self._cc_env.add_item(f'(PROD) - {tenant}', tenant)

        self._ck_prod_client = ControlCheckBox('prod_client', default=True)
        self._ck_prod_web = ControlCheckBox('prod_web', default=True)
        self._ck_prod_app = ControlCheckBox('prod_app', default=True)
        self._ck_prod_db = ControlCheckBox('prod_db', default=True)
        self._ck_uat_client = ControlCheckBox('uat_client', default=True)
        self._ck_uat_web = ControlCheckBox('uat_web', default=True)
        self._ck_uat_app = ControlCheckBox('uat_app', default=True)
        self._ck_uat_db = ControlCheckBox('uat_db', default=True)
        self._ck_dev_client = ControlCheckBox('dev_client', default=True)
        self._ck_dev_web = ControlCheckBox('dev_web', default=True)
        self._ck_dev_app = ControlCheckBox('dev_app', default=True)
        self._ck_dev_db = ControlCheckBox('dev_db', default=True)
        self._runbutton     = ControlButton('Deploy')

        self._txt_ip.key_pressed_event = self._runReady
        self._txt_name.key_pressed_event = self._runReady
        self._subnet_size.key_pressed_event = self._runReady
        self._auto_ip.changed_event = self._auto_ip_press


        #Define the event that will be called when the run button is processed
        self._runbutton.value       = self.__runEvent
        self._runbutton.enabled     = False
        #self._cc_env.value          = self.__envEvent

        #Define the organization of the Form Controls
        # self._formset = [
        #     ('_text'),
        #     ('_ck_prod_client'),
        #     ('_ck_prod_web'),
        #     ('_ck_prod_app'),
        #     ('_ck_prod_db'),
        #     ('_ck_uat_client'),
        #     ('_ck_uat_web'),
        #     ('_ck_uat_app'),
        #     ('_ck_uat_db'),
        #     ('_ck_dev_client'),
        #     ('_ck_dev_web'),
        #     ('_ck_dev_app'),
        #     ('_ck_dev_db'),
        #     ('_runbutton'),
        # ]

        self._formset = [
            ('_txt_name'),
            ('_auto_ip'),
            ('_txt_ip'),
            ('_subnet_size'),
            ('_author'),
            ('_requestor'),
            ('_change'),
            ('_reserve_in_ipam', '_append'),
            ('_cc_env'),
            ('_ck_prod_client', '_ck_uat_client', '_ck_dev_client'),
            ('_ck_prod_web', '_ck_uat_web', '_ck_dev_web'),
            ('_ck_prod_app', '_ck_uat_app', '_ck_dev_app'),
            ('_ck_prod_db', '_ck_uat_db', '_ck_dev_db'),
            ('_runbutton'),
        ]
예제 #6
0
from torch.optim import lr_scheduler
from torch.utils.data import DataLoader
from sklearn.metrics import precision_recall_fscore_support

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

parser = argparse.ArgumentParser()
parser.add_argument('--config_file_path',
                    type=str,
                    default='conf_files/config')

## ===============================
# Compile and configure all the model parameters.
## ===============================
args = parser.parse_args()
config = read_config.read(args.config_file_path)
name = config['name']
total_epoch = config['total_epoch']
batch_size = config['batch_size']
class_number = config['class_number']
learning_rate = config['learning_rate']
extractor = config['extractor']
image_size = config['image_size']
target_list = config['target_list'].split(',')

constant.resume_train = bool(config['resume'])
constant.number_worker = config['number_workers']
constant.sampling = config['sampling']
constant.sampling_size = config['sampling_size']

seed = 42