コード例 #1
0
ファイル: rmpe_server.py プロジェクト: zbxzc35/openpose_keras
def main():

    train =  Server(GetConfig("Canonical"), COCOSourceConfig("../dataset/coco_train_dataset.h5"), 5555, "Train", shuffle=True,  augment=True)
    val =    Server(GetConfig("Canonical"), COCOSourceConfig("../dataset/coco_val_dataset.h5"), 5556, "Val",   shuffle=False, augment=False)

    processes = [train, val]

    while None in [p.process.exitcode for p in processes]:

        print("exitcodes", [p.process.exitcode for p in processes])
        for p in processes:
            if p.process.exitcode is None:
                p.join()
コード例 #2
0
from addins.head_counter_config import HeadCounterConfig
from model import get_testing_model
from glob import glob

toloka_dir = os.path.abspath(
    '/opt/home/anatolix/YaDisk/Приложения/Яндекс.Толока')
results_dir_mask = os.path.join(toloka_dir,
                                "Results/Heads/assignments_*.tsv.csv")
img_dir = os.path.join(toloka_dir, "Yandex.Toloka/pochta")

task = sys.argv[1]
assert task == "predict" or task == "render"
config_name = sys.argv[2]
model = sys.argv[3]

config = GetConfig(config_name)

val_size = 19

val_ids = None
train_ids = None


def prepare(config, model_file):

    model = get_testing_model(np_branch1=config.paf_layers,
                              np_branch2=config.heat_layers + 1)

    print("using model:", model_file)
    model.load_weights(model_file)
コード例 #3
0
def db_release():
    requests.request('GET', 'http://127.0.0.1:5000/shutdown')
    conf = GetConfig()
    conf.release_db_disk(logger)
    start_server()
コード例 #4
0
def clear_dir():
    conf = GetConfig()
    conf.clean_tmp_file()
コード例 #5
0
        for i in range(matches.shape[0]):
            okp_threshold = eval_result.params.iouThrs[i]
            scores['matched_%.2f' % okp_threshold] = sum(matches[i, :] != 0)
        scores['average'] = np.mean(np.sum(matches != 0, axis=1)) / scores['gt_person_count']

        return scores

    evalImgs = eval_result.evalImgs
    scores = [convert_match_to_score(image_match) for image_match in evalImgs if image_match is not None]

    return pd.DataFrame(scores)


if __name__ == "__main__":
    config = GetConfig('Canonical')
    params, model_params = config_reader(figstr='testing/config')
    from posenet.mymodel3 import get_testing_model

    # with tf.device("/cpu:0"):
    #     model_single = get_testing_model(np_branch1=config.paf_layers, np_branch2=config.heat_layers, stages=1)
    # model = multi_gpu_model(model_single, gpus=2)
    model = get_testing_model(np_branch1=config.paf_layers, np_branch2=config.heat_layers+1, stages=3)  # fixme: background + 1
    training_dir = './training/'
    trained_models = [
        'weights'
        # 'weights-cpp-lr'
        # 'weights-python-last',
    ]

    optimal_epoch_loss = 'val_weight_stage6_L1_loss'
コード例 #6
0
                    trans_status = True
                    os.remove(tp)
            if f_type == 'video':
                obj_id = self.media_shortcut(tmp)
                info = {'shortcut': obj_id if obj_id else ''}
            if f_type == 'audio':
                info = self.media_info_extract(tmp)
            res.append({
                'file_path': tmp,
                'des': info,
                "trans_status": trans_status
            })
        return config.build_response('after_upload', res, 200)


config = GetConfig()
fo = FileOperation()
file = Blueprint('file', __name__)
globalLock = threading.Lock()


@file.route('/upload', methods=['POST'])
def file_upload():
    if request.method == 'POST':
        if request.form["name"] and request.form['f_type'] and request.form[
                'unique_id']:
            tmp_dir = config.get_tmp_by_type(
                request.form['f_type']) + '\\' + request.form['unique_id']
            globalLock.acquire()
            if not os.path.exists(tmp_dir):
                os.mkdir(tmp_dir)
コード例 #7
0
 def _get_files(self):
     return GetConfig().get_log()
コード例 #8
0
from keras.utils import plot_model
from keras import Model, Sequential
from keras.layers import Input, ZeroPadding2D, BatchNormalization, Activation, Conv2D, MaxPooling2D, \
    AveragePooling2D, UpSampling2D, Lambda, Dropout
from keras.layers.merge import Concatenate, Multiply, Add
from keras.regularizers import l2
from keras.initializers import random_normal, constant
from keras.applications.vgg19 import preprocess_input
import keras.backend as K
import tensorflow as tf
import re
import numpy as np
from config import COCOSourceConfig, GetConfig

config = GetConfig("Canonical")


def relu(x):
    return Activation('relu')(x)


def conv(x,
         nf,
         ks,
         name,
         weight_decay,
         stride=1,
         use_bias=False,
         use_bn=False,
         use_relu=True):
    kernel_reg = l2(weight_decay[0]) if weight_decay else None
コード例 #9
0
        if self.mask_cache is not None:
            return self.mask_cache

        head_layer = global_config.find_heat_layer('HeadCenter')

        if global_config.num_parts == 1:
            #background is ok
            print("Layers will be kept: ", head_layer, "background")
            self.mask_cache = np.ones(global_config.parts_shape,
                                      dtype=np.float)
        else:
            print("Layers will be kept: ", head_layer)
            self.mask_cache = np.zeros(global_config.parts_shape,
                                       dtype=np.float)
            self.mask_cache[:, :, head_layer] = 1.

        return self.mask_cache

    def source(self):

        return self.hdf5_source


Configs["HeadCount"] = HeadCounterConfig
Configs["HeadTrim"] = HeadCounterTrimmedConfig

if __name__ == "__main__":

    # test it
    foo = GetConfig("HeadCount")