Skip to content

Instantly share code, notes, and snippets.

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

Pigeon p-geon

🕊️
pigeoning
View GitHub Profile
import tensorflow as tf
AUTOTUNE = tf.data.experimental.AUTOTUNE
import pathlib
import random
import os
import IPython.display as display
import matplotlib.pyplot as plt
@p-geon
p-geon / Makefile
Last active February 23, 2021 08:00
Docker+LaTeX
export PWD=`pwd`
export DIR=.
export FILENAME=main
# ===========================================
en: ## compile LaTeX with English
@make tex CONTAINER=pman0214/alpine-texlive-ja-epspdf
@make aux CONTAINER=pman0214/alpine-texlive-ja-epspdf
@make tex CONTAINER=pman0214/alpine-texlive-ja-epspdf
@make tex CONTAINER=pman0214/alpine-texlive-ja-epspdf
@make dvi CONTAINER=pman0214/alpine-texlive-ja-epspdf
@p-geon
p-geon / Makefile
Last active February 23, 2021 12:29
GeneralPurpose for CC-56 Blog
## ENVs
# basic
export PWD=`pwd`
# docker
export CONTAINER_NAME=container_name
export DIR_DOCKER=docker
export DOCKERFILE_NAME=Dockerfile
export EXPOSED_PORT=8888
export CONTAINER_ID=`docker ps --format {{.ID}}`
# --------------------------------------------------------
# initialize
ip link
sudo su
apt update
apt upgrade -y
apt install -y openssh-server vim
# method-1
sudo service network-manager stop
sudo update-rc.d -f network-manager remove
"""
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"
# 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([
# 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
docker run --rm hello-world
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 \
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]