https://mixi-developers.mixi.co.jp/22-technical-training-5fc362a9dc41
投稿者: chosuke
jquery ハンバーガーメニュー
Vket Cloud
WEBサービスの作り方
地震情報
【速報中】石川県能登地方で震度6強の地震 津波被害心配なし | NHK
https://www3.nhk.or.jp/news/html/20230505/k10014058181000.html
ディープ ラーニング入門
Hello world!
Welcome to WordPress. This is your first post. Edit or delete it, then start writing!
Python 引数のデフォルト値
def show_time(h, m, s=0, ms=0):
print(f”{h:02}:{m:02}:{s:02}.{ms:03}”)
show_time(11, 23, 52, 220)
show_time(4, 54, 2, 12)
show_time(12, 3)
show_time(5, 25, 32)
Python AIprograminng
import IPython
from google.colab import output
import cv2
import numpy as np
from PIL import Image
from io import BytesIO
import base64
def run(img_str):
#decimg to image
decimg = base64.b64decode(img_str.split(‘,’)[1], validata=True)
decimg = Image.open(BytesIO(decimg))
decimg = np.array(decimg, dtype=np.uint8);
decimg = cv2.cvtColor(decimg, cv2.COLOR_BGR2RGB)
# image classify
img = cv2.resize(decimg, (64, 64))
img = img_to_array(img)
img = img / 255.0
img = img[np.newaxis]
img = np.asarray(img)
preds = keras_model.predict(img)
result = np.argmax(preds[0])
# draw output
out_img = decimg
cv2.putText(out_img, labels[result], (10,50),
cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 1, cv2.LINE_AA)
#encode to string
_, encimg = cv2.imencode(“.jpg”, out_img,
[int(cv2.IMWRITE_JPEG_QUALITY), 80])
img_str = encimg.tostring()
img_str = (“data:imge/jpeg:base64,” +
base64.b64encode(img_str).decode(‘utf-8’))
return IPython.display.JSON({‘img_str’: img_str})
output.register_callback(‘notebook.run’,run)
https://colab.research.google.com/drive/1cF–C6PRT2j7hPdn5ia1I7SlwGqdvB-d?hl=ja#scrollTo=eT8PXuywDsmO
AI programming Code
import random
# ユーザーからの入力を受け付ける関数
def get_user_input():
user_input = input(“ユーザー: “)
return user_input
# AIの応答を生成する関数
def generate_response(user_input):
responses = [“こんにちは!”, “お元気ですか?”, “何かお助けできることはありますか?”]
response = random.choice(responses)
return response
# メインの処理
def main():
print(“AI: こんにちは!私はAIです。何か質問がありますか?”)
while True:
user_input = get_user_input()
response = generate_response(user_input)
print(“AI:”, response)
if __name__ == ‘__main__’:
main()

