Skip to content

Instantly share code, notes, and snippets.

@wwiiiii
wwiiiii / webcam_record.py
Created October 8, 2020 16:06
CCTV 대신 웹캠으로 집안 녹화하기
import numpy as np
import cv2
import time
from datetime import datetime
import pathlib
save_gap = 1800
done = False
while not done:
@wwiiiii
wwiiiii / pr.py
Created July 29, 2019 04:16
using line_profiler with multiprocessing, no decorator
import time
from torch.multiprocessing import Process, Queue as mpQueue, set_start_method
from line_profiler import LineProfiler
def test(x):
for i in range(3):
if x == 1:
print(x)
time.sleep(0.1)
else:
import gc
import time
import numpy as np
def foo(repeat):
a = []
for _ in range(repeat):
a.append(np.zeros((84, 84, 1)))
s = time.time()
return s
from io import BytesIO
from PIL import Image, ImageDraw, ImageFont
class schedule:
def __init__(self, fname):
self.talks = []
with open(fname, 'r', encoding='utf-8') as f:
for line in f:
line = line.split()
time, line = line[0], ' '.join(line[1:])
import gc
import time
from io import BytesIO
import multiprocessing
from multiprocessing.pool import ThreadPool
import torch
import requests
from PIL import Image
from torchvision import transforms
import random
import gym
import numpy as np
import tensorflow as tf
L2_REG = 1e-2
LR = 1e-3
class pg:
def __init__(self):
import random
import gym
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.distributions import Categorical
L2_REG = 1e-2
def _batch_normalization(inp, is_train, name=None, is_conv=True):
now_mean, now_var = tf.nn.moments(inp, axes=[0, 1, 2] if is_conv else [0])
if name is None:
name = str(time.time())
gamma = tf.get_variable('gamma_%s' % name, shape=[inp.shape[-1]])
beta = tf.get_variable('beta_%s' % name, shape=[inp.shape[-1]])
ema = tf.train.ExponentialMovingAverage(decay=0.99)
def update():
with tf.control_dependencies([ema.apply([now_mean, now_var])]):
#include <cstdio>
#include <queue>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int depth(int a)
{
int now = 3, res = 0, sum = 0;
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int n, m, k;
vector<long long int> container; //raw data 저장 배열, 범위 [1...n]
vector<long long int> tree; // 세그먼트 트리, 루트는 1, 왼쪽 자식은 2i, 오른쪽 자식은 2i+1
vector<long long int> lazy; // 현재 구간에 할당된 lazy값. 하위 구간을 참조해야 되면 0으로 바꾸고 밑으로 내려보냄
/*