Discover Snippets

@takane takane / tasks.json Created at Thu Jan 15 12:20:53 JST 2026
macOSのVSCode用
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug (Clang/LLDB)",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"cwd": "${fileDirname}",
@takane takane / test Created at Tue Sep 17 09:07:59 JST 2024
test code
@ml2024 ml2024 / getimages.py Created at Thu Jun 27 11:40:23 JST 2024
インターネット上から画像収集
# pip install icrawler

from icrawler.builtin import BingImageCrawler
crawler = BingImageCrawler(storage = {'root_dir' : './image/tflask'})
crawler.crawl(keyword = '三角フラスコ', max_num = 30)
crawler = BingImageCrawler(storage = {'root_dir' : './image/beaker'})
crawler.crawl(keyword = 'ビーカー', max_num = 30)
crawler = BingImageCrawler(storage = {'root_dir' : './image/funnel'})
crawler.crawl(keyword = 'ろうと', max_num = 30)
crawler = BingImageCrawler(storage = {'root_dir' : './image/burette'})
@takane takane / getImages.py Created at Thu Jun 27 11:39:19 JST 2024
# pip install icrawler

from icrawler.builtin import BingImageCrawler
crawler = BingImageCrawler(storage = {'root_dir' : './image/tflask'})
crawler.crawl(keyword = '三角フラスコ', max_num = 30)
crawler = BingImageCrawler(storage = {'root_dir' : './image/beaker'})
crawler.crawl(keyword = 'ビーカー', max_num = 30)
crawler = BingImageCrawler(storage = {'root_dir' : './image/funnel'})
crawler.crawl(keyword = 'ろうと', max_num = 30)
crawler = BingImageCrawler(storage = {'root_dir' : './image/burette'})
@ml2024 ml2024 / graph_turi.py Created at Wed Jun 05 18:35:58 JST 2024
import numpy as np
import matplotlib.pyplot as plt

data01_axis1, data01_value1 = np.loadtxt("./kari2.txt", delimiter="|", usecols=range(1,3), unpack=True)

fig = plt.figure(figsize=(10, 6))
ax = fig.add_subplot(111)
ax.plot(data01_axis1, data01_value1, ".-", color="k", label="value1 of data01")
# ax.set_xlim(1000, 3000)
ax.set_xlabel("iterations")
@cs2023 cs2023 / Oxydol.swift Created at Wed Nov 29 14:14:23 JST 2023
OxydolをCodableに
import SwiftUI

class Oxydol : Codable {
var name: String
var kind: String
var formula: String
var images: [String]

enum CodingKeys: String, CodingKey {
case name, kind, formula, images
@s20h109 s20h109 / create-frame Created at Fri Sep 15 12:08:04 JST 2023
import turicreate as tc
import re

# 学習用画像をロードする(JPEG以外はスキップされる)
data = tc.image_analysis.load_images('training-images', with_path=True)
print(data['path'])

# ディレクトリ名からラベルを作成する
data['label'] = data['path'].apply(lambda path: re.match(r'.*/training-images/(.*)/.*', path).group(1))
@takane takane / .zshrc Created at Wed Sep 06 11:59:58 JST 2023
Apple Siliconのマシンでhomebrewおよびpyenvを利用するときの設定ファイル (各自のホームディレクトリに作成) 。1行目から6行目はHomebrew用
if [ "$(uname -m)" = "arm64" ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
export PATH="/opt/homebrew/bin:$PATH"
else
eval "$(/usr/local/bin/brew shellenv)"
fi

if [ "$(uname -m)" = "arm64" ]; then
# arm64
export PYENV_ROOT="$HOME/.pyenv_arm64"
@s20h109 s20h109 / test.sh Created at Tue Jul 25 15:25:01 JST 2023
convertコマンドを一括実行するスクリプト
#!/bin/bash

for file in $*
do
convert -rotate 45 ${file} ${file%.*}_45.JPG
done
@ml2023 ml2023 / turi2.py Created at Sun Jul 09 14:27:08 JST 2023
Turi Createでラベル作成の関数を使った例
import turicreate as tc
import re

# データセットの読み込み
train_data = tc.image_analysis.load_images('./Train9' , with_path=True)

# データセットの読み込み
test_data = tc.image_analysis.load_images('./Test9' , with_path=True)

# ラベル作成の関数