Skip to content

Instantly share code, notes, and snippets.

View kouya17's full-sized avatar

Koya Aoki kouya17

View GitHub Profile
def objective(trial):
import keras
#セッションのクリア
keras.backend.clear_session()
num_layer = trial.suggest_int("num_layer", 3, 8)
mid_units = int(trial.suggest_discrete_uniform("mid_units", 100, 300, 100))
num_filters = [int(trial.suggest_discrete_uniform("num_filter_"+str(i), 16, 128, 16)) for i in range(num_layer)]
dropout_rate = trial.suggest_uniform('dropout_rate', 0.0, 0.5)
metrics = trial.suggest_categorical('metrics', ['accuracy'])
def create_model(num_layer, mid_units, num_filters, dropout_rate):
from keras.models import Sequential
from keras.layers import Dense, Dropout, Flatten
from keras.layers import Conv2D, MaxPooling2D
model = Sequential()
model.add(Conv2D(filters=num_filters[0], kernel_size=(3, 3),
activation="relu",
input_shape=(37, 110, 1)))
for i in range(1, num_layer):
model.add(Conv2D(filters=num_filters[i], kernel_size=(3,3),
def load_data(path, isGray = False, isEqualLength = False, isFlat = False):
import sys
from PIL import Image
import random
import os
import numpy as np
from lib.json_data import read_by_key
from tensorflow.keras.utils import to_categorical
import copy
gun_list = read_by_key(os.path.join('settings', 'data.json'), 'gunList')
# -*- coding: utf-8 -*-
import Adafruit_PCA9685
import cv2
import numpy as np
from tensorflow.keras.applications.mobilenet_v2 import preprocess_input
from tensorflow.keras.preprocessing.image import img_to_array
from tensorflow.keras.models import load_model
import time
@kouya17
kouya17 / generate_keyframs_bezier.py
Last active February 7, 2021 07:47
要素の背景色が変化するアニメーションをCSSで実装するためのkeyframeを生成する(ベジェ曲線によるイージング含む)
wid = 10 # グラデーションの変化幅(%)
color_before = '#efefef' # もともとの背景色
color_after = '#ffcc99' # 変化後の背景色
first_duration = 35 # 1変化目の時間幅(%)
second_duration = 30 # 2変化目の時間幅(%)
class Bezier:
def __init__(self, p):
self.__p = p
@kouya17
kouya17 / bezier.py
Created February 7, 2021 06:41
ベジェ曲線を生成する
import matplotlib.pyplot as plt
class Bezier:
def __init__(self, p):
self.__p = p
def calc(self, t):
return self.__calc(self.__p, t)
@kouya17
kouya17 / generate_keyframes.py
Created February 7, 2021 03:40
要素の背景色が変化するアニメーションをCSSで実装するためのkeyframeを生成するプログラム
wid = 10 # グラデーションの変化幅(%)
color_before = '#efefef' # もともとの背景色
color_after = '#ffcc99' # 変化後の背景色
first_duration = 35 # 1変化目の時間幅(%)
second_duration = 30 # 2変化目の時間幅(%)
f = open('./css.txt', mode='w')
for i in range(first_duration):
p = i + 1
f.write(' ' + str(p) + '% {\n background: linear-gradient(to right, ' + color_after + ' ' +
// GETリクエスト
axios
.get("http://<localIP>:50001")
.then((response) => {
console.log(response);
})
.catch((error) => {
console.log("<>", error);
})
[package]
name = "hello-world"
version = "0.1.0"
authors = ["kouya17 <my email>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
actix-web = "3"
use actix_web::{get, post, web, App, HttpResponse, HttpServer, Responder};
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
struct Operation {
kind: String,
user: String,
}
#[get("/")]