This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def load_ecg(file): | |
| # load the ecg | |
| # example file: 'mit-bih-arrhythmia-database-1.0.0/101' | |
| # load the ecg | |
| record = wfdb.rdrecord(file) | |
| # load the annotation | |
| annotation = wfdb.rdann(file, 'atr') | |
| # extract the signal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| os.makedirs("annotated_results", exist_ok=True) | |
| test_image_paths = test_df.file_name.unique() | |
| for clothing_image in test_image_paths: | |
| file_path = f'{IMAGES_PATH}/{clothing_image}' | |
| im = cv2.imread(file_path) | |
| outputs = predictor(im) | |
| v = Visualizer( | |
| im[:, :, ::-1], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| os.makedirs("faces", exist_ok=True) | |
| dataset = [] | |
| for index, row in tqdm(faces_df.iterrows(), total=faces_df.shape[0]): | |
| img = urllib.request.urlopen(row["content"]) | |
| img = Image.open(img) | |
| img = img.convert('RGB') | |
| image_name = f'face_{index}.jpeg' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| !pip install -U torch==1.5 torchvision==0.6 -f https://download.pytorch.org/whl/cu101/torch_stable.html | |
| !pip install cython pyyaml==5.1 | |
| !pip install -U 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI' | |
| import torch, torchvision | |
| print(torch.__version__, torch.cuda.is_available()) | |
| !gcc --version |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def cal_shap(num, m = 150000): | |
| x_sample = numpy_sample(valx, m, 1) | |
| features_permute = np.array([np.random.permutation(i) for i in np.tile(np.array(list(range(25))),(m,1))]) | |
| shap_values = [] | |
| for i,f in enumerate(features): | |
| b1 = [np.concatenate([instance[:,:,:i+1],x_sample[:,j:j+1,fts[i+1:]]],axis=2) for j, fts in enumerate(features_permute)] | |
| b1 = np.concatenate(b1,axis=1) | |
| b2 = [np.concatenate([instance[:,:,:i],x_sample[:,j:j+1,fts[i:]]],axis=2) for j, fts in enumerate(features_permute)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fig = plt.figure(figsize=(10,10)) | |
| for f, feature in enumerate(features): | |
| print(feature_dict[feature]['meaning'], end="\r") | |
| Min, _, _, _, Max, _ = boxnwhisker_value(np.reshape(x_transpose[:,:,f:f+1],-1)) | |
| mean = feature_dict[feature]['mean'] | |
| std = feature_dict[feature]['std'] | |
| x = np.linspace(Min, Max, num_space) | |
| X, Y = np.meshgrid(x, time_range) | |
| preds = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class attention_block(nn.Module): | |
| def __init__(self, input_sz = 64, hidden_sz = 64, tp = 'fea'): | |
| super().__init__() | |
| self.tp = tp | |
| self.ln_h = linear_block(hidden_sz, input_sz) | |
| self.ln_i = linear_block(input_sz, input_sz) | |
| self.ln_w = linear_block(input_sz, input_sz) | |
| self.v = self.rand_p(input_sz, input_sz) | |
| @staticmethod |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "count": 23, | |
| "data": { | |
| "address_city_district": "Chau Thanh District", | |
| "address_country": "Vietnam", | |
| "address_full": "Village 9, Tan Thach Commune, Chau Thanh District, Ben Tre Province", | |
| "address_full_en": "Village 9, Tan Thach Commune, Chau Thanh District, Ben Tre Province", | |
| "address_province": "Ben Tre Province", | |
| "address_street": "Village 9", | |
| "auditing_company": [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| from flask import Flask | |
| from module.company.model_crawler import db_crawler | |
| from module.company.view import module_company | |
| from module.home.view import module_home | |
| def create_app(): | |
| app = Flask(__name__) | |
| # setup config |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import datetime | |
| import json | |
| from flask import Blueprint, jsonify, request | |
| from module.company.model_crawler import Company, db_crawler | |
| from module.company.vietnammarkets.VietnamMarkets import VietnamMarkets | |
| module_company = Blueprint('module_scrap_news', __name__, template_folder='templates') |
NewerOlder