Skip to content

Instantly share code, notes, and snippets.

View p-geon's full-sized avatar
🕊️
pigeoning

Pigeon p-geon

🕊️
pigeoning
View GitHub Profile
@p-geon
p-geon / useful_python.py
Last active June 16, 2018 11:17
pythonで便利なやつら
# 便利なデバッガー
import pdb; pdb.set_trace()
# 毎回書くアレ。画像表示用関数
import matplotlib.pyplot as plt
def single_color(img, dpi=72):
plt.figure(dpi=dpi)
plt.imshow(img)
plt.show()
plt.close()
import numpy as np
print("range: ", np.max(X[0]), np.min(X[0]))
# 画面をリフレッシュしつつアタッチ
tmux a -d
GPUconfig = tf.ConfigProto(
gpu_options=tf.GPUOptions(
allow_growth=True
, visible_device_list="0"
)
, device_count={"GPU":1}
)
with tf.Session(graph=graph, config=GPUconfig) as sess:
print(sess.run())
from tqdm import tqdm
import numpy as np
from skimage.io import imread, imsave
win_h = win_w = 640
orig = imread(fname="image_A.png")
ours = imread(fname="image_B.png")
def main():
for i in tqdm(range(1)):
h_bias, w_bias = np.random.randint(0, orig.shape[0]-win_h), np.random.randint(0, orig.shape[1]-win_w)
crop_orig = orig[h_bias:h_bias+win_h, w_bias:w_bias+win_w]
FROM nvidia/cuda:9.0-cudnn7-runtime-ubuntu16.04
# Set anaconda(miniconda) path
ENV MINICONDA /opt/miniconda
ENV PATH $MINICONDA/bin:$PATH
# Download anaconda and install it
RUN apt-get update && apt-get install -y wget build-essential
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
docker run --rm hello-world
# resize
from skimage.io import imread, imsave
from skimage.transform import resize
x = imread("X.png")
x2 = resize(x, (128, 128))
imsave("resize.png", x2)
# overlay
from skimage.io import imread, imsave
from skimage.transform import resize
# curl -O https://gist.githubusercontent.com/xagano/1ba3caabd6d1c40d0fe85058a7294222/raw/b2ea3934cfeec110aaf74ca8f5bbdd07fae628fe/TF2_MNIST.py
import time
import tensorflow as tf
mnist = tf.keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0
model = tf.keras.models.Sequential([
"""
Before running this cell, you will set hidden vars by "add-ons" menu.
"""
from kaggle_secrets import UserSecretsClient
def clone_repository(
ssh_keyval: "str: BEGIN RSA PRIVATE KEY to END RSA PRIVATE KEY"
, ssh_keyname: "str: id_rsa..."
, gitrepo: "str: your private repository to clone"