Skip to content

Instantly share code, notes, and snippets.

View vannguyen3007's full-sized avatar
๐Ÿˆ
Focusing

IMei vannguyen3007

๐Ÿˆ
Focusing
View GitHub Profile
@vannguyen3007
vannguyen3007 / function loading signals.py
Created November 26, 2020 06:41
function loading signals
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
@vannguyen3007
vannguyen3007 / save folder.py
Created November 22, 2020 05:54
save folder
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],
@vannguyen3007
vannguyen3007 / Data Preprocessing.py
Last active November 20, 2020 08:02
Data Preprocessing
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'
@vannguyen3007
vannguyen3007 / install_detectron2.sh
Created November 20, 2020 07:44
Install Detectron2
!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
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)]
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 = []
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
{
"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": [
# -*- 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
@vannguyen3007
vannguyen3007 / view.py
Created October 5, 2020 10:17
module important
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')