repo_name
stringlengths
6
97
path
stringlengths
3
341
text
stringlengths
8
1.02M
daegutted/Carteirinha-Vitual
backend/modelo.py
from ast import Num from config import * # Classe pai para funcionário e cidadão class Pessoa(db.Model): Id = db.Column(db.Integer, primary_key=True) NomeCompleto = db.Column(db.String(200)) DtNascimento = db.Column(db.String(100)) Genero = db.Column(db.String(1)) Cpf = db.Column(db.String(100)) ...
Aetf/superpaper
superpaper/spanmode.py
<gh_stars>100-1000 """Control host OS desktop background spanning mode when needed.""" import os import platform import subprocess if platform.system() == "Windows": import winreg def set_spanmode(): """Sets host OS desktop background to span all displays.""" pltf = platform.system() if pltf == "Windo...
Aetf/superpaper
superpaper/configuration_dialogs.py
<reponame>Aetf/superpaper<gh_stars>0 """ GUI dialogs for Superpaper. """ import os import time import superpaper.perspective as persp import superpaper.sp_logging as sp_logging import superpaper.wallpaper_processing as wpproc from superpaper.data import GeneralSettingsData, ProfileData, TempProfileData, CLIProfileData...
Aetf/superpaper
superpaper/wallpaper_processing.py
<reponame>Aetf/superpaper<gh_stars>0 """ Wallpaper image processing back-end for Superpaper. Applies image corrections, crops, merges etc. and sets the wallpaper with native platform methods whenever possible. Written by <NAME>, copyright 2020 under MIT licence. """ import configparser import math import os import p...
bzhou26/CMPUT403
kattis done/allaboutthatbase/allaboutthatbase.py
''' Kattis ID: < allaboutthatbase > Topic: (Arithmetic) Level: 1 point Brief problem description: we interpret the number 7234572345 as: 7×10^4+2×10^3+3×10^2+4×10^1+5×10^0. Your job is to determine the bases in which given arithmetic expressions are valid. We define an expression as valid i...
bzhou26/CMPUT403
contest/0122/1.py
<filename>contest/0122/1.py import itertools for i in itertools.permutations('abcd',4): print (''.join(i))
bzhou26/CMPUT403
contest/0122/sums.py
import sys from itertools import permutations #def choose(l): #global cont #if cont = len(object) def main(): file_list = [] num_set = [] query_set = [] distance = set() cont=0 alldis=set() #for line in sys.stdin: #n = int(line); #i=0 #while(i<n): ...
bzhou26/CMPUT403
contest/aa.py
<reponame>bzhou26/CMPUT403<filename>contest/aa.py import sys def main(): kase = int(input()) while (kase>0): result = set() kase -= 1; num = int(input()) while (num > 0): num -= 1 dis = input() result.add(dis) print(len(result)) ...
ramadhanqa/tugas3_datmining
analisa-kprototype.py
#!/usr/bin/env python import numpy as np from kmodes.kprototypes import KPrototypes # stocks with their market caps, sectors and countries syms = np.genfromtxt('data-prototype.csv', dtype=str, delimiter=',')[:, 0] X = np.genfromtxt('data-prototype.csv', dtype=object, delimiter=',')[:, 1:] X[:, 0] = X[:, 0].astype(flo...
ludeeus/custom_component_myfitnesspal
custom_components/my_fitnesspal/config_flow.py
<reponame>ludeeus/custom_component_myfitnesspal<gh_stars>10-100 import voluptuous as vol import logging from collections import OrderedDict from datetime import datetime, date from homeassistant import config_entries from homeassistant.const import CONF_USERNAME, CONF_PASSWORD, CONF_NAME import homeassistant.helpers...
ludeeus/custom_component_myfitnesspal
custom_components/my_fitnesspal/const.py
"""Constants in myfitnesspal component.""" DOMAIN = "my_fitnesspal" ATTRIBUTION = "Myfitnesspal.com" NAME = "MyFitnessPal" DEFAULT_NAME = "myfitnesspal" ICON = "mdi:run-fast" VERSION = "0.0.1" ISSUE_URL = "https://github.com/helto4real/custom_component_myfitnesspal/issues" SENSOR = "sensor" PLATFORMS = [SENSOR] ...
shawwn/tensorboard
tensorboard/dataclass_compat_test.py
# Copyright 2020 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
bionanoimaging/cellSTORM-pyTorch
train.py
<gh_stars>1-10 import time from options.train_options import TrainOptions from data.data_loader import CreateDataLoader from models.models import create_model from util.visualizer import Visualizer """ This module builds a standard pix2pix image-to-image GAN based on the work of https://github.com/junyanz/pytorch-Cycl...
bionanoimaging/cellSTORM-pyTorch
test_multipleVideo.py
import time import os from options.test_options import TestOptions from data.data_loader import CreateDataLoader from models.models import create_model from util.visualizer import Visualizer from util import html import numpy as np import tifffile from PIL import Image import glob, os """ This module builds a standar...
bionanoimaging/cellSTORM-pyTorch
data/aligned_dataset.py
<gh_stars>1-10 import os.path import random import torchvision.transforms as transforms import torch from data.base_dataset import BaseDataset from data.image_folder import make_dataset from PIL import Image import numpy as np import scipy.ndimage class AlignedDataset(BaseDataset): def initialize(self, opt): ...
bionanoimaging/cellSTORM-pyTorch
test.py
<reponame>bionanoimaging/cellSTORM-pyTorch import time import os from options.test_options import TestOptions from data.data_loader import CreateDataLoader from models.models import create_model from util.visualizer import Visualizer from util import html import numpy as np import tifffile from PIL import Image """ T...
bionanoimaging/cellSTORM-pyTorch
data/video_dataset.py
<filename>data/video_dataset.py import os.path import random import torchvision.transforms as transforms import torch from data.base_dataset import BaseDataset from data.image_folder import make_dataset from PIL import Image import skvideo.io import matplotlib as plt import numpy as np class VideoDataset(BaseDataset)...
bionanoimaging/cellSTORM-pyTorch
models/models.py
def create_model(opt): model = None print(opt.model) assert(opt.dataset_mode == 'aligned') from .pix2pix_model import Pix2PixModel model = Pix2PixModel() model.initialize(opt) print("model [%s] was created" % (model.name())) return model
qizhidong/xmind2testlink
xmind2testlink/xray.py
<filename>xmind2testlink/xray.py<gh_stars>0 #!/usr/bin/env python # encoding: utf-8 import requests import json import time from xmind2testlink.datatype import TestCase class XrayIssue: def __init__(self, x_acpt, jira_token, xray_client_id=None, xray_client_key=None): self.xray_headers = { ...
qizhidong/xmind2testlink
main.py
""" A tool to parse xmind file into testlink xml file, which will help you generate a testlink recognized xml file, then you can import it into testlink as test suites. Usage: xmind2testlink [path_to_xmind_file] [-json] Example: xmind2testlink C:\\tests\\testcase.xmind => output xml xmind2testlink C:\\tests\...
qizhidong/xmind2testlink
xmind2testlink/main.py
<filename>xmind2testlink/main.py """ A tool to parse xmind file into testlink xml file, which will help you generate a testlink recognized xml file, then you can import it into testlink as test suites. Usage: xmind2testlink [path_to_xmind_file] [-json] Example: xmind2testlink C:\\tests\\testcase.xmind => outp...
klmp200/Pandoc-Converter
PandocConverter.py
<reponame>klmp200/Pandoc-Converter<gh_stars>0 # -*- coding: utf-8 -*- # @Author: klmp200 # @Date: 2016-03-17 19:08:11 # @Last Modified by: klmp200 # @Last Modified time: 2016-03-19 16:30:02 import sublime import sublime_plugin import subprocess import re import os class PandocConverterCommand(sublime_plugin.Text...
msjz/ArabCoders-Workshop
rename files/rename_files.py
<gh_stars>0 import os import string def rename_files(): files_list = os.listdir(r"D:\Study\1MAC\test\prank") saved_path = os.getcwd() print "Current working directory is: " + saved_path os.chdir(r"D:\Study\1MAC\test\prank") for file_name in files_list: os.rename(file_name, file_name.translate(None, "0123456789")...
dineshpanchal93/helpremove
account_report/config/account_report.py
<gh_stars>0 from __future__ import unicode_literals from frappe import _ def get_data(): return [ { "label": _("Sanket"), "items": [ { "type": "doctype", "name": "Test", "description": _("For Test.") }, { "type": "doctype", "name": "overtime", "description": _("For Te...
dineshpanchal93/helpremove
account_report/config/hr.py
from __future__ import unicode_literals from frappe import _ def get_data(): return [ { "label": _("Over Time"), "items": [ { "type": "doctype", "name": "overtime", "description": _("For Overtime.") }, { "type": "report", "name": "Monthly Overtime", "doctype": "o...
dineshpanchal93/helpremove
account_report/config/desktop.py
<filename>account_report/config/desktop.py # -*- coding: utf-8 -*- from __future__ import unicode_literals from frappe import _ def get_data(): return [ { "module_name": "HR", "color": "#3498db", "icon": "octicon octicon-repo", "type": "module", "hidden": 1 } ]
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/data/word2vec_dataset.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ...
jd-aig/aves2_algorithm_components
src/cv/image_classification/Configure_file.py
<reponame>jd-aig/aves2_algorithm_components import tensorflow as tf def configure_lr(init_lr, decay_policy, decay_steps, decay_rate, global_steps, warm_lr=0.0001, warm_steps=0): lr_decay_list = { 'exponential_decay': tf.train.exponential_decay(learning_rate=init_lr, ...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/models/dssm.py
<filename>src/nlp/PlatformNlp/models/dssm.py # coding=utf-8 from __future__ import absolute_import from __future__ import division from __future__ import print_function __all__ = ['DssmModel'] __author__ = 'xulu46' __date__ = '2020.10.14' """The main dssm model and related functions.""" import copy import tensorflow ...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/models/bert.py
<filename>src/nlp/PlatformNlp/models/bert.py # coding=utf-8 # Copyright 2018 The Google AI Language Team Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/models/cdssm.py
<gh_stars>1-10 # coding=utf-8 from __future__ import absolute_import from __future__ import division from __future__ import print_function __all__ = ['CdssmModel'] __author__ = 'xulu46' __date__ = '2020.10.14' """The main cdssm model and related functions.""" import copy import tensorflow as tf from PlatformNlp.modul...
jd-aig/aves2_algorithm_components
src/ml/classification/test_classification/run.py
from sklearn.metrics import accuracy_score,precision_score,recall_score,f1_score,confusion_matrix from sklearn.externals import joblib import pandas as pd import argparse import os parser = argparse.ArgumentParser() parser.add_argument("--data_dir", type=str, default="../data/") parser.add_argument("--model_dir", type=...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/data/__init__.py
<reponame>jd-aig/aves2_algorithm_components<gh_stars>1-10 import argparse import importlib import os from PlatformNlp.data.base_dataset import BaseDataset DATA_REGISTRY = {} def get_available_word_split_impl(): return ['word', 'char'] def get_available_type(): return ["train", "valid", "test"] def get_da...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/criterions/multi_label_cross_entropy.py
<filename>src/nlp/PlatformNlp/criterions/multi_label_cross_entropy.py import math import tensorflow as tf from PlatformNlp.criterions.platform_criterion import PlatformNlpCriterion from PlatformNlp.criterions import register_criterion @register_criterion('multi_label_cross_entropy') class MultiLabelCrossEntropyCrite...
jd-aig/aves2_algorithm_components
src/cv/image_classification/pre.py
import tensorflow as tf import math def parse_example_proto(example_serialized): # a dict mapping from feature keys to tensor and sparsetensor values feature_map = { 'image/height': tf.VarLenFeature(dtype=tf.int64), 'image/width': tf.VarLenFeature(dtype=tf.int64), 'image/class/label': tf.FixedLen...
jd-aig/aves2_algorithm_components
src/cv/face_detection/faceboxes/test_faceboxes/try_detector.py
import os os.environ['CUDA_VISIBLE_DEVICES'] = '0' import numpy as np from PIL import Image, ImageDraw import os import cv2 import time from face_detector import FaceDetector import argparse parser = argparse.ArgumentParser() parser.add_argument("--data_dir",type=str,default='../data_dir/') parser.add_argument("--mod...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/metrics/__init__.py
<filename>src/nlp/PlatformNlp/metrics/__init__.py # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import importlib import os from .platform_metrics import PlatformMetrice M...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/modules/attention.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/options.py
import argparse import sys from typing import Callable, List, Optional from PlatformNlp import utils from PlatformNlp.data import get_available_word_split_impl, get_available_type def get_preprocessing_parser(default_task="multi_class"): parser = get_parser("Preprocessing", default_task) add_preprocess_args(...
jd-aig/aves2_algorithm_components
src/cv/ocr_end2end/ATTENTION_OCR/datasets/newtextdataset.py
<reponame>jd-aig/aves2_algorithm_components<gh_stars>1-10 from datasets import fsns import os import json DEFAULT_DATASET_DIR = 'dataset_dir/' def get_split(split_name, config_path, dataset_dir=None, config=None): if not dataset_dir: dataset_dir = DEFAULT_DATASET_DIR if not config: config = json.load(open...
jd-aig/aves2_algorithm_components
src/cv/image_classification/nets/nets_factory.py
<reponame>jd-aig/aves2_algorithm_components # Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
jd-aig/aves2_algorithm_components
src/nlp/Platform_cli/preprocess.py
import logging import os import sys sys.path.append("../") sys.path.append("../PlatformNlp/") from PlatformNlp import options, tasks, utils from PlatformNlp.data import get_dataset from PlatformNlp.tokenization import CharTokenizer, WordTokenizer logging.basicConfig( format='%(asctime)s | %(levelname)s | %(name)s...
jd-aig/aves2_algorithm_components
src/cv/image_classification/early_stop.py
<reponame>jd-aig/aves2_algorithm_components def loss_early_stop(loss, param): #print('Last Loss {}; Loss Count:{}'.format(param['last'],param['count'])) if loss >= param['last']: param['count'] += 1 else: param['count'] = 0 param['last'] = loss return param def top1_early_stop(top...
jd-aig/aves2_algorithm_components
src/cv/object_detection/test_objd/test.py
<filename>src/cv/object_detection/test_objd/test.py from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np import os import time import six.moves.urllib as urllib import sys import tarfile import tensorflow as tf import zipfile from distutils.ver...
jd-aig/aves2_algorithm_components
src/cv/object_detection/ssd_mobilenetv2/cal_params.py
import os import argparse from object_detection.utils import label_map_util parser = argparse.ArgumentParser() parser.add_argument("--data_dir", type=str, default="./") parser.add_argument("--epochs", type=int, default=30) parser.add_argument("--batch_size", type=int, default=24) args = parser.parse_args() label_map_...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/metrics/platform_metrics.py
import logging import os import warnings logger = logging.getLogger(__name__) class PlatformMetrice(object): """ Tasks store dictionaries and provide helpers for loading/iterating over Datasets, initializing the Model/Criterion and calculating the loss. """ @staticmethod def add_args(parser)...
jd-aig/aves2_algorithm_components
src/cv/ocr_detection/CTPN/main/eval.py
import datetime import os import sys import time import numpy import tensorflow as tf sys.path.append(os.getcwd()) for i in os.listdir(os.getcwd()): if not '.' in i: sys.path.append(os.getcwd()+'/'+i) from tensorflow.contrib import slim from nets import model_train as model from utils.dataset import data_...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/metrics/word_embedding_metrics.py
import logging from PlatformNlp.metrics import register_metrices from PlatformNlp.metrics.platform_metrics import PlatformMetrice from PlatformNlp.tokenization import load_vocab import json import numpy as np logger = logging.getLogger(__name__) @register_metrices('word_embedding_metrics') class WordEmbeddingMetrics...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/criterions/multi_class_cross_entropy.py
import math import tensorflow as tf from PlatformNlp.criterions.platform_criterion import PlatformNlpCriterion from PlatformNlp.criterions import register_criterion @register_criterion('multi_class_cross_entropy') class MultiClassCrossEntropyCriterion(PlatformNlpCriterion): def __init__(self, args, task): ...
jd-aig/aves2_algorithm_components
src/cv/face_detection/faceboxes/faceboxes_facedet/train.py
<filename>src/cv/face_detection/faceboxes/faceboxes_facedet/train.py<gh_stars>1-10 import tensorflow as tf import json import os from model import model_fn from src.input_pipeline import Pipeline import argparse tf.logging.set_verbosity('INFO') parser = argparse.ArgumentParser() parser.add_argument("--train_tfrecord",...
jd-aig/aves2_algorithm_components
src/ml/cluster/kmeans/run.py
<filename>src/ml/cluster/kmeans/run.py<gh_stars>1-10 from sklearn.cluster import KMeans from sklearn.metrics import calinski_harabaz_score from sklearn.externals import joblib import pandas as pd import argparse import os import json parser = argparse.ArgumentParser() parser.add_argument("--data_dir", type=str, defaul...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/metrics/multi_label_cross_entry_metrics.py
import logging from PlatformNlp.metrics import register_metrices from PlatformNlp.metrics.platform_metrics import PlatformMetrice from PlatformNlp.utils import calculate_multi_label import json logger = logging.getLogger(__name__) @register_metrices('multi_label') class MultiLabelMetrics(PlatformMetrice): """ ...
jd-aig/aves2_algorithm_components
src/cv/face_detection/faceboxes/val_faceboxes/save.py
<reponame>jd-aig/aves2_algorithm_components<filename>src/cv/face_detection/faceboxes/val_faceboxes/save.py import tensorflow as tf import json from model import model_fn import argparse import os """The purpose of this script is to export a savedmodel.""" parser = argparse.ArgumentParser() parser.add_argument("--outpu...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/metrics/ner_metrics.py
from PlatformNlp.metrics import register_metrices from PlatformNlp.metrics.platform_metrics import PlatformMetrice from PlatformNlp.tokenization import load_vocab from PlatformNlp import conlleval import logging import json import os logger = logging.getLogger(__name__) @register_metrices('ner_metrics') class NerMet...
jd-aig/aves2_algorithm_components
src/cv/face_detection/faceboxes/val_faceboxes/val.py
import tensorflow as tf import json import os from model import model_fn from src.input_pipeline import Pipeline import argparse tf.logging.set_verbosity('INFO') parser = argparse.ArgumentParser() parser.add_argument("--val_tfrecord", type=str, default="../data/") parser.add_argument("--model_dir", type=str, default="...
jd-aig/aves2_algorithm_components
src/cv/image_classification/preprocessing/new_vgg_preprocessing.py
<reponame>jd-aig/aves2_algorithm_components # it is a reconsitution of vgg_preprocessing with opencv # ============================================================================== """Provides utilities to preprocess images. The preprocessing steps for VGG were introduced in the following technical report: Very De...
jd-aig/aves2_algorithm_components
src/ml/regression/decisionTree/run.py
from sklearn.tree import DecisionTreeRegressor from sklearn.metrics import mean_squared_error,r2_score from sklearn.externals import joblib import pandas as pd import argparse import os parser = argparse.ArgumentParser() parser.add_argument("--data_dir", type=str, default="../data/") parser.add_argument("--output_path"...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/utils.py
import importlib.util import logging import os import sys import warnings import tensorflow as tf from typing import Callable, Dict, List, Optional import sklearn.metrics from sklearn.preprocessing import label_binarize from sklearn.metrics import roc_curve, auc import numpy as np from scipy import interp logger = lo...
jd-aig/aves2_algorithm_components
src/ml/classification/randomForest/run.py
<reponame>jd-aig/aves2_algorithm_components from sklearn.ensemble import RandomForestClassifier from sklearn.metrics import accuracy_score,precision_score,recall_score,f1_score,confusion_matrix from sklearn.externals import joblib import numpy as np import pandas as pd import argparse import os import json import time ...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/modules/cosine_score.py
import tensorflow as tf def get_cosine_score(query_arr, doc_arr): # query_norm = sqrt(sum(each x^2)) pooled_len_1 = tf.sqrt(tf.reduce_sum(tf.square(query_arr), 1)) pooled_len_2 = tf.sqrt(tf.reduce_sum(tf.square(doc_arr), 1)) pooled_mul_12 = tf.reduce_sum(tf.multiply(query_arr, doc_arr), 1) cos_sco...
jd-aig/aves2_algorithm_components
src/ml/cluster/gmm/run.py
from sklearn.mixture import GaussianMixture from sklearn.metrics import calinski_harabaz_score from sklearn.externals import joblib import pandas as pd import argparse import os import json parser = argparse.ArgumentParser() parser.add_argument("--data_dir", type=str, default="../data/") parser.add_argument("--output...
jd-aig/aves2_algorithm_components
src/cv/image_classification/model_train.py
<filename>src/cv/image_classification/model_train.py # from __future__ import print_function import tensorflow as tf # the same as neuhub import os import numpy import time from tensorflow.contrib.data.python.ops import batching from tensorflow.contrib.data.python.ops import interleave_ops from tensorflow.contrib.data....
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/models/textcnn.py
# coding=utf-8 from __future__ import absolute_import from __future__ import division from __future__ import print_function __all__ = ['TextCNNModel'] __author__ = 'xulu46' __date__ = '2019.09.29' """The main textcnn model and related functions.""" import copy import tensorflow as tf from PlatformNlp.modules.conv_lay...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/data/base_dataset.py
<reponame>jd-aig/aves2_algorithm_components class BaseDataset(): """Loader for MultiClass dDataset""" def __init__(self, args): self.label_mapping = {}
jd-aig/aves2_algorithm_components
src/ml/regression/randomForest/run.py
from sklearn.ensemble import RandomForestRegressor from sklearn.metrics import mean_squared_error,r2_score from sklearn.externals import joblib import pandas as pd import argparse import os parser = argparse.ArgumentParser() parser.add_argument("--data_dir", type=str, default="../data/") parser.add_argument("--output_p...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/__init__.py
<filename>src/nlp/PlatformNlp/__init__.py import PlatformNlp.criterions # noqa import PlatformNlp.models # noqa import PlatformNlp.modules # noqa import PlatformNlp.optim # noqa import PlatformNlp.tasks # noqa import PlatformNlp.metrics
jd-aig/aves2_algorithm_components
src/nlp/Platform_cli/train.py
import argparse import logging import time import sys import os import shutil sys.path.append("../") sys.path.append("../PlatformNlp/") from PlatformNlp.utils import total_sample import tensorflow as tf from PlatformNlp import ( checkpoint_util, options, tasks, utils, ) from PlatformNlp.optim.AdamWeig...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/modules/conv_layer.py
import tensorflow as tf from PlatformNlp.modules.utils import get_shape_list, create_initializer def conv_layer(input_tensor, filter_sizes=[2, 3], num_filters=128, initializer_range=0.1): input_shape = get_shape_list(input_tensor, expected_rank=4) sequence_length = inp...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/models/platform_model.py
<filename>src/nlp/PlatformNlp/models/platform_model.py """ Base classes for various platform models. """ import logging logger = logging.getLogger(__name__) class PlatformModel(): """Base class for Platform models.""" @staticmethod def add_args(parser): """Add model-specific arguments to the par...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/modules/transformer.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ...
jd-aig/aves2_algorithm_components
src/ml/regression/test_regression/run.py
from sklearn.metrics import mean_squared_error,r2_score from sklearn.model_selection import train_test_split from sklearn.externals import joblib import numpy as np import pandas as pd import argparse import os import json parser = argparse.ArgumentParser() parser.add_argument("--data_dir", type=str, default="../data/"...
jd-aig/aves2_algorithm_components
src/ml/classification/decisionTree/run.py
from sklearn.tree import DecisionTreeClassifier from sklearn.metrics import accuracy_score,precision_score,recall_score,f1_score,confusion_matrix from sklearn.externals import joblib import numpy as np import pandas as pd import argparse import os import json parser = argparse.ArgumentParser() parser.add_argument("--da...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/modules/drop_out.py
import tensorflow as tf def dropout(input_tensor, dropout_prob): """Perform dropout. Args: input_tensor: float Tensor. dropout_prob: Python float. The probability of dropping out a value (NOT of *keeping* a dimension as in `tf.nn.dropout`). Returns: A version of `input_tensor` with dropout a...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/data/text_semilarity_dataset.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ...
jd-aig/aves2_algorithm_components
src/ml/classification/val_classification/run.py
from sklearn.metrics import accuracy_score,precision_score,recall_score,f1_score,confusion_matrix from sklearn.externals import joblib import pandas as pd import argparse import os import json parser = argparse.ArgumentParser() parser.add_argument("--data_dir", type=str, default="../data/") parser.add_argument("--model...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/models/word2vec.py
<gh_stars>1-10 # coding=utf-8 from __future__ import absolute_import from __future__ import division from __future__ import print_function __all__ = ['Word2vecModel'] __author__ = 'xulu46' __date__ = '2020.10.14' """The main dssm model and related functions.""" import copy import tensorflow as tf from PlatformNlp.mod...
jd-aig/aves2_algorithm_components
src/ml/regression/val_regression/run.py
from sklearn.metrics import mean_squared_error,r2_score from sklearn.model_selection import train_test_split from sklearn.externals import joblib import numpy as np import pandas as pd import argparse import os import json parser = argparse.ArgumentParser() parser.add_argument("--data_dir", type=str, default="../data/"...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/criterions/platform_criterion.py
class PlatformNlpCriterion(): def __init__(self, args, task): self.args = args self.task = task @staticmethod def add_args(parser): """Add criterion-specific arguments to the parser.""" pass @classmethod def build_criterion(cls, args, task): """Construct a...
jd-aig/aves2_algorithm_components
src/cv/ocr_end2end/ATTENTION_OCR/tfrecord.py
<filename>src/cv/ocr_end2end/ATTENTION_OCR/tfrecord.py # -*- coding: UTF-8 -*- import tensorflow as tf import numpy as np import os os.environ['TF_CPP_MIN_LOG_LEVEL'] = '1' import threading lock = threading.Lock() import random import cv2 import codecs import json import sys reload(sys) sys.setdefaultencoding('utf-8...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/metrics/multi_class_cross_entry_metrics.py
import logging from PlatformNlp.metrics import register_metrices from PlatformNlp.metrics.platform_metrics import PlatformMetrice from PlatformNlp.utils import calculate_label import json logger = logging.getLogger(__name__) @register_metrices('multi_class') class MultiClassMetrics(PlatformMetrice): """ Sen...
jd-aig/aves2_algorithm_components
src/cv/object_detection/fasterrcnn_resnet50/cal_params.py
import os import argparse from object_detection.utils import label_map_util parser = argparse.ArgumentParser() parser.add_argument("--data_dir", type=str, default="./") parser.add_argument("--epochs", type=int, default=30) parser.add_argument("--batch_size", type=int, default=24) parser.add_argument("--learning_rate",...
jd-aig/aves2_algorithm_components
src/cv/image_classification/preprocessing/fake_new_inception_preprocessing.py
<reponame>jd-aig/aves2_algorithm_components from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy import cv2 import tensorflow as tf import time def opencv_preprocess_for_train(image,height,width,begin,size): print('opeencv start') croped_im...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/tasks/platform_task.py
import logging import os import warnings from PlatformNlp.data.dictionary import Dictionary logger = logging.getLogger(__name__) class PlatformTask(object): """ Tasks store dictionaries and provide helpers for loading/iterating over Datasets, initializing the Model/Criterion and calculating the loss. ...
jd-aig/aves2_algorithm_components
src/cv/ocr_recognition/CRNN/data_provider/__init__.py
<gh_stars>1-10 # -*- coding: utf-8 -*- # @Time : 17-9-22 下午1:39 # @Author : <NAME> # @Site : http://github.com/TJCVRS # @File : __init__.py # @IDE: PyCharm Community Edition
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/data/dictionary.py
<gh_stars>1-10 import os from collections import Counter from multiprocessing import Pool from PlatformNlp import utils class Dictionary(object): """A mapping from symbols to consecutive integers""" def __init__( self, *, # begin keyword-only arguments begin="[CLS]", pad="[P...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/criterions/nce_loss.py
import math import tensorflow as tf from PlatformNlp.criterions.platform_criterion import PlatformNlpCriterion from PlatformNlp.criterions import register_criterion @register_criterion('nce') class NceLossCriterion(PlatformNlpCriterion): def __init__(self, args, task): super().__init__(args, task) ...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/modules/batch_norm.py
<reponame>jd-aig/aves2_algorithm_components import tensorflow as tf def batch_normalization(x, phase_train, gamma, beta): """ Batch normalization on convolutional maps. Ref.: http://stackoverflow.com/questions/33949786/how-could-i-use-batch-normalization-in-tensorflow Args: x: Tensor...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/modules/dssm_layer.py
import tensorflow as tf from PlatformNlp.modules.utils import get_shape_list, create_initializer from PlatformNlp.modules.batch_norm import batch_normalization from PlatformNlp.modules.drop_out import dropout from PlatformNlp.modules.cosine_score import get_cosine_score def dssm_layer(query_ids, doc_ids, hidden_sizes...
jd-aig/aves2_algorithm_components
src/cv/ocr_detection/EAST/pro.py
<filename>src/cv/ocr_detection/EAST/pro.py txt_fn = im_fn.replace(os.path.basename(im_fn).split('.')[1], 'txt') if not os.path.exists(txt_fn): print('text file {} does not exists'.format(txt_fn)) continue text_polys, text_tags = load_annoataion(txt_fn) text_polys, text_tags = check_and_validate_polys(text_poly...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/modules/layer_norm_and_drop_out.py
from PlatformNlp.modules.layer_norm import layer_norm from PlatformNlp.modules.drop_out import dropout def layer_norm_and_dropout(input_tensor, dropout_prob, name=None): """Runs layer normalization followed by dropout.""" output_tensor = layer_norm(input_tensor, name) output_tensor = dropout(output_tensor, drop...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/modules/utils.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/criterions/ner_loss.py
import math import tensorflow as tf from PlatformNlp.criterions.platform_criterion import PlatformNlpCriterion from PlatformNlp.criterions import register_criterion from tensorflow.contrib import crf @register_criterion('ner') class NerLossCriterion(PlatformNlpCriterion): def __init__(self, args, task): ...
jd-aig/aves2_algorithm_components
src/ml/regression/linearReg/run.py
from sklearn.linear_model import LinearRegression from sklearn.metrics import mean_squared_error,r2_score from sklearn.externals import joblib import pandas as pd import argparse import os parser = argparse.ArgumentParser() parser.add_argument("--data_dir", type=str, default="../data/") parser.add_argument("--output_pa...
jd-aig/aves2_algorithm_components
src/cv/ocr_detection/CTPN/utils/prepare/test.py
<reponame>jd-aig/aves2_algorithm_components #!/usr/bin/python # -*- coding: UTF-8 -*- import numpy as np import shapely from shapely.geometry import Polygon,MultiPoint from utils import pickTopLeft line1=[1,0,30,1,5,55,5,20,40,3,6,40,10,4] p=np.array(line1).reshape(7, 2) points = Polygon(p).convex_hull print(poin...
jd-aig/aves2_algorithm_components
src/cv/image_classification/performence.py
<reponame>jd-aig/aves2_algorithm_components<gh_stars>1-10 import sklearn from sklearn import metrics from sklearn.preprocessing import label_binarize from sklearn.preprocessing import LabelBinarizer from sklearn.preprocessing import OneHotEncoder import json import argparse import numpy def per(labels,logits,files,out...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/checkpoint_util.py
import re import operator import collections import tensorflow as tf def get_assignment_map_from_checkpoint(tvars, init_checkpoint): """Compute the union of the current variables and checkpoint variables.""" initialized_variable_names = {} name_to_variable = collections.OrderedDict() shape_to_variable = coll...
jd-aig/aves2_algorithm_components
src/cv/image_classification/preprocessing/new_inception_preprocessing.py
<reponame>jd-aig/aves2_algorithm_components<filename>src/cv/image_classification/preprocessing/new_inception_preprocessing.py # it is a reconsitution of inception_preprocessing with opencv tool # ============================================================================== """Provides utilities to preprocess images fo...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/modules/layer_norm.py
import tensorflow as tf def layer_norm(input_tensor, name=None): """Run layer normalization on the last dimension of the tensor.""" return tf.contrib.layers.layer_norm( inputs=input_tensor, begin_norm_axis=-1, begin_params_axis=-1, scope=name)
jd-aig/aves2_algorithm_components
src/cv/ocr_end2end/ATTENTION_OCR/demo_inference.py
# -*- coding: utf-8 -*- """A script to run inference on a set of image files. NOTE #1: The Attention OCR model was trained only using FSNS train dataset and it will work only for images which look more or less similar to french street names. In order to apply it to images from a different distribution you need to retr...
jd-aig/aves2_algorithm_components
src/nlp/PlatformNlp/tasks/multi_class.py
<filename>src/nlp/PlatformNlp/tasks/multi_class.py # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import os import numpy as np import codecs import random from PlatformNlp i...