このページは,学術の進展には,用語の定義,実験等での実証が重要であり,そのための基本となる情報をまとめたいという理念による. 第三者のソフトウェア,データセット,製品等を説明しているものがあるが, それらの利用条件は利用者で確認すること.個々のソフトウェア,データセット,製品等の評価,評論は行わない.
データ処理,データベース,ディープラーニング分野のための基礎用語. 項目を 0-9,a-z, あーん,漢字順に並べている.
【目次】
【サイト内のまとめページへのリンク】
【Google Colaboratory の使い方】
Google Colaboratory は,オンラインの Python の開発環境.使い方などは, 別ページ »で説明
【サイト内の主な Windows 関連ページ】
【サイト内の主な Ubuntu 関連ページ】
2to3 は,Python バージョン 2 用のソースコードを Python バージョン 3 用に変換するプログラム.
詳しくは: 別ページ »で説明している.
顔のデータベース,顔の 68 ランドマークが付いている.
【文献】
C. Sagonas, G. Tzimiropoulos, S. Zafeiriou and M. Pantic, "300 Faces in-the-Wild Challenge: The First Facial Landmark Localization Challenge," 2013 IEEE International Conference on Computer Vision Workshops, 2013, pp. 397-403, doi: 10.1109/ICCVW.2013.59.
https://ibug.doc.ic.ac.uk/media/uploads/documents/sagonas_2016_imavis.pd
【関連する外部ページ】
【関連項目】 HELEN データセット, iBUG 300-W データセット, face alignment, 顔ランドマーク (facial landmark)の検出, 3次元の顔の再構成 (3D face reconstruction), OpenMMLab, 顔の 68 ランドマーク, 顔のデータベース
3DF Zephyr Free は,フォトグラメトリのソフトウェア 3dF Zephyr の無料版
【関連項目】 フォトグラメトリ, Meshroom
3DDFA_V2 は, 3次元の顔の再構成 (3D face reconstruction) のうち dense vertices regression を行う一手法.論文は,2020年発表.
【文献】
Jianzhu Guo, Xiangyu Zhu, Yang Yang, Fan Yang, Zhen Lei, Stan Z. Li, Towards Fast, Accurate and Stable 3D Dense Face Alignment, ECCV 2020.
https://arxiv.org/pdf/2009.09960v2.pdf
【関連する外部ページ】
URL: https://github.com/cleardusk/3DDFA_V2
作成された3次元モデルを Blender にインポートした画面.
次のページは,Google Colaboratory のページである.ページを開き実行できる.
URL: https://colab.research.google.com/drive/1OKciI0ETCpWdRjP-VOGpBulDJojYfgWv [Google Colaboratory]
実行により,3次元のポリゴンが得られていることを確認できる.
結果は /content/3DDFA_V2/examples/results/ にできる. ここには,顔の3次元データであるポリゴンメッシュ(.obj ファイル)もある.
.obj ファイルをダウンロードし Blender で表示してみると次のようになる.
画像から,物体検出を行うとともに,その3次元の向きの推定も行う.
【関連項目】 Objectron
3次元ゲームエンジン (3-D game engine) の機能を持つソフトウェアとしては, GoDot, Open 3D Engine, Unreal Engine, Panda3D などがある.
3次元の顔の再構成 (3D face reconstruction) は, 顔の写った画像から,元の顔の3次元の形を構成すること.
3次元の顔の再構成は,次の2つの種類がある.
3次元再構成 (3D reconstruction) の機能をもつソフトウェアとしては, colmap, Meshroom がある.
【関連項目】 colmap, Meshroom, Multi View Stereo, OpenMVG, OpenMVS, Structure from Motion
3次元点群データ (3-D point cloud data) を扱うには,MeshLab や CloudCompare が便利である.
7-Zipはファイルやフォルダの圧縮・解凍作業を行うためのツールである.Windows の標準機能では簡単に扱えない各種形式のアーカイブファイルを扱うことが可能である.
7-Zip の公式ページ: https://sevenzip.osdn.jp/ からダウンロードしてインストールする.
7-Zip のインストールの詳細: 別ページ »で説明
コマンドプロンプトを管理者として実行: 別ページ »で説明
次のコマンドを実行
powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";C:\Program Files\7-Zip\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"
URL: https://www.visuallocalization.net/datasets/
Access はリレーショナルデータベース管理の機能を持ったソフトウエア.
【サイト内の関連ページ】
M.Zeiler の AdaDelta 法は,学習率をダイナミックに変化させる技術. 学習率をダイナミックに変化させる技術は,その他 Adam 法なども知られる.
確率的勾配降下法 (SGD 法) をベースとしているが, 確率的勾配降下法が良いのか,Adadelta 法が良いのかは,一概には言えない.
【Keras のプログラム】
from tensorflow.keras.optimizers import Adadelta optimizer = Adadelta(rh=0.95)
M. Zeiler, Adadelta An adaptive learning rate method, 2012.  
Adam 法は,学習率をダイナミックに変化させる技術. 学習率をダイナミックに変化させる技術は,その他 AdaDelta 法なども知られる. Adam 法を使うプログラム例は次の通り.
【Keras のプログラム】
m.compile( optimizer=tf.keras.optimizers.Adam(learning_rate=0.001), loss='sparse_categorical_crossentropy', metrics=['sparse_categorical_crossentropy', 'accuracy'] )
Diederik Kingma and Jimmy Ba, Adam: A Method for Stochastic Optimization, 2014, CoRR, abs/1412.6980
ADE20K データセット は, セマンティック・セグメンテーション,シーン解析(scene parsing), インスタンス・セグメンテーション (instance segmentation)についてのアノテーション済みの画像データセットである.
次の特色がある
画像数,オブジェクト数などは次の通り.
うち学習用: 25,574 枚, うち検証用: 2,000 枚, うちテスト用: 3,000 枚.
利用には,次の URL で登録が必要.
ADE20K データセットの URL: http://groups.csail.mit.edu/vision/datasets/ADE20K/
【文献】
【関連する外部ページ】
このスターターコードは,画像1枚について元画像とアノテーションを表示するもの
【関連項目】 セマンティック・セグメンテーション (semantic segmentation), シーン解析(scene parsing), インスタンス・セグメンテーション (instance segmentation), Detectron2 CASILVision, MIT Scene Parsing Benchmark, 物体検出
AFLW (Annotated Facial Landmarks in the Wild) データセットは, Flickr から収集された24,386枚の顔画像である. さまざまな表情,民族,年齢,性別,撮影条件,環境条件の顔が収集されている. それぞれの顔には,最大21個の顔ランドマークが付けられている.
次の URL で公開されているデータセット(オープンデータ)である.
URL: https://www.tugraz.at/institute/icg/research/team-bischof/lrs-group/downloads
【文献】
M. Köstinger, P. Wohlhart, P. M. Roth and H. Bischof, "Annotated Facial Landmarks in the Wild: A large-scale, real-world database for facial landmark localization," 2011 IEEE International Conference on Computer Vision Workshops (ICCV Workshops), 2011, pp. 2144-2151, doi: 10.1109/ICCVW.2011.6130513.
【関連する外部ページ】
https://github.com/open-mmlab/mmpose/blob/master/docs/en/tasks/2d_face_keypoint.md#aflw-dataset
Anaconda3は,Python 処理系, conda その他の詰め合わせ. パッケージ管理は anaconda, conda コマンドで行う. pip や python setpy.py でのインストール予定がない場合には候補の1つになりえる.
Windows での Anaconda3 のインストールには,複数の方法がある.次のいずれかによりインストールできる.
winget をインストールしたのち,コマンドプロンプトを管理者として開き「winget install Anaconda3」を実行.
【関連項目】 Python のインストール: 別項目で説明している.
手作業で収集された,「in-the-wild」の顔と年齢のデータベース. 年号まで正確に記録された顔画像が含まれている.
次の URL で公開されているデータセット(オープンデータ)である.
https://ibug.doc.ic.ac.uk/resources/agedb/
【文献】
S. Moschoglou, A. Papaioannou, C. Sagonas, J. Deng, I. Kotsia and S. Zafeiriou, "AgeDB: The First Manually Collected, In-the-Wild Age Database," 2017 IEEE Conference on Computer Vision and Pattern Recognition Workshops (CVPRW), 2017, pp. 1997-2005, doi: 10.1109/CVPRW.2017.250.
https://ibug.doc.ic.ac.uk/media/uploads/documents/agedb.pdf
【関連する外部ページ】
【関連項目】 顔認識 (face recognition), 顔のデータベース
イメージ・マッティング (image matting) のデータセット. 3種類の前景(Salient Opaque, Salient Transparent/Meticulous, Non-Salient)を含む 500枚の画像について,元画像と alpha matte と Trimap のデータセットである.
次の URL で公開されているデータセット(オープンデータ)である.
URL: https://drive.google.com/drive/folders/1IyPiYJUp-KtOoa-Hsm922VU3aCcidjjz
【文献】
Jizhizi Li, Jing Zhang, DaCheng Tao, Deep Automatic Natural Image Matting, CoRR, abs/2107.07235v1, 2021.
https://arxiv.org/pdf/2107.07235v1.pdf
【関連する外部ページ】
【関連用語】 イメージ・マッティング (image matting), オープンデータ (open data)
AlexeyAB darknet は,YOLOv2, YOLOv3, YOLOv4 の機能などを持つ.
【文献】
Chien-Yao Wang, Alexey Bochkovskiy, Hong-Yuan Mark Liao, Scaled-YOLOv4: Scaling Cross Stage Partial Network, Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) 2021, pp. 13029-13038, also CoRR, Scaled-YOLOv4: Scaling Cross Stage Partial Network, 2021.
https://arxiv.org/pdf/2011.08036v2.pdf
【サイト内の関連ページ】
AlexryAB/darknet のインストールと動作確認(Scaled YOLO v4 による物体検出)(Windows 上)
【関連する外部ページ】
【関連項目】 YOLOv3, YOLOv4, RetinaNet, 物体検出
AlexNet の場合
input 3@224x224 conv 11x11 96@55x55 pooling conv 5x5 256@27x27 pooling 16@5x5 conv 3x3 384@13x13 conv 3x3 384@13xx13 conv 3x3 256@13x13 affine 4096 affine 4096 1000
参考文献: ch08/deep=cnvnet.py
AltCLIP の特徴は, CLIP のテキストエンコーダ (text encoder) を 学習済みの多言語のテキストエンコーダ XLM-R で置き換えたこと.
【文献】
Zhongzhi Chen, Guang Liu, Bo-Wen Zhang, Fulong Ye, Qinghong Yang, Ledell Wu, AltCLIP: Altering the Language Encoder in CLIP for Extended Language Capabilities, arXiv:2211.06679, 2022.
【関連項目】 CLIP
機械学習による物体検出では, 「AP」は,「average precision」の意味である.
Apache Hadoop は,並列処理のための MapReduce という機構を持つ.これは,Hadoop の分散ファイルシステム (Hadoop Distributed File System; HDFS) 上で動く.MapReduce とは,アプリケーションが,多数の小さな処理単位 (block) に分割するための機構である.分散ファイルシステムは, データブロック (data block) 単位での複製を作り,クラスタを構成するノード上に配置する.
Ubuntu での Apache Hadoop のインストール: 別ページ »で説明している.
「Applications of Deep Neural Networks」は,ディープラーニングに関するテキスト. ニューラルネットワーク, CNN (convolutional neural network), LSTM (Long Short-Term Memory), GRU (Gated Recurrent Neural Networks), GAN (Generative Adversarial Network), 強化学習とその応用について学ぶことができる. Python, TensorFlow, Keras を使用している.
【関連する外部ページ】
【関連項目】 CNN (convolutional neural network), GAN (Generative Adversarial Network), GRU (Gated Recurrent Neural Networks), Keras, LSTM (Long Short-Term Memory), TensorFlow, ディープラーニング ニューラルネットワーク, 強化学習
距離学習の1手法である. 分類モデルが特徴ベクトルを生成するための複数の層と,最終層の softmax から構成されているとき, その分類モデルでの,特徴ベクトルを生成するための複数の層の出力に対して, L2 正規化の処理と,Angular Magin Penalty 層による処理を追加し,softmax 層につなげる.
deepface, InsightFace などで実装されている.
【文献】
Jiankang Deng, Jia Guo, Niannan Xue, Stefanos Zafeiriou, ArcFace: Additive Angular Margin Loss for Deep Face Recognition, CVPR 2019, also CoRR, abs/1801.07698v3, 2019.
https://arxiv.org/pdf/1801.07698v3.pdf
【関連する外部ページ】
【関連項目】 deepface, InsightFace, 顔検証 (face verification), 顔識別 (face identification), 顔認識 (face recognition), 顔に関する処理
asteroid は,音源分離(audio source separation)のツールキット.
【文献】
Ryosuke Sawata, Stefan Uhlich, Shusuke Takahashi, Yuki Mitsufuji, All for One and One for All: Improving Music Separation by Bridging Networks, CoRR, abs/2010.04228v4, 2021.
PDF: https://arxiv.org/pdf/2010.04228v4.pdf
【関連する外部ページ】
【関連用語】 audio source seperation, music source separation, speech enhancement
asteroid のインストールと動作確認(音源分離)(Python,PyTorch を使用)(Windows 上): 別ページ »で説明している.
公式の手順 https://github.com/asteroid-team/asteroid による.
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
%cd /content !rm -rf asteroid !git clone https://github.com/asteroid-team/asteroid %cd asteroid !python3 setup.py develop !pip3 install -r requirements.txt
Spatio-Temporal Action Recognition の一手法.2016年発表
Gu, Chunhui and Sun, Chen and Ross, David A and Vondrick, Carl and Pantofaru, Caroline and Li, Yeqing and Vijayanarasimhan, Sudheendra and Toderici, George and Ricco, Susanna and Sukthankar, Rahul and others, Ava: A video dataset of spatio-temporally localized atomic visual actions, Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 6047--6056, 2018.
【関連項目】 MMAction2, Spatio-Temporal Action Recognition, 動作認識 (action recognition)
Bark は Transformer ベースの音声合成の技術.多言語に対応.
【サイト内の関連ページ】
【関連する外部ページ】
【関連項目】 VALL-E X
BASNet は, ディープラーニングにより,Salient Object Detection (顕著オブジェクトの検出)を行う一手法.2019年発表.
BASNet は次の2つのモジュールから構成される.
入力画像から saliency map を生成する. U-Net に類似の構造を持つ,教師有りの Encoder-Decoder ネットワークである. この段階での saliency map は,粗い (coarse) ものである.
Predict Module が生成した saliency map をリファイン (refine) する. Residual Refinement Module は Predict Module が生成した saliency map と,正解 (ground truth) との残差 (residuals) を学習する.
Salient Object Detection は, 視覚特性の異なるオブジェクトを,画素単位で切り出す. 前景と背景の分離に役立つ場合がある.人間がマスクの指定や塗り分け(Trimap など)を行うことなく実行される.
【文献】
Qin, Xuebin and Zhang, Zichen and Huang, Chenyang and Gao, Chao and Dehghan, Masood and Jagersand, Martin, BASNet: Boundary-Aware Salient Object Detection, The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2019
【関連する外部ページ】
【関連用語】 U-Net, U2-Net, salient object detection, セマンティック・セグメンテーション (semantic segmentation)
BASNet のインストールとテスト実行(顕著オブジェクトの検出)(Python,PyTorch を使用)(Windows 上): 別ページ »で説明している.
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
BASNet のテストプログラムのオンライン実行を行うまでの手順を示す.
!git clone https://github.com/NathanUA/BASNet.git
公式ページ https://github.com/xuebinqin/BASNet の指示による. 学習済みモデル(ファイル名 basenet.pth)は,次で公開されている. ダウンロードし,saved_models/basnet_bsi の下に置く
https://drive.google.com/open?id=1s52ek_4YTDRt_EOkx1FS53u-vJa0c4nu
%cd BASNet !curl -L https://github.com/opencv/opencv/blob/master/samples/data/fruits.jpg?raw=true -o fruits.jpg !curl -L https://github.com/opencv/opencv/blob/master/samples/data/home.jpg?raw=true -o home.jpg !curl -L https://github.com/opencv/opencv/blob/master/samples/data/squirrel_cls.jpg?raw=true -o squirrel_cls.jpg from PIL import Image Image.open('fruits.jpg').show() Image.open('home.jpg').show() Image.open('squirrel_cls.jpg').show()
%cd BASNet !python basnet_test.py
物体検出, instance segmentaion, multi object tracking, segmentation trackling, セマンティック・セグメンテーション (semantic segmentation), lane marking,l pose estimation 等の用途を想定したデータセット
【関連項目】 物体検出, instance segmentaion, multi object tracking, segmentation trackling, セマンティック・セグメンテーション (semantic segmentation), lane marking, pose estimation
Windows での BDD100K Images, Detection 2020 Labels, Pose Estimation Labels の展開手順は次の通り.
BDD100K を image tagging, 物体検出 (object detection), pose estimation に用いることを想定.
BDD100K のデータセットの準備の説明ページ(公式): https://github.com/SysCV/bdd100k-models/blob/main/doc/PREPARE_DATASET.md
copy bdd100k_images_100k.zip %LOCALAPPDATA% copy bdd100k_labels_release.zip %LOCALAPPDATA% copy bdd100k_pose_labels_trainval.zip %LOCALAPPDATA% cd %LOCALAPPDATA% powershell -command "Expand-Archive -DestinationPath . -Path bdd100k_images_100k.zip" powershell -command "Expand-Archive -DestinationPath . -Path bdd100k_labels_release.zip" powershell -command "Expand-Archive -DestinationPath . -Path bdd100k_pose_labels_trainval.zip"
└─bdd100k | └── images ├── test ├── train └── val | └─labels ├──bdd_labels_images_train.json ├──bdd_labels_images_val.json └─ pose21
Windows での BDD100K Images, Detection 2020 Labels, Pose Estimation Labels の展開手順は次の通り.
BDD100K を image tagging, 物体検出 (object detection), pose estimation に用いることを想定.
BDD100K のデータセットの準備の説明ページ(公式): https://github.com/SysCV/bdd100k-models/blob/main/doc/PREPARE_DATASET.md
sudo cp bdd100k_images_100k.zip /usr/local sudo cp bdd100k_labels_release.zip /usr/local sudo cp bdd100k_pose_labels_trainval.zip /usr/local cd /usr/local sudo 7z x bdd100k_images_100k.zip sudo 7z x bdd100k_labels_release.zip sudo 7z x bdd100k_pose_labels_trainval.zip sudo chown -R $USER bdd100k
cd /usr/local sudo rm -rf bdd100k-models sudo git clone https://github.com/SysCV/bdd100k-models sudo chown -R $USER bdd100k-models cd bdd100k-models sed -i -e 's/git+git/git+https/g' requirements.txt sudo pip3 install -U -r requirements.txt sudo python3 det/setup.py install sudo python3 drivable/setup.py install sudo python3 ins_seg/setup.py install sudo python3 pose/setup.py install sudo python3 sem_seg/setup.py install sudo python3 tagging/setup.py install cd /usr/local mkdir bdd100k\jsons python3 -m bdd100k.label.to_coco -m pose \ -i bdd100k/labels/pose_21/pose_train.json \ -o bdd100k/jsons/pose_train_cocofmt.json python3 -m bdd100k.label.to_coco -m pose \ -i bdd100k/labels/pose_21/pose_val.json \ -o bdd100k/jsons/pose_val_cocofmt.json
└─bdd100k | └── images ├── test ├── train └── val | └─labels ├──bdd_labels_images_train.json ├──bdd_labels_images_val.json └─ pose21
【関連項目】 Residual Networks (ResNets)
BioID 顔データベースは,23名, 1521枚のモノクロの画像.解像度は 384x286 である.目の位置に関するデータを含む.
BioID 顔データベースは次の URL で公開されているデータセット(オープンデータ)である.
BLAS の主な機能(ごく一部を紹介)
Blenderは,3次元コンピュータグラフィックス・アニメーションソフトウェアである. 3次元モデルの編集,レンダリング,光源やカメラ等を設定しての3次元コンピュータグラフィックス・アニメーション作成機能がある.
【関連項目】 bpy (blenderpy), yuki-koyama の blender-cli-rendering
Windows での Blender のインストールは,複数の方法がある.
Ubuntu での Blender のインストールは,別ページ »で説明している.
次の動画は,Blender のモーショントラッキング機能を用いた映像作成について説明している.
https://www.youtube.com/watch?v=lY8Ol2n4o4A
次の動画は,作成された映像,グリーンバックの映像である.
https://www.youtube.com/watch?v=FFJ_THGj72U
BM3D image denosing の公式ソースコード(GitHub のページ): https://github.com/gfacciol/bm3d
【関連項目】 image denosing
Boost は, C++ のライブラリ.
Boost の URL: https://www.boost.org/
Windows での Boost 1_83 のインストールとテスト実行(ソースコードを使用): 別ページ »で説明している.
Ubuntu でインストールを行うには,次のコマンドを実行.
sudo apt -y update sudo apt -y install libboost-all-dev
Boston housing price 回帰データセットは,次のプログラムでロードできる.
【Keras のプログラム】
from tensorflow.keras.datasets import boston_housing (x_train, y_train), (x_test, y_test) = boston_housing.load_data()
【関連項目】 Keras に付属のデータセット
ディープラーニングによる物体検出のための学習と検証では, アノテーションとして,物体のバウンディングボックスが広く用いられている.
ディープラーニングによるインスタンス・セグメンテーション (instance segmentation)でも, Tian らの BoxInst (2021年発表) のように,画素単位でのアノテーションでなく, バウンディングボックスを用いる手法が登場している.
【関連項目】 インスタンス・セグメンテーション (instance segmentation), バウンディングボックス, 物体検出,
bpy (blenderpy) では,Blender がPython モジュールになっている.
【関連項目】 Blender yuki-koyama の blender-cli-rendering
PyPI を用いてのインストールでは,2021年12月時点では,使用する Python はバージョン 3.7,Blender は 2.8. 新しい Blender の Python モジュールを必要する場合には,下の項目を見ること.
https://pypi.org/project/bpy/ の記載により,PyPI の bpy (blenderpy) のインストールを行う.
「-3.7」のところには, いま確認した Python のバージョンを指定する.
「-3.7」のところには, いま確認した Python のバージョンを指定する.
エラーメッセージが出ていなければ OK.
py -3.7 -c "import bpy"
詳しくは,別ページ »で説明
Git の公式ページ: https://git-scm.com/
CMake の公式ダウンロードページ: https://cmake.org/download/
SlikSVN のページ: https://sliksvn.com/
インストールしたい Blender のバージョンにあう Blender のタグを,次のページで探す.
「v3.0.1」のところには,使用したいバージョンの Blender のタグを指定すること.
cd %LOCALAPPDATA% rmdir /s /q blender git clone -b v3.0.1 https://github.com/blender/blender
Visual Studio Community 2022 を使うときは「make update 2022」,「make release 2022」 を実行.
終了まで時間がかかるので,しばらく待つ
cd %LOCALAPPDATA% cd blender make update 2022b make release 2022b
「c:\Program Files\Python39」のところは, Python のインストールディレクトリを指定すること.
python -m pip install numpy cd %LOCALAPPDATA%\blender\build\release copy bin\bpy.pyd c:\Program Files\Python39\Lib\site-packages\ copy bin\*.dll c:\Program Files\Python39\Lib\site-packages\ del c:\Program Files\Python39\Lib\site-packages\python36.dll xcopy /E bin\3.0 c:\Program Files\Python39\
コマンドプロンプトで次のコマンドを実行する.
エラーメッセージが出なければ OK.
python -c "import bpy; scene = bpy.data.scenes['Scene']; print(scene)"
Build Tools for Visual Studio 2019(ビルドツール for Visual Studio 2019)は,Windows で動くMicrosoft の C++ コンパイラーである.
(例)cl hello.c
「cl hello.c」でコンパイルしたときは「hello.exe」ファイルができるので確認
#pragma warning(disable: 4996)
【サイト内の関連ページ】
【関連する外部ページ】
Build Tools for Visual Studio 2022(ビルドツール for Visual Studio 2022)は,Windows で動くMicrosoft の C++ コンパイラーである.
(例)cl hello.c
「cl hello.c」でコンパイルしたときは「hello.exe」ファイルができるので確認
#pragma warning(disable: 4996)
【サイト内の関連ページ】
Windows での Build Tools for Visual Studio 2022(ビルドツール for Visual Studio 2022)のインストール: 別ページ »で説明している.
【関連する外部ページ】
Build Tools for Visual Studio 2022 (ビルドツール for Visual Studio 2022)の公式ダウンロードページ: https://visualstudio.microsoft.com/ja/visual-cpp-build-tools/
正しくマスクが装着された状態の顔の写真 (CMFD) と, 正しくマスクが装着されていない状態の顔の写真 (IMFD) のデータセット.
文献
Adnane Cabani and Karim Hammoudi and Halim Benhabiles and Mahmoud Melkemi, MaskedFace-Net -- A Dataset of Correctly/Incorrectly Masked Face Images in the Context of COVID-19, Smart Health, 2020.
Science Direct: https://www.sciencedirect.com/science/article/pii/S2352648320300362?via%3Dihub
【サイト内の関連ページ】
chandrikadeb7 / Face-Mask-Detection のインストールと動作確認(マスク有り顔,マスクなし顔の検出)(Python,TensorFlow を使用)(Windows 上): 別ページ »で説明している.
【関連する外部ページ】
公式 URL: https://github.com/cabani/MaskedFace-Net
【関連項目】 顔のデータベース, 顔検出 (face detection)
Caffe 2 のインストール
【関連する外部ページ】
Caltech Pedestrian データセット は,都市部を走行中の車両から撮影したデータ. 機械学習による物体検出 の学習や検証に利用できるデータセットである.
Caltech Pedestrian データセットは次の URL で公開されているデータセット(オープンデータ)である.
URL: http://www.vision.caltech.edu/datasets/
【関連情報】
Ceres ソルバ(Ceres Solver)は,非線形の最適化の機能をもったソフトウェア.
公式ページ: http://ceres-solver.org/
【文献】
Agarwal, Sameer and Mierle, Keir and The Ceres Solver Team, Ceres Solver, https://github.com/ceres-solver/ceres-solver, 2022.
Windows での Ceres ソルバ(Ceres Solver) のインストール: 別ページ »で説明している.
Ceres ソルバ(Ceres Solver) 2.1.0 の非公式ビルド: ceres-solver.zip
私がビルドしたもの,非公式,無保証, https://github.com/ceres-solver/ceres-solver で公開されているソースコードを改変せずにビルドした. Windows 10, Visual Build Tools for Visual Studio 2022 を用いてビルドした. 作者が定めるライセンス https://github.com/ceres-solver/ceres-solver/blob/master/LICENSE による.
zip ファイルは C:\ 直下で展開し,C:\ceres-solver での利用を想定.
Places365 データセットを用いた事前学習済みモデルと, それを利用した,画像分類,image tagging, Class Activation Mapping (CAM) のプログラムが公開されている.
CASILVision の Place365 を使用. 公開されているプログラムは,次の手順で実行できる. 画像分類の結果は, 「0.511 -> food_court, 0.085 -> fastfood_restaurant, 0.083 -> cafeteria, 0.040 -> dining_hall, 0.021 -> flea_market/indoor」のように表示される.
image tagging では, 「no horizon, enclosed area, man-made, socializing, indoor lighting, cloth, congregating, eating, working」 のように,屋内であるか屋外であるかのタグなどが得られる.
!rm -rf places365 !git clone https://github.com/CSAILVision/places365 %cd places365 !python3 run_placesCNN_unified.py from PIL import Image Image.open('cam.jpg').show()
Large-scale CelebFaces Attributes (CelebA) データセットは,顔画像とアノテーションのデータ. 機械学習による顔検出,顔ランドマーク (facial landmark),顔認識,顔の生成などの学習や検証に利用できるデータセットである.
Large-scale CelebFaces Attributes (CelebA) データセットは次の URL で公開されているデータセット(オープンデータ)である.
URL: https://mmlab.ie.cuhk.edu.hk/projects/CelebA.html
【関連情報】
Deep Learning Face Attributes in the Wild, Ziwei Liu, Ping Luo, Xiaogang Wang, Xiaoou Tang, ICCV 2015.
【関連項目】 顔のデータベース, 顔ランドマーク (facial landmark)
マルチモーダル名前付きエンティティ認識(Multimodal Named Entity Recognition; MNER)およびマルチモーダル関係抽出(Multimodal Relation Extraction; MRE)の改善に注力し、これらの分野における精度向上を目指している。この目的のために、Chain of Thought(CoT)プロンプトを活用し、大規模言語モデル(LLM)から reasoning を抽出している。論文の手法は、名詞、文、マルチモーダルの観点からの多粒度の推論と、スタイル、エンティティ、画像を含むデータ拡張を網羅している。これにより、LLMからの reasoning をより効果的に抽出している。MNERの有効性を評価するために、Twitter2015、Twitter2017、SNAP、WikiDiverseという様々なデータセットを使用し、提案方法の効果を検証している。
【文献】
Feng Chen, Yujian Feng, Chain-of-Thought Prompt Distillation for Multimodal Named Entity Recognition and Multimodal Relation Extraction, arXiv:2306.14122v3, 2023.
https://arxiv.org/pdf/2306.14122v3.pdf
【関連する外部ページ】
CityGML は,3次元の都市,3次元の景観を扱う機能を持つデータフォーマット. 次のようなモジュールがある.
Appearance, Bridge, Building, CityFurniture, LandUse, Relief, Transportation, Tunnel, Vegetation, Vegetation, WaterBody, TexturedSurface
CityGML の公式情報は,Open Geospatial Consortium のページで公開されている.
Open Geospatial Consortium の CityGML ページ: https://www.ogc.org/standards/citygml
CityGML の仕様書も,このページで公開されている.
CityGML のビューワには FZKViewer がある. Windows での FZKViewer のインストールは 別ページ »で説明している.
【関連項目】 FZKViewer
CSAILVision の公式デモ(GitHub のページ): https://colab.research.google.com/github/CSAILVision/semantic-segmentation-pytorch/blob/master/notebooks/DemoSegmenter.ip
【関連項目】 セマンティック・セグメンテーション (semantic segmentation)
Windows での cgal のインストール(Windows 上): 別ページ »で説明している.
Ubuntu でインストールを行うには,次のコマンドを実行.
sudo apt -y update sudo apt -y install libcgal-dev libcgal-qt5-dev
写真やビデオから,マスクありの顔と,マスク無しの顔を検出する技術およびソフトウェア. 顔検出,マスク有りの顔とマスク無しの顔の分類を同時に行っている. MobileNetV2 (ディープニューラルネットワーク)を使用.
ソースコードは公開されており,画像を追加して学習をやり直すことも可能
Bing Search API, Kaggle dataset, RMDF dataset から収集された顔のデータセット(マスクあり: 2165 枚,マスクなし 1930 枚)が同封.
【関連する外部ページ】
【関連項目】 cabani の MaskedFace-Net データセット, Face Mask Detection, マスク付き顔の処理 顔検出 (face detection)
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
!rm -rf Face-Mask-Detection !git clone https://github.com/chandrikadeb7/Face-Mask-Detection %cd Face-Mask-Detection !pip3 install -U -r requirements.txt
Chandrika Deb の顔マスク検出に同封のデータセット(Deb Bing Search API, Kaggle dataset, RMDF dataset から収集された顔のデータセット(マスクあり: 2165 枚,マスクなし 1930 枚)により学習を行う.
!python3 train_mask_detector.py --dataset dataset
!sed -i -e 's/cv2.imshow("Output", image)/cv2.imwrite("result.png", image)/g' detect_mask_image.py !sed -i -e 's/cv2.waitKey(0)//g' detect_mask_image.py !python3 detect_mask_image.py --image images/pic1.jpeg from PIL import Image Image.open('result.png').show()
curl は URL を指定して画像ファイルをダウンロードしている.
!curl -O https://www.kkaneko.jp/sample/face/3284.png !python3 detect_mask_image.py --image 3284.png from PIL import Image Image.open('result.png').show()
!curl -O https://www.kkaneko.jp/sample/face/3288.png !python3 detect_mask_image.py --image 3288.png from PIL import Image Image.open('result.png').show()
chandrikadeb7 / Face-Mask-Detection のインストールと動作確認(マスク有り顔,マスクなし顔の検出)(Python,TensorFlow を使用)(Windows 上): 別ページで説明
前準備:事前に Python のインストール: 別項目で説明している., NVIDIA CUDA ツールキット,NVIDIA cuDNN のインストール: 別項目で説明している.を行うこと.
sudo apt -y update sudo apt -y install git cd /usr/local sudo rm -rf Face-Mask-Detection sudo git clone https://github.com/chandrikadeb7/Face-Mask-Detection sudo chown -R $USER Face-Mask-Detection # システム Python の環境とは別の Python の仮想環境(システム Python を使用)を作成 sudo apt -y update sudo apt -y install python3-venv python3 -m venv ~/a source ~/a/bin/activate cd /usr/local/Face-Mask-Detection pip install -U -r requirements.txt pip list
Chandrika Deb の顔マスク検出に同封のデータセット(Deb Bing Search API, Kaggle dataset, RMDF dataset から収集された顔のデータセット(マスクあり: 2165 枚,マスクなし 1930 枚)により学習を行う. その後,顔マスク検出を行う.
source ~/a/bin/activate cd /usr/local/Face-Mask-Detection python train_mask_detector.py --dataset dataset
「python detect_mask_video.py 」はカメラの顔マスク検出を行う.
python detect_mask_image.py --image images/pic1.jpeg python detect_mask_video.py
画像補正は,画像を射影変換することにより,斜め方向からの撮影画像を正面画像に変換する. 意図しないカメラ回転(ロール、ピッチ、ヨー)を含む画像を正面画像に補正できる.
また,AIの事前学習は,通常,正面画像で行われることが多く,画像補正を使うことで,AIの推論をより精度よく行うことができると期待できる.
【文献】
Chaudhury, Krishnendu, Stephen DiVerdi, and Sergey Ioffe. "Auto-rectification of user photos." 2014 IEEE International Conference on Image Processing (ICIP). IEEE, 2014.
【資料】
【サイト内の関連ページ】
【関連する外部ページ】
GitHub のページ: https://github.com/chsasank/Image-Rectification
CIFAR-10 データセット(Canadian Institute for Advanced Research, 10 classes)は,公開されているデータセット(オープンデータ)である.
CIFAR-10 データセット(Canadian Institute for Advanced Research, 10 classes) は,クラス数 10 の カラー画像と,各画像に付いたのラベルから構成されるデータセットである. 機械学習での画像分類の学習や検証に利用できる.
(内訳)60000枚の内訳は次の通りである
50000枚:教師データ
10000枚:検証データ
【文献】
Alex Krizhevsky, Vinod Nair, and Geoffrey Hinton. 'Learning multiple layers of features from tiny images', Alex Krizhevsky, 2009.
【サイト内の関連ページ】
【関連する外部ページ】
【関連項目】 CIFAR-100 データセット(Canadian Institute for Advanced Research, 100 classes), Keras に付属のデータセット, TensorFlow データセット, オープンデータ, 画像分類
次の Python プログラムは,TensorFlow データセットから,CIFAR-10 データセットのロードを行う. x_train, y_train が学習用のデータ.x_test, y_test が検証用のデータになる.
次のプログラムでは、x_train と y_train を 25枚分表示することにより,x_train と y_train が,画像であることが確認できる.
tensorflow_datasets の loadで, 「batch_size = -1」を指定して,一括読み込みを行っている.
from __future__ import absolute_import, division, print_function, unicode_literals import tensorflow as tf import numpy as np import tensorflow_datasets as tfds %matplotlib inline import matplotlib.pyplot as plt import warnings warnings.filterwarnings('ignore') # Suppress Matplotlib warnings # CIFAR-10 データセットのロード cifar10, cifar10_metadata = tfds.load('cifar10', with_info = True, shuffle_files=True, as_supervised=True, batch_size = -1) x_train, y_train, x_test, y_test = cifar10['train'][0], cifar10['train'][1], cifar10['test'][0], cifar10['test'][1] plt.style.use('default') plt.figure(figsize=(10,10)) for i in range(25): plt.subplot(5,5,i+1) plt.xticks([]) plt.yticks([]) plt.grid(False) # squeeze は,サイズ1の次元を削除.numpy は tf.Tensor を numpy に変換 plt.imshow(np.squeeze(x_train[i]), cmap=plt.cm.binary) plt.xlabel(y_train[i].numpy()) # 確認表示 plt.show()
次の Python プログラムは,Keras に付属のデータセットの中にある CIFAR-10 データセットのロードを行う. x_train, y_train が学習用のデータ.x_test, y_test が検証用のデータになる.
次のプログラムでは,x_train と y_train を 25枚分表示することにより,x_train と y_train が,カラー画像であることが確認できる.
import tensorflow.keras from tensorflow.keras.datasets import cifar10 %matplotlib inline import matplotlib.pyplot as plt import warnings warnings.filterwarnings('ignore') # Suppress Matplotlib warnings # CIFAR-10 データセットのロード (x_train, y_train), (x_test, y_test) = cifar10.load_data() plt.style.use('default') plt.figure(figsize=(10,10)) for i in range(25): plt.subplot(5,5,i+1) plt.xticks([]) plt.yticks([]) plt.grid(False) plt.imshow(x_train[i], cmap=plt.cm.binary) plt.xlabel(y_train[i]) # 確認表示 plt.show()
次の Python プログラムは,TensorFlow データセットから,CIFAR-10 データセットのロードを行う. x_train, y_train が学習用のデータ.x_test, y_test が検証用のデータになる.
次のプログラムでは、x_train と y_train を 25枚分表示することにより,x_train と y_train が,画像であることが確認できる.
tensorflow_datasets の loadで, 「batch_size = -1」を指定して,一括読み込みを行っている.
ロードの後,正規化を行う.type は型,shape はサイズ,np.max と np.mi は最大値と最小値.
from __future__ import absolute_import, division, print_function, unicode_literals import tensorflow as tf import numpy as np import tensorflow_datasets as tfds %matplotlib inline import matplotlib.pyplot as plt import warnings warnings.filterwarnings('ignore') # Suppress Matplotlib warnings # CIFAR-10 データセットのロード cifar10, cifar10_metadata = tfds.load('cifar10', with_info = True, shuffle_files=True, as_supervised=True, batch_size = -1) x_train, y_train, x_test, y_test = cifar10['train'][0], cifar10['train'][1], cifar10['test'][0], cifar10['test'][1] plt.style.use('default') plt.figure(figsize=(10,10)) for i in range(25): plt.subplot(5,5,i+1) plt.xticks([]) plt.yticks([]) plt.grid(False) # squeeze は,サイズ1の次元を削除.numpy は tf.Tensor を numpy に変換 plt.imshow(np.squeeze(x_train[i]), cmap=plt.cm.binary) plt.xlabel(y_train[i].numpy()) # 確認表示 plt.show() # メタデータの表示 print(cifar10_metadata) # 正規化 # 【x_train, x_test, y_train, y_test の numpy ndarray への変換と,値の範囲の調整(値の範囲が 0 〜 255 であるのを,0 〜 1 に調整)】 x_train = x_train.numpy().astype("float32") / 255.0 x_test = x_test.numpy().astype("float32") / 255.0 y_train = y_train.numpy() y_test = y_test.numpy() print(type(x_train), x_train.shape, np.max(x_train), np.min(x_train)) print(type(x_test), x_test.shape, np.max(x_test), np.min(x_test)) print(type(y_train), y_train.shape, np.max(y_train), np.min(y_train)) print(type(y_test), y_test.shape, np.max(y_test), np.min(y_test))
CIFAR-100 データセット(Canadian Institute for Advanced Research, 100 classes)は,公開されているデータセット(オープンデータ)である.
CIFAR-100 データセット(Canadian Institute for Advanced Research, 100 classes) は,機械学習での画像分類の学習や検証に利用できるデータセット.
(内訳)60000枚の内訳は次の通りである
50000枚:教師データ
10000枚:検証データ
【文献】
Alex Krizhevsky, Vinod Nair, and Geoffrey Hinton. Learning multiple layers of features from tiny images, Alex Krizhevsky, 2009.
【サイト内の関連ページ】
【関連する外部ページ】
【関連項目】 CIFAR-10 データセット(Canadian Institute for Advanced Research, 10 classes), Keras に付属のデータセット, TensorFlow データセット, オープンデータ, 画像分類
次の Python プログラムは,TensorFlow データセットから,CIFAR-100 データセットのロードを行う. x_train, y_train が学習用のデータ.x_test, y_test が検証用のデータになる.
次のプログラムでは、x_train と y_train を 25枚分表示することにより,x_train と y_train が,画像であることが確認できる.
tensorflow_datasets の loadで, 「batch_size = -1」を指定して,一括読み込みを行っている.
from __future__ import absolute_import, division, print_function, unicode_literals import tensorflow as tf import numpy as np import tensorflow_datasets as tfds %matplotlib inline import matplotlib.pyplot as plt import warnings warnings.filterwarnings('ignore') # Suppress Matplotlib warnings # CIFAR-100 データセットのロード cifar100, cifar100_metadata = tfds.load('cifar100', with_info = True, shuffle_files=True, as_supervised=True, batch_size = -1) x_train, y_train, x_test, y_test = cifar100['train'][0], cifar100['train'][1], cifar100['test'][0], cifar100['test'][1] plt.style.use('default') plt.figure(figsize=(10,10)) for i in range(25): plt.subplot(5,5,i+1) plt.xticks([]) plt.yticks([]) plt.grid(False) # squeeze は,サイズ1の次元を削除.numpy は tf.Tensor を numpy に変換 plt.imshow(np.squeeze(x_train[i]), cmap=plt.cm.binary) plt.xlabel(y_train[i].numpy()) # 確認表示 plt.show()
次の Python プログラムは,TensorFlow データセットから,CIFAR-100 データセットのロードを行う. x_train, y_train が学習用のデータ.x_test, y_test が検証用のデータになる.
次のプログラムでは、x_train と y_train を 25枚分表示することにより,x_train と y_train が,画像であることが確認できる.
tensorflow_datasets の loadで, 「batch_size = -1」を指定して,一括読み込みを行っている.
ロードの後,正規化を行う.type は型,shape はサイズ,np.max と np.mi は最大値と最小値.
from __future__ import absolute_import, division, print_function, unicode_literals import tensorflow as tf import numpy as np import tensorflow_datasets as tfds %matplotlib inline import matplotlib.pyplot as plt import warnings warnings.filterwarnings('ignore') # Suppress Matplotlib warnings # CIFAR-100 データセットのロード cifar100, cifar100_metadata = tfds.load('cifar100', with_info = True, shuffle_files=True, as_supervised=True, batch_size = -1) x_train, y_train, x_test, y_test = cifar100['train'][0], cifar100['train'][1], cifar100['test'][0], cifar100['test'][1] plt.style.use('default') plt.figure(figsize=(10,10)) for i in range(25): plt.subplot(5,5,i+1) plt.xticks([]) plt.yticks([]) plt.grid(False) # squeeze は,サイズ1の次元を削除.numpy は tf.Tensor を numpy に変換 plt.imshow(np.squeeze(x_train[i]), cmap=plt.cm.binary) plt.xlabel(y_train[i].numpy()) # 確認表示 plt.show() # メタデータの表示 print(cifar100_metadata) # 正規化 # 【x_train, x_test, y_train, y_test の numpy ndarray への変換と,値の範囲の調整(値の範囲が 0 〜 255 であるのを,0 〜 1 に調整)】 x_train = x_train.numpy().astype("float32") / 255.0 x_test = x_test.numpy().astype("float32") / 255.0 y_train = y_train.numpy() y_test = y_test.numpy() print(type(x_train), x_train.shape, np.max(x_train), np.min(x_train)) print(type(x_test), x_test.shape, np.max(x_test), np.min(x_test)) print(type(y_train), y_train.shape, np.max(y_train), np.min(y_train)) print(type(y_test), y_test.shape, np.max(y_test), np.min(y_test))
Cityscapes データセット は,車両と人が撮影されたアノテーション済の画像データ. 機械学習での セマンティック・セグメンテーション (semantic segmentation), インスタンス・セグメンテーション (instance segmentation) に利用できるデータセットである.
Cityscapes データセットは, 50都市の数ヶ月間(春,夏,秋)の日中,良好な/中程度の天候のもとで撮影,計測されたデータである.データの種類は次の通りである.
画像数は,合計で,24998 枚であり,その内訳は次のとおりである.
クラスは次の通りである.これらクラス以外に「unlabeled」がある.
road, sidewalk, parking, rail track, person, rider, car, truck, bus, on rails, motorcycle, bicycle, caravan, trailer, building, wall, fence, guard rail, bridge, tunnel, pole, pole group, traffic sign, traffic light, vegetation, terrain, sky, ground, dynamic, static
これらクラスは,次のようにグループ化されている. (flat などがグループ名である).
クラスの説明は次のページにある.
Cityscapes データセットは次の URL で公開されているデータセット(オープンデータ)である.利用には登録が必要である.
https://www.cityscapes-dataset.com/
【関連情報】
Marius Cordts, Mohamed Omran, Sebastian Ramos, Timo Rehfeld, Markus Enzweiler, Rodrigo Benenson, Uwe Franke, Stefan Roth, Bernt Schiele, The Cityscapes Dataset for Semantic Urban Scene Understanding, CVPR 2016, also CoRR abs/1604.01685, 2016.
【関連項目】 Detectron2, MMSegmentation, OpenMMLab, PANet
Cityscapes データセットの train and val と test は,合計で 5000枚の画像と関連データである.
train and val と test の Ground Truth と画像のダウンロードのため, gtFine,leftImg8bit のダウンロードを行うときは, Cityscapes データセットのダウンロードのページで,次を選ぶ. (必要最小限のダウンロードを行うこと).
Cityscape データセットのページ: https://www.cityscapes-dataset.com/
Clang は,LLVMのサブプロジェクトである. C言語ファミリ(C,C++,Objective C/C++,OpenCL,CUDA,RenderScript)の機能, GCC互換のコンパイラドライバ (clang) の機能, MSVC互換のコンパイラドライバ (clang-cl.exe) の機能を持つ.
【関連する外部ページ】
【サイト内の関連ページ】
【関連項目】 LLVM
clapack は,元々 FORTRAN で書かれていた LAPACK の,C言語版 (C 言語に書き直されたもの)である. lapack は,行列に関する種々の問題(連立1次方程式,固有値問題,などなど多数)を解く機能を持つソフトウェア.BLAS の機能を使う.
Windows での clapack のインストール(Windows 上): 別ページ »で説明している.
Class Activation Mapping (CAM) は, Bolei Zhou により,2016年に提案された.
Bolei Zhou Aditya Khosla Agata Lapedriza Aude Oliva Antonio Torralba, Learning Deep Features for Discriminative Localization, CVPR 2016, also CoRR, https://arxiv.org/abs/1512.04150v1, 2016.
【関連項目】 CASILVision
CRAFT は,文字検出の一手法.
【文献】 Youngmin Baek, Bado Lee, Dongyoon Han, Sangdoo Yun, and Hwalsuk Lee, Character Region Awareness for Text Detection, Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 9365--9374, 2019.
【関連する外部ページ】
GitHub のページ: https://github.com/clovaai/CRAFT-pytorch
【関連項目】 EasyOCR
CRAFT のインストールと動作確認(テキスト検出)(Python,PyTorch を使用)(Windows 上): 別ページ »で説明している.
crowd countingは, 画像内の人数を数えること. 監視等に役立つ. さまざま状況において, さまざまな大きさで画像内にある人物を数えることが課題であり, 画像からの物体検出とは研究課題が異なる.
【関連用語】 FIDTM, JHU-CROWD++ データセット, NWPU-Crowd データセット, ShanghaiTech データセット, UCF-QNRF データセット
CLIP(Contrastive Language-Image Pre-Training)では, テキスト画像のペアを用いて学習が行われる. GPT-2,GPT-3 のゼロショット学習 (zero-shot learning) のゼロショットと同様に, 画像に対して,テキストが結果として求まる. CLIP は,ImageNet データセット のゼロショットに対して, ResNet50と同等の性能があるとされる.
CLIP の GitHub のページ: https://github.com/openai/CLIP
CLIP のサンプルプログラムの実行結果は次の通り.
【関連項目】 AltCLIP
cmake は,ソフトウェアのソースコードからのビルドを簡単に行えるようにするためのソフトウェアである.
cmake のオプションは,Windows では cmake-gui コマンド,Ubuntu など linux 系では ccmake コマンドで確認できる.
cmake のジェネレータについて: 別ページ »で説明している.
cmake の使い方の例: 別ページ »で説明している.
CMake の公式ダウンロードページ: https://cmake.org/download/
Windows での cmake のインストールには,複数の方法がある.次のいずれかによりインストールできる.
詳しくは: 別ページ »で説明
このとき,ライセンス条項の確認を行う.
設定は,「Add CMake to the system PATH for all users」をチェックするのが使いやすい. 他の設定は既定(デフォルト)のままでよい.
winget をインストールしたのち,コマンドプロンプトを管理者として開き「winget install cmake」を実行.
その後,Windows のシステム環境変数 Path に「C:\Program Files\CMake\bin」を追加し,パスを通す.
Windows での環境変数の設定は,マイコンピュータを右クリック → プロパティ→ 詳細設定 → 環境変数をクリック
Windowsの画面の表示では、「\」(円マーク)が表示される
Ubuntu では,端末で,次のコマンドを実行して,cmake をインストールする.
sudo apt -y update sudo apt -y install cmake cmake-curses-gui cmake-gui
ソースコードからビルドする場合には,次のように操作する.
sudo apt -y update sudo apt -y install build-essential gcc g++ make sudo apt -y install git cmake cmake-curses-gui cmake-gui cd /tmp curl -L -O https://github.com/Kitware/CMake/releases/download/v3.22.2/cmake-3.22.2.tar.gz tar -xvzof cmake-3.22.2.tar.gz cd cmake-3.22.2 ./configure --prefix=/usr/local make sudo make install
C-MS-Celeb Cleaned データセット は, MS-Celeb-1M データセット を整えたもの.間違いの修正など.
人物数は 94,682 (94,682 identities), 画像数は 6,464,018 枚 (6,464,018 images)
次の URL で公開されているデータセット(オープンデータ)である.
https://github.com/EB-Dodo/C-MS-Celeb
Chi Jin, Ruochun Jin, Kai Chen, and Yong Dou, “A Community Detection Approach to Cleaning Extremely Large Face Database,” Computational Intelligence and Neuroscience, vol. 2018, Article ID 4512473, 10 pages, 2018. doi:10.1155/2018/4512473
【関連項目】 顔のデータベース, MS-Celeb-1M データセット, 顔検出 (face detection)
CNN (convolutional neural network) は畳み込みニューラルネットワークのこと.
COCO(Common Object in Context)データセットは,物体検出やセグメンテーション,キーポイント検出,姿勢推定,画像分類,キャプショニング等の多様なタスクに対応可能な画像データセットとして,2014年にMicrosoftにより公開された.これは,人間や自動車,家具,食品等,多岐にわたるカテゴリのオブジェクトを含む数十万枚以上の画像から構成され,それぞれの画像は,80種類のカテゴリに対応する形でアノテーションが施されている. COCO は次の URL で公開されているデータセット(オープンデータ)である.
COCO は,以下の特徴がある.
COCO の 80 のクラスのラベルは次の通りである.
['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush']
【文献】
Tsung-Yi Lin, Michael Maire, Serge Belongie, Lubomir Bourdev, Ross Girshick, James Hays, Pietro Perona, Deva Ramanan, C. Lawrence Zitnick, Piotr Dollr, Microsoft COCO: Common Objects in Context, CoRR, abs/1405.0312, 2014.
https://arxiv.org/pdf/1405.0312v3.pdf
【サイト内の関連ページ】
COCO 2017 データセットのダウンロードとカテゴリ情報や画像情報の確認(Windows 上): 別ページ »で説明している.
【関連する外部ページ】
【関連項目】 pycocotools, 物体検出, インスタンス・セグメンテーション (instance segmentation), keypoint detection, panoptic segmentation, セマンティック・セグメンテーション (semantic segmentation)
Windows での COCO 2014 のダウンロードと展開の手順は次の通り.
COCO データセットの公式ページ: https://cocodataset.org/#home
コマンドプロンプトを管理者として開き ダウンロードのため,次のコマンドを実行
cd %LOCALAPPDATA% curl -O http://images.cocodataset.org/zips/train2017.zip curl -O http://images.cocodataset.org/zips/val2014.zip curl -O http://images.cocodataset.org/zips/test2017.zip curl -O http://images.cocodataset.org/annotations/annotations_trainval2014.zip
cd %LOCALAPPDATA% powershell -command "Expand-Archive -DestinationPath . -Path train2014.zip" powershell -command "Expand-Archive -DestinationPath . -Path val2014.zip" powershell -command "Expand-Archive -DestinationPath . -Path test2014.zip" powershell -command "Expand-Archive -DestinationPath . -Path annotations_trainval2014.zip"
└── COCO_DATASET_ROOT | ├── annotations ├── stuff_train2014.json (the original json files) ├── stuff_test2014.json (the original json files) ├── stuff_val2014.json (the original json files) ├── train2014 ├── test2014 └── val2014
Ubuntu の場合.次により,/usr/local/mscoco2014, /usr/local/mscoco2017 にダウンロードされる.
`sudo mkdir cd /usr/local/coco2017 sudo chown -R $USER /usr/local/coco2017 cd /usr/local/coco2017 # labels curl -O -L https://github.com/ultralytics/yolov5/releases/download/v1.0/coco2017labels-segments.zip unzip coco2017labels-segments.zip cd /usr/local/coco2017 # 19G, 118k images curl -O http://images.cocodataset.org/zips/train2017.zip unzip -d /usr/local/coco2017/coco train2017.zip # 1G, 5k images curl -O http://images.cocodataset.org/zips/val2017.zip unzip -d /usr/local/coco2017/coco val2017.zip # 7G, 41k images (optional) curl -O http://images.cocodataset.org/zips/test2017.zip unzip -d /usr/local/coco2017/coco test2017.zip # curl -O http://images.cocodataset.org/annotations/annotations_trainval2017.zip unzip -d annotations_trainval2017.zip # curl -O http://images.cocodataset.org/annotations/stuff_annotations_trainval2017.zip unzip -d stuff_annotations_trainval2017.zip # curl -O http://images.cocodataset.org/annotations/panoptic_annotations_trainval2017.zip unzip -d panoptic_annotations_trainval2017.zip # sudo mkdir cd /usr/local/coco2014 sudo chown -R $USER /usr/local/coco2014 cd /usr/local/coco2014 curl -O http://images.cocodataset.org/zips/train2014.zip curl -O http://images.cocodataset.org/zips/val2014.zip curl -O http://images.cocodataset.org/zips/test2014.zip curl -O http://images.cocodataset.org/annotations/annotations_trainval2014.zip unzip -d train2014.zip unzip -d val2014.zip unzip -d test2014.zip unzip -d annotations_trainval2014.zip
ファイルの配置は次のようになる(現在確認中).
coco2014/ annotations/ images/ objectInfo150.txt sceneCategories.txt coco2017/ coco/ annotations/ images/ train2017/ val2017/ test2017/ labels/ objectInfo150.txt sceneCategories.txt
cocoapi のインストールを行う. cocoapi は, COCO (Common Object in Context) データセット の Python API である.
python -m pip install -U cython python -m pip install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"
Windows では,コマンドプロン プトを管理者として実行し, 次のコマンドを実行する.
python -m pip install git+https://github.com/cocodataset/panopticapi.git
URL: https://cocodataset.org/#keypoints-2017
COCO の Keypoints 2014/2017 アノテーションは,次からダウンロードできる.
COLMAP は 3次元再構成の機能を持ったソフトウェア.
【文献】
Johannes L. Schonberger, Jan-Michael Frahm, Structure-From-Motion Revisited, CVPR 2016, 2016
【サイト内の関連ページ】
【関連する外部ページ】
Coqui TTS は,音声合成および音声変換(Voice Changer)の研究プロジェクトならびに成果物.
Coqui の GitHub のページ: https://github.com/coqui-ai/TTS
Rohan Badlani, Adrian Łancucki, Kevin J. Shih, Rafael Valle, Wei Ping, Bryan Catanzaro, One TTS Alignment To Rule Them All, CoRR, abs/2108.10447v1, 2021.
【関連項目】 音声合成 (Text To Speech; TTS)
公式の手順(https://github.com/coqui-ai/TTS/tree/dev#install-tts)に従う.
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
次のコマンドを実行.することにより,Coqui TTS のインストール,日本語のモデル類のダウンロード, 音声合成の実行が行われる. 結果は,tts_output.wav にできる.
!pip3 install TTS[all] !rm -rf TTS !git clone https://github.com/coqui-ai/TTS %cd TTS !pip3 install -e .[all] !make system-deps !make install !python3 setup.py install !tts --list_models !tts --text "日本国民は正当に選挙された国会における代表者を通じて行動し、われらとわれらの子孫のために、諸国民と協和による成果と、わが国全土にわたって自由のもたらす恵沢を確保し、政府の行為によって再び戦争の惨禍が起こることのないようにすることを決意し、ここに主権が国民に存することを宣言し、この憲法を確定する。そもそも国政は国民の厳粛な信託によるものであって、その権威は国民に由来し、その権力は国民の代表者がこれを行使し、その福利は国民がこれを享受する。これは人類普遍の原理であり、この憲法は、かかる原理に基づくものである。われらはこれに反する一切の憲法、法令及び詔勅を排除する。" --model_name "tts_models/ja/kokoro/tacotron2-DDC" --vocoder_name "vocoder_models/ja/kokoro/hifigan_v1"
公式の手順(https://github.com/coqui-ai/TTS/tree/dev#install-tts)に従う.
次のコマンドを実行.することにより,Coqui TTS のインストール,日本語のモデル類のダウンロード, 音声合成の実行が行われる. 結果は,tts_output.wav にできる.
cd /usr/local sudo pip3 install TTS[all] sudo rm -rf TTS sudo git clone https://github.com/coqui-ai/TTS cd TTS sudo pip3 install -e .[all] sudo make system-deps sudo make install sudo python3 setup.py install tts --list_models tts --text "日本国民は正当に選挙された国会における代表者を通じて行動し、われらとわれらの子孫のために、諸国民と協和による成果と、わが国全土にわたって自由のもたらす恵沢を確保し、政府の行為によって再び戦争の惨禍が起こることのないようにすることを決意し、ここに主権が国民に存することを宣言し、この憲法を確定する。そもそも国政は国民の厳粛な信託によるものであって、その権威は国民に由来し、その権力は国民の代表者がこれを行使し、その福利は国民がこれを享受する。これは人類普遍の原理であり、この憲法は、かかる原理に基づくものである。われらはこれに反する一切の憲法、法令及び詔勅を排除する。" --model_name "tts_models/ja/kokoro/tacotron2-DDC" --vocoder_name "vocoder_models/ja/kokoro/hifigan_v1"
CoTracker は、動画のポイントトラッキングの一手法である。 この手法は、長期間の追跡やオクルージョン(遮蔽)の取り扱いの難しさに対処するために開発された。 CoTracker では、ポイントをグループとして追跡する方法、つまりグループベースのアプローチを採用しており、ポイント間の相互関係を活用する。さらに、時間的なスライディングウィンドウメカニズムを使用して、長期間にわたる追跡を行う。実験結果からは、co-trackingが既存の手法に比べて、オクルージョンや長期間のビデオに対する追跡の安定性が向上したことが示されている。
【文献】
Nikita Karaev, Ignacio Rocco, Benjamin Graham, Natalia Neverova, Andrea Vedaldi, Christian Rupprecht, CoTracker: It is Better to Track Together, arXiv:2307.07635v1, 2023.
https://arxiv.org/pdf/2307.07635v1.pdf
【関連する外部ページ】
https://huggingface.co/spaces/facebook/cotracker
CSPNet は,ステージの最初の特徴マップ (feature map) と最後の特徴マップ (feature map) を統合することを特徴とする手法.
CSPNet は, ResNet, ResNeXt, DenseNet などに適用でき, ImageNet データセットを用いた画像分類の実験では,計算コスト,メモリ使用量,推論の速度,推論の精度の向上ができるとされている. その結果として,物体検出 についても改善ができるとされている.
CSPNet の公式の実装 (GitHub) のページでは, 画像分類として, CSPDarkNet-53, CSPResNet50, CSPResNeXt-50, 物体検出として, CSPDarknet53-PANet-SPP, CSPResNet50-PANet-SPP, CSPResNeXt50-PANet-SPP 等の実装が公開されている.
Scaled YOLO v4 では,CSPNet の技術が使われている.
Chien-Yao Wang, Hong-Yuan Mark Liao, I-Hau Yeh, Yueh-Hua Wu, Ping-Yang Chen, Jun-Wei Hsieh, CSPNet: A New Backbone that can Enhance Learning Capability of CNN, CoRR, abs/1911.11929v1, 2019.
【関連用語】 AlexeyAB darknet, 画像分類, 物体検出, Scaled YOLO v4, pytorchimagemodels
csvkit は,CSV ファイルを操作する機能を持ったソフトウェア.
csvkit の公式ドキュメント: https://csvkit.readthedocs.io/en/latest/
【主な機能】
csvsql a.csv > a.sql csvsql --query "select * from a;" --insert a.csv > a.sql
csvkit 及び類似ソフトウェアのインストールは次のような手順になる.
Windows では,コマンドプロン プトを管理者として実行し, 次のコマンドを実行する.
python -m pip install -U pip setuptools pandas openpyxl csvkit python -m pip install -e git+https://github.com/wireservice/agate-excel.git#egg=agate-excel python -m pip install -U agate-dbf agate-sql six olefile
端末で,次のコマンドを実行
sudo apt -y update sudo apt -y install csvkit python3-pandas python3-csvkit
次の URL で公開されている.
URL: https://github.com/wireservice/csvkit/tree/master/examples/realdata
上の URL をWebブラウザで開くか,次のコマンドでダウンロードできる.
curl -L -O https://raw.githubusercontent.com/wireservice/csvkit/master/examples/realdata/ne_1033_data.xlsx
Computing Research Repository を,縮めて 「CoRR」という. URL は次の通り.
CoRR の URL: https://arxiv.org/corr
cudart64_100.dll は,NVIDIA CUDA 10.0 のファイル. NVIDIA CUDA 10.0 をインストールすることにより, cudart64_100.dll を得ることができる.
cudart64_101.dll は,NVIDIA CUDA 10.1 のファイル. NVIDIA CUDA 10.1 をインストールすることにより, cudart64_101.dll を得ることができる.
cudart64_110.dll は,NVIDIA CUDA 11 のファイル. NVIDIA CUDA 11 をインストールすることにより, cudart64_110.dll を得ることができる.
cudnn64_7.dll は,NVIDIA cuDNN 7 のファイル. NVIDIA cuDNN 7 (例えば,NVIDIA cuDNN 7.6.5) をインストールすることにより, cudnn64_7.dll を得ることができる.
Windows では,次の操作により,cudnn64_7.dll にパスが通っていることを確認する.
Windows のコマンドプロンプトを開き、次のコマンドを実行する.エラーメッセージが出ないことを確認.
where cudnn64_7.dll
【関連情報】
cudnn64_8.dll は,NVIDIA cuDNN v8 のファイル. NVIDIA cuDNN v8 をインストールすることにより, cudnn64_8.dll を得ることができる.
Windows では,次の操作により,cudnn64_8.dll にパスが通っていることを確認する.
Windows のコマンドプロンプトを開き、次のコマンドを実行する.エラーメッセージが出ないことを確認.
where cudnn64_8.dll
【関連情報】
反射率とテクスチャに関するデータベース
CuRRET データベース (Columbia-Utrecht Reflectance and Texture Database)は次の URL で公開されているデータセット(オープンデータ)である.
URL: https://www.cs.columbia.edu/CAVE/software/curet/html/about.php
DeepFace は,ArcFace 法による顔識別の機能や,顔検出,年齢や性別や表情の推定の機能などを持つ.
ArcFace 法は,距離学習の技術の1つである. 画像分類において,種類が不定個であるような画像分類に使うことができる技術である. 顔のみで動くということではないし, 顔の特徴を捉えて工夫されているということもない.
DeepFace の URL: https://github.com/serengil/deepface
ArcFace 法の概要は次の通り
【関連項目】 ArcFace 法, 顔検出, 顔識別 (face identification), 顔認識, 顔に関する処理
実験するときは,顔の部分だけを切り出す作業をペイントソフトなどで行い,その後実験に進むと良いと思います.
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
!pip3 install deepface !git clone --recursive https://github.com/serengil/deepface from deepface import DeepFace import pandas as pd pd.set_option('display.max_rows', None) print(pd.get_option('display.max_rows'))
単一のディレクトリ ./deepface/tests/dataset に,処理したい顔画像をすべて入れておく
ディレクトリ内の全画像ファイルとの顔識別を行い,それぞれの顔画像ファイルとの距離を表示.
df = DeepFace.find(img_path="./deepface/tests/dataset/img38.jpg", db_path="./deepface/tests/dataset", distance_metric='euclidean') a = df.sort_values('VGG-Face_euclidean') print(a)
obj = DeepFace.analyze(img_path = "./deepface/tests/dataset/img38.jpg", actions = ['age', 'gender', 'emotion']) print(obj)
DeepForge は,ディープラーニングのソフトウェア一式.Webサーバも付属していて,Webブラウザからディープラーニングのソフトウェアの作成,実行,保存が簡単にできる.ソフトウェアの作成は,Webブラウザ上でのエディタでも,Webブラウザ上でのビジュアルなエディタでもできる.ディープラーニングでのニューラルネットワークの構造が図で簡単に確認できて便利
【サイト内の関連ページ】
【関連する外部ページ】
DeepLab2 は,セグメンテーションの機能を持つ TensorFlow のライブラリである. DeepLab, Panoptic-DeepLab, Axial-Deeplab, Max-DeepLab, Motion-DeepLab, ViP-DeepLab を含む.
DeepLab2 の公式のデモ(Google Colaboratory のページ)の実行により,下図のように panoptic segmentation の結果が表示される.
そのデモのページの URL: https://colab.research.google.com/github/google-research/deeplab2/blob/main/DeepLab_Demo.ipynb#scrollTo=6552FXlAOHnX
【文献】
Mark Weber, Huiyu Wang, Siyuan Qiao, Jun Xie, Maxwell D. Collins, Yukun Zhu, Liangzhe Yuan, Dahun Kim, Qihang Yu, Daniel Cremers, Laura Leal-Taixe, Alan L. Yuille, Florian Schroff, Hartwig Adam, Liang-Chieh Chen, DeepLab2: A TensorFlow Library for Deep Labeling, CoRR, abs/2106.09748v1, 2021.
【サイト内の関連ページ】
【関連項目】 セマンティック・セグメンテーション (semantic segmentation), panoptic segmentation, depth estimation
Deeplab2 を動かすため,protobuf==3.19.6
cd c:\ rmdir /s /q c:\deeplab2 mkdir c:\deeplab2 cd c:\deeplab2 git clone https://github.com/google-research/deeplab2.git python -m pip install -U tensorflow==2.10.1 protobuf==3.19.6
cd c:\deeplab2 protoc deeplab2\*.proto --python_out=.
コマンドプロンプトを管理者として実行: 別ページ »で説明
powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"PYTHONPATH\", \"Machine\"); $oldpath += \";c:\deeplab2\"; [System.Environment]::SetEnvironmentVariable(\"PYTHONPATH\", $oldpath, \"Machine\")"
cd c:\deeplab2\deeplab2\model python deeplab_test.pyDeeplab2 のインストール(Ubuntu 上)
ttps://github.com/google-research/deeplab2/blob/main/g3doc/setup/installation.md の記載による.
- protoc のインストール
sudo apt -y update sudo apt -y install libprotobuf-dev protobuf-compiler protobuf-c-compiler python3-protobuf- pycocotoos のインストール
sudo pip3 install tensorflow tf-models-official pillow matplotlib cython sudo pip3 install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI" # install pycocotools cd /usr/local sudo git clone https://github.com/cocodataset/cocoapi.git sudo chown -R $USER cocoapi cd ./cocoapi/PythonAPI make echo 'export PYTHONPATH=$PYTHONPATH:/usr/local/cocoapi/PythonAPI' >> ~/.bashrc- DeepLab2 のインストール
cd /usr/local sudo rm -rf deeplab2 sudo git clone https://github.com/google-research/deeplab2.git sudo chown -R $USER deeplab2 cd /usr/local protoc deeplab2/*.proto --python_out=. cd /usr/local bash deeplab2/compile.sh echo 'export PYTHONPATH=$PYTHONPATH:/usr/local' >> ~/.bashrc echo 'export PYTHONPATH=$PYTHONPATH:/usr/local/deeplab2' >> ~/.bashrc- TensorFlow モデルのインストール
cd /usr/local sudo rm -rf models sudo git clone https://github.com/tensorflow/models.git sudo chown -R $USER models cd /usr/local/models/research protoc object_detection/protos/*.proto --python_out=. protoc lstm_object_detection/protos/*.proto --python_out=. cd /usr/local/models/research\delf protoc delf/protos/*.proto --python_out=. echo 'export PYTHONPATH=$PYTHONPATH:/usr/local/models' >> ~/.bashrc- DeepLab2 の動作確認
source ~/.bashrc cd /usr/local # Model training test (test for custom ops, protobuf) python deeplab2/model/deeplab_test.py # Model evaluator test (test for other packages such as orbit, cocoapi, etc) python deeplab2/trainer/evaluator_test.pyDeepLabv3
セマンティック・セグメンテーションのモデル. 2017年発表.
Liang-Chieh Chen, George Papandreou, Florian Schroff, Hartwig Adam, Rethinking Atrous Convolution for Semantic Image Segmentation
【関連項目】 Residual Networks (ResNets) , モデル, セマンティック・セグメンテーション
セマンティック・セグメンテーションのモデル. 2018年発表.
Liang-Chieh Chen and Yukun Zhu and George Papandreou and Florian Schroff and Hartwig Adam, Encoder-Decoder with Atrous Separable Convolution for Semantic Image Segmentation, ECCV, 2018.
【関連項目】 Residual Networks (ResNets) , モデル, セマンティック・セグメンテーション
DeepL API の認証キーの取得はオンラインで可能である.クレジットカード番号の登録などが必要になる.
【関連する外部ページ】
DeepL Pro のページ: https://www.deepl.com/pro#developer
【関連項目】 speech enhancement, speech recognition
公式の手順 https://github.com/anicolson/DeepXi による.
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
%cd /content !rm -rf DeepXi !git clone https://github.com/anicolson/DeepXi.git %cd DeepXi !pip3 install -r requirements.txt
物体検出の一手法.2021 年発表.
Xizhou Zhu and Weijie Su and Lewei Lu and Bin Li and Xiaogang Wang and Jifeng Dai, Deformable DETR: Deformable Transformers for End-to-End Object Detection, International Conference on Learning Representations, also CoRR, abs/2010.04159v4, 2021.
【関連項目】 DETR, MMDetection, 物体検出
音源分離(music source separation)を行う 1手法.2019年発表.2021年に hybrid version が発表. 音声と楽器音の混合から,音声や楽器音を分離できる.
Hybrid Spectrogram and Waveform Source Separation, Alexandre Défossez, Proceedings of the ISMIR 2021 Workshop on Music Source Separation, also CoRR, abs/2111.03600v1, 2021.
【関連用語】 audio source seperation, music source separation
公式の手順 https://github.com/facebookresearch/demucs による.
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
!pip3 install -U git+https://github.com/facebookresearch/demucs#egg=demucs !pip3 show demucs
ここでは,1.m4a をダウンロードしている.
%cd /content !curl -O https://www.kkaneko.jp/sample/audio/1.m4a
!demucs 1.m4a
「1」のところは,処理したサウンドファイルのファイル名にあわせること.
from google.colab import files %cd separated/mdx_extra_q/1 files.download('drums.wav') files.download('bass.wav') files.download('other.wav') files.download('vocals.wav')
CoRR, abs/1608.06993
Keras の DenseNet121 を用いて DenseNet121 を作成するプログラムは次のようになる. 「weights=None」を指定することにより,最初,重みをランダムに設定する.
【Keras のプログラム】
m = tf.keras.applications.densenet.DenseNet121(input_shape=INPUT_SHAPE, weights=None, classes=NUM_CLASSES)
Keras の DenseNet169 を用いて DenseNet169 を作成するプログラムは次のようになる. 「weights=None」を指定することにより,最初,重みをランダムに設定する.
【Keras のプログラム】
m = tf.keras.applications.densenet.DenseNet169(input_shape=INPUT_SHAPE, weights=None, classes=NUM_CLASSES)
Keras の応用のページ: https://keras.io/ja/applications/
PyTorch HUB のページ: https://pytorch.org/hub/pytorch_vision_densenet/ を参考にした.
Google Colab あるいはパソコン(Windows あるいは Linux)を使用.
前準備として,Python のインストール: 別項目で説明している., PyTorch のインストール を行う.
Google Colaboratory では, Python, PyTorch はインストール済みなので,インストール操作は不要.
次に,pip を用いて,pillow のインストールを行う.
pip install -U pillow
PyTorch, torchvision のモデルについては: https://pytorch.org/vision/stable/models.html に説明がある.
import torch import torchvision.models as models device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') m = models.densenet121(pretrained=True).to(device)
from PIL import Image import requests # ダウンロードとロード url = 'https://github.com/pytorch/hub/raw/master/images/dog.jpg' response = requests.get(url) img = Image.open(requests.get(url, stream=True).raw) # 確認表示 display(img)
from PIL import Image from torchvision import transforms img = Image.open(filename) preprocess = transforms.Compose([ transforms.Resize(256), transforms.CenterCrop(224), transforms.ToTensor(), transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]), ]) input_tensor = preprocess(img) input_batch = input_tensor.unsqueeze(0)
「m.eval()」は,推論を行うときのためのもの.これを行わないと訓練(学習)が行われる.
import torch if torch.cuda.is_available(): input_batch = input_batch.to('cuda') m.eval() with torch.no_grad(): output = m(input_batch)
import urllib url, filename = ("https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt", "imagenet_classes.txt") try: urllib.URLopener().retrieve(url, filename) except: urllib.request.urlretrieve(url, filename) with open("imagenet_classes.txt", "r") as f: categories = [s.strip() for s in f.readlines()] # The output has unnormalized scores. To get probabilities, you can run a softmax on it. probabilities = torch.nn.functional.softmax(output[0], dim=0) print(probabilities) top5_prob, top5_catid = torch.topk(probabilities, 5) for i in range(top5_prob.size(0)): print(categories[top5_catid[i]], top5_prob[i].item())
Google Colaboratory での結果
Windows での結果
Linux での結果
PyTorch HUB のページ: https://pytorch.org/hub/pytorch_vision_densenet/ を参考にした.
Google Colab あるいはパソコン(Windows あるいは Linux)を使用.
前準備として,Python のインストール: 別項目で説明している., PyTorch のインストール を行う.
Google Colaboratory では, Python, PyTorch はインストール済みなので,インストール操作は不要.
次に,pip を用いて,pillow のインストールを行う.
pip install -U pillow
PyTorch, torchvision のモデルについては: https://pytorch.org/vision/stable/models.html に説明がある.
import torch import torchvision.models as models device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') m = models.densenet169(pretrained=True).to(device)
from PIL import Image import requests from IPython.display import display # ダウンロードとロード url = 'https://github.com/pytorch/hub/raw/master/images/dog.jpg' response = requests.get(url) img = Image.open(requests.get(url, stream=True).raw) # 確認表示 display(img)
from PIL import Image from torchvision import transforms img = Image.open(filename) preprocess = transforms.Compose([ transforms.Resize(256), transforms.CenterCrop(224), transforms.ToTensor(), transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]), ]) input_tensor = preprocess(img) input_batch = input_tensor.unsqueeze(0)
「m.eval()」は,推論を行うときのためのもの.これを行わないと訓練(学習)が行われる.
import torch if torch.cuda.is_available(): input_batch = input_batch.to('cuda') m.eval() with torch.no_grad(): output = m(input_batch)
import urllib url, filename = ("https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt", "imagenet_classes.txt") try: urllib.URLopener().retrieve(url, filename) except: urllib.request.urlretrieve(url, filename) with open("imagenet_classes.txt", "r") as f: categories = [s.strip() for s in f.readlines()] # The output has unnormalized scores. To get probabilities, you can run a softmax on it. probabilities = torch.nn.functional.softmax(output[0], dim=0) print(probabilities) top5_prob, top5_catid = torch.topk(probabilities, 5) for i in range(top5_prob.size(0)): print(categories[top5_catid[i]], top5_prob[i].item())
Google Colaboratory での結果
Windows での結果
Linux での結果
depth image は遠近である depth を示す画像. 画素ごとの色や明るさで depth を表示する.
画像からの depth image の推定は,ステレオカメラや動画から視差を得る方法が主流である.
単一のカメラでの画像から depth image を推定する方法としては,ディープラーニングを用いる monodepth2 法 (2019 年発表) が知られる.
monodepth2 の GitHub のページ: https://github.com/nianticlabs/monodepth2
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
!pip3 install -U numpy pillow matplotlib torch torchvision opencv-python opencv-contrib-python scikit-image !git clone --recursive https://github.com/nianticlabs/monodepth2
%cd monodepth2 !python3 test_simple.py --image_path assets/test_image.jpg --model_name mono+stereo_640x192
from PIL import Image Image.open('assets/test_image.jpg').show() Image.open('assets/test_image_disp.jpeg').show()
【文献】
Yuxin Wu and Alexander Kirillov and Francisco Massa and Wan-Yen Lo and Ross Girshick, Detectron2, https://github.com/facebookresearch/detectron2, 2019.
【サイト内の関連ページ】
物体検出,インスタンス・セグメンテーション,パノプティック・セグメンテーションの実行(Detectron2,PyTorch, Python を使用)(Windows 上)
【関連する外部ページ】
【関連項目】 ADE20K データセット, インスタンス・セグメンテーション (instance segmentation)
インストールは次のページで説明されている.
https://github.com/facebookresearch/detectron2/releases
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する)
PyTorch は,ディープラーニングのフレームワークの 機能を持つ Pythonのパッケージ
次のプログラム実行により,PyTorch のバージョンが「1.10.0+cu111」のように表示される.
import torch print(torch.__version__)
次のプログラム実行により,NVIDIA CUDA ツールキットのバージョンが「cu111」のように表示される.
import torch CUDA_VERSION = torch.__version__.split("+")[-1] print(CUDA_VERSION)
import torch TORCH_VERSION = ".".join(torch.__version__.split(".")[:2]) print(TORCH_VERSION)
NVIDIA CUDA ツールキット 11.1, PyTorch 1.10 の場合には,次のようになる
「cu111/torch1.10」のところは, NVIDIA CUDA ツールキット のバージョン, PyTorch のバージョンに合わせる
!pip3 install detectron2==0.6 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu111/torch1.10/index.html
必要に応じて,中のファイルを利用できるように準備しておく.
!curl -LO https://github.com/facebookresearch/detectron2/archive/refs/tags/v0.6.tar.gz !tar -xvzof v0.6.tar.gz
https://colab.research.google.com/drive/16jcaJoc6bCFAQ96jDe2HwtXj7BMD_-m5#scrollTo=FsePPpwZSmqt の記載による
!curl -O http://images.cocodataset.org/val2017/000000439715.jpg from PIL import Image Image.open('000000439715.jpg').show()
https://colab.research.google.com/drive/16jcaJoc6bCFAQ96jDe2HwtXj7BMD_-m5#scrollTo=FsePPpwZSmqt の記載による
「im = cv2.imread('000000439715.jpg')」で,処理したい画像ファイルをロードしている.
import detectron2 from detectron2 import model_zoo from detectron2.engine import DefaultPredictor from detectron2.config import get_cfg from detectron2.utils.visualizer import Visualizer from detectron2.data import MetadataCatalog, DatasetCatalog cfg = get_cfg() # add project-specific config (e.g., TensorMask) here if you're not running a model in detectron2's core library cfg.merge_from_file(model_zoo.get_config_file("COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml")) cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.5 # set threshold for this model # Find a model from detectron2's model zoo. You can use the https://dl.fbaipublicfiles... url as well cfg.MODEL.WEIGHTS = model_zoo.get_checkpoint_url("COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml") predictor = DefaultPredictor(cfg) import cv2 im = cv2.imread('000000439715.jpg') outputs = predictor(im)
https://colab.research.google.com/drive/16jcaJoc6bCFAQ96jDe2HwtXj7BMD_-m5#scrollTo=FsePPpwZSmqt の記載による
# look at the outputs. See https://detectron2.readthedocs.io/tutorials/models.html#model-output-format for specification print(outputs["instances"].pred_classes) print(outputs["instances"].pred_boxes)
https://colab.research.google.com/drive/16jcaJoc6bCFAQ96jDe2HwtXj7BMD_-m5#scrollTo=FsePPpwZSmqt の記載による
# We can use `Visualizer` to draw the predictions on the image. v = Visualizer(im[:, :, ::-1], MetadataCatalog.get(cfg.DATASETS.TRAIN[0]), scale=1.2) out = v.draw_instance_predictions(outputs["instances"].to("cpu")) import matplotlib.pyplot as plt plt.imshow(out.get_image()[:, :, ::-1])
別ページ »で説明している.
インストールは次のページで説明されている.
https://github.com/facebookresearch/detectron2/releases
このページによれば,Linux マシンで,NVIDIA CUDA ツールキット 11.1, PyTorch 1.9 がインストール済みの場合には,次のような手順になる.
python -m pip install detectron2==0.5 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu111/torch1.9/index.html
物体検出, panoptic segmentation の一手法.2020年発表.
Nicolas Carion, Francisco Massa, Gabriel Synnaeve, Nicolas Usunier, Alexander Kirillov, Sergey Zagoruyko, End-to-End Object Detection with Transformers, ECCV 2020, also CoRR, abs/2005.12872v3, 2020.
【関連項目】 Deformable DETR, MMDetection, panoptic segmentation, 物体検出,
【文献】
Xinqi Lin, Jingwen He, Ziyan Chen, Zhaoyang Lyu, Ben Fei, Bo Dai, Wanli Ouyang, Yu Qiao, Chao Dong, DiffBIR: Towards Blind Image Restoration with Generative Diffusion Prior, arXiv:2308.15070v1, 2023.
https://arxiv.org/pdf/2308.15070v1.pdf
【関連する外部ページ】
Jascha Sohl-Dickstein, Eric A. Weiss, Niru Maheswaranathan, Surya Ganguli, Deep Unsupervised Learning using Nonequilibrium Thermodynamics, arXiv:1503.03585 [cs.LG].
IPython の display は,画像表示の機能がある. display は,Jupyter Qt Console や Google Colaboratory などで動く
次の Python プログラムは,画像ファイルのダウンロードとロードと確認表示を行う.確認表示で display を用いている.
from PIL import Image import requests from IPython.display import display # ダウンロードとロード url = 'https://github.com/pytorch/hub/raw/master/images/dog.jpg' response = requests.get(url) img = Image.open(requests.get(url, stream=True).raw) # 確認表示 display(img)
次の Python プログラムは,Iris データセットのロードと確認表示を行う. Pandas データフレームの df にロードしている. 確認表示で display を用いている.
import pandas as pd from sklearn.datasets import load_iris from IPython.display import display iris = load_iris() df = pd.DataFrame(iris.data, columns=iris.feature_names) df['species'] = iris.target_names[iris.target] display(df)
Pandas データフレームのすべての行を表示したいときは,次のように 「pd.set_option('display.max_rows', None)」を使用する
import pandas as pd from sklearn.datasets import load_iris from IPython.display import display iris = load_iris() df = pd.DataFrame(iris.data, columns=iris.feature_names) df['species'] = iris.target_names[iris.target] pd.set_option('display.max_rows', None) display(df)
Dlib は,数多くの機能を持つソフトウェア. Python, C++ のプログラムから使うためのインタフェースを持つ.
Dlib の機能には,機械学習,数値計算,グラフィカルモデル推論,画像処理,スレッド,通信,GUI,データ圧縮・一貫性,テスト,さまざまなユーティリティがある.
Dlib には,顔情報処理に関して,次の機能がある.
ディープニューラルネットワークの学習済みモデルも配布されている
Dlib の URL: http://dlib.net/
【関連項目】 FairFace, Max-Margin 物体検出 , 顔検出 (face detection), 顔ランドマーク (facial landmark), 顔のコード化
Dlib のインストールは,複数の方法がある.
Dlib 19.24.99 の非公式ビルド: dlib.zip
私がビルドしたもの,非公式,無保証, 公開されているDlib のソースコードを改変せずにビルドした. Windows 10, Visual Build Tools for Visual Studio 2022 を用いてビルドした.NVIDIA CUDA は使用せずにビルドした. Eigen の MPL2 ライセンスによる.
zip ファイルは C:\ 直下で展開し,C:\dlib での利用を想定.
Dlib の顔検出 は次の仕組みで行われる.
Dlib には,ディープラーニングの CNN (convolutional neural network) を用いた物体検出 が実装されている. そこでは,Max-Margin 物体検出法が利用されている(文献は次の通り). それにより,Dlib の顔検出 が行われる.
Davis E. King, Max-Margin Object Detection, CoRR, abs/1502.00046, 2015
Dlib を用いた顔検出のプログラム例
ここでダウンロードしている mmod_human_face_detector.dat は,学習済みモデルのファイルである. ImageNet データセット, AFLW, , VGG, , face scrub 画像について, Dlib の作者がアノテーションしたものを用いて学習済みである. 詳細は https://github.com/davisking/dlib-models
Windows では, コマンドプロンプトを管理者として開き次のコマンドを実行する.
python -m pip install dlib opencv-python matplotlib curl -O http://dlib.net/files/mmod_human_face_detector.dat.bz2 "c:\Program Files\7-Zip\7z.exe" x mmod_human_face_detector.dat.bz2
Linux では次のコマンドを実行する.
sudo apt -y update sudo apt -y install python3-matplotlib libopencv-dev libopencv-core-dev python3-opencv libopencv-contrib-dev opencv-data sudo pip3 install dlib curl -O http://dlib.net/files/mmod_human_face_detector.dat.bz2 bzip2 -d mmod_human_face_detector.dat.bz2
import dlib import cv2 %matplotlib inline import matplotlib.pyplot as plt import warnings warnings.filterwarnings('ignore') # Suppress Matplotlib warnings import time import argparse # 使い方: 次のプログラムを a.py というファイル名で保存し,「python a.py」のように実行. # あるいは python a.py --image IMG_3264.png --model mmod_human_face_detector.dat のように. # --model は学習済みモデルのファイル名を指定できる ap = argparse.ArgumentParser() ap.add_argument("-i", "--image", help="input image", default="a.png") ap.add_argument("-m", "--model", help="pre-trained model", default="python_examples/mmod_human_face_detector.dat") ap.add_argument("-u", "--upsample", type=int, default=1) args = vars(ap.parse_args()) # face_detector = dlib.cnn_face_detection_model_v1(args['model']) # 画像ファイル名を a.png のところに設定 bgr = cv2.imread(args['image']) if bgr is None: print("画像ファイルがない") exit() # 顔検出を行う. start = time.time() faces = face_detector(cv2.cvtColor(bgr, cv2.COLOR_BGR2RGB), args['upsample']) end = time.time() print("秒数 : ", format(end - start, '.2f')) # 顔検出で得られた顔(複数あり得る)それぞれについて、赤い四角を書く for i, f in enumerate(faces): x = f.rect.left() y = f.rect.top() width = f.rect.right() - x height = f.rect.bottom() - y cv2.rectangle(bgr, (x, y), (x + width, y + height), (0, 0, 255), 2) print("%s, %d, %d, %d, %d" % (args['image'], x, y, x + width, y + height)) # 画面に描画 plt.style.use('default') plt.imshow(cv2.cvtColor(bgr, cv2.COLOR_BGR2RGB)) # ファイルに保存 cv2.imwrite("result.png", bgr)
次のページは,上のプログラム等を記載したGoogle Colaboratory のページである.ページを開き実行できる.
URL: https://colab.research.google.com/drive/1q-dGCfre8MT5Zet2O3xYoYMUP0sx_KLc?usp=sharing [Google Colaboratory]
Dlib の顔検出の詳しい手順: 別ページ »で説明している.
Docker は,Windowsなどのオペレーティングシステムの中に, Docker コンテナ という Dockerのエリアを複数作ることができる。 Docker コンテナの中には、ソフトもインストールしたりできるが、 それは、おおもとのWindows などのオペレーティングシステムや,他の Docker コンテナとは隔離される (つまり、Docker コンテナの中のアプリを起動するときは、Docker のコマンドも必要)。 いろんなソフトを試したいときに便利。「サーバ」を立てたいというとき、サーバのソフトを丸ごと Docker コンテナの中に入れておくと、サーバの運用保守(サーバを止めたりと、バージョンアップで入れ替えたりなど)が楽になる可能性がある
【サイト内の主な Docker 関連ページ】
【関連する外部ページ】
Docker Desktop のインストール,Ubuntu 22.04 コンテナとイメージの作成(Windows 上)で説明している.
Docker Engine,Docker Desktop のインストールと使用法,Docker Compose の「はじめよう」を実行(Ubuntu 22.04 上): 別ページ »で説明している.
Docker Compose は, Docker を簡単に管理できるツール.環境変数を個々の Docker コンテナごとに変えるといったことも簡単にできるようになる.
【サイト内の主な Docker 関連ページ】
次のコマンドを実行する.exit で終了すると,コンテナは削除される(「--rm」を付けている)
docker run --rm -it --name myubuntu ubuntu:22.04 PS1='\h:\w\$ '
Docker の主なコマンド
DreamGaussianは3Dコンテンツ生成の新しいフレームワークであり、特に画像から3Dモデルを生成する(Image-to-3D)とテキストから3Dモデルを生成する(Text-to-3D)の二つの主要なタスクに対応しています。既存の手法であるNeural Radiance Fields(NeRF)は高品質な結果を出すものの、計算時間が長いという課題がありました。DreamGaussianの特長は、3Dガウススプラッティングモデルを用いることで、メッシュの抽出とUV空間でのテクスチャの精緻化が効率的に行える点です。この新しいアプローチにより、DreamGaussianは既存のNeRFベースの手法よりも高速な3Dコンテンツ生成を実現しています。さらに、実験結果では、DreamGaussianがImage-to-3DとText-to-3Dの両方のタスクで既存の方法よりも高速であることが確認されています。
【文献】
Jiaxiang Tang, Jiawei Ren, Hang Zhou, Ziwei Liu, Gang Zeng, DreamGaussian: Generative Gaussian Splatting for Efficient 3D Content Creation, arXiv:2309.16653v1, 2023.
https://arxiv.org/pdf/2309.16653v1.pdf
【関連する外部ページ】
元画像
中間結果(左),最終結果のスクリーンショット(右)
処理結果(3次元データ): b.obj, b.mtl, b_albedo.png
処理結果のスクリーンショット(動画):
処理結果(3次元データ): icecream_mesh.obj, icecream_mesh.mtl, icecream_mesh_albedo.png, icecream_model.ply
処理結果のスクリーンショット(動画): icecream.mp4
DUTS データセットは,saliency detection のためのデータセットである. 10,553枚の訓練画像と5,019枚のテスト画像を含む.
いずれも手動でアノテーションされている.
次の URL で公開されているデータセット(オープンデータ)である.
URL: http://saliencydetection.net/duts/
J. Deng, W. Dong, R. Socher, L.-J. Li, K. Li, and L. Fei-Fei, Imagenet: A large-scale hierarchical image database, CVPR, 2009.
J. Xiao, J. Hays, K. A. Ehinger, A. Oliva, and A. Torralba, SUN database: Large-scale scene recognition from abbey to zoo, CVPR, 2010.
Lijun Wang, Huchuan Lu, Yifan Wang, Mengyang Feng, Dong Wang, Baocai Yin, and Xiang Ruan, Learning to detect salient objects with image-level supervision, CVPR, 2017.
https://openaccess.thecvf.com/content_cvpr_2017/papers/Wang_Learning_to_Detect_CVPR_2017_paper.pdf
Keras で Early Stopping を自動で行いたいとき,次のようにコールバックを書く.
【Keras のプログラム】
from kernel.callbacks import EarlyStopping cb = EarlyStopping(monitor='var_loss', patience = 10)
コールバックは,次のようにして使用する.
【Keras のプログラム】
history = m.fit(x_train, y_train, batch_size=32, epochs=50, validation_data=(x_test, y_test), callbacks=[cb])
EasyOCR は,多言語の文字認識のソフトウエア. テキスト検出に CRAFT を使用.
学習用のソースコードも公開されている.
【サイト内の関連ページ】
EasyOCR のインストールと動作確認(多言語の文字認識)(Python,PyTorch を使用)(Windows 上): 別ページ »で説明している.
【関連する外部ページ】
【関連項目】 CRAFT, OCR
公式の手順 (https://github.com/JaidedAI/EasyOCR)による
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
!pip3 install git+git://github.com/jaidedai/easyocr.git
「ja」は「日本語」の意味.
import easyocr reader = easyocr.Reader(['ja']) result = reader.readtext('1.png')
from IPython.display import display display(result)
JAIDED AI による EasyOCR のオンラインデモの URL: https://www.jaided.ai/easyocr/
エッジから,オブジェクトのバンディングボックス(包含矩形)を求める方法.
C. L. Zitnick and P. Doll ́ar. Edge boxes: Locating object proposals from edges, ECCV, 2014.
【関連項目】 物体検出
zylo117 による EfficientDet の実装 (GitHub) のページ: https://github.com/zylo117
【関連項目】 物体検出
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する)
# install requirements !pip3 install pycocotools numpy opencv-python opencv-contrib-python tqdm tensorboard tensorboardX pyyaml webcolors !pip3 install torch==1.4.0 !pip3 install torchvision==0.5.0 # run the simple inference script !rm -rf Yet-Another-EfficientDet-PyTorch !git clone https://github.com/zylo117/Yet-Another-EfficientDet-PyTorch !mkdir Yet-Another-EfficientDet-PyTorch/weights !(cd Yet-Another-EfficientDet-PyTorch/weights; curl -L -O https://github.com/zylo117/Yet-Another-Efficient-PyTorch/releases/download/1.0/efficientdet-d0.pth) !(cd Yet-Another-EfficientDet-PyTorch; python3 efficientdet_test.py)
Eigen は, 次の機能を持つ C++ テンプレートライブラリ.SSEを使うように最適化されている.
Eigen の URL: https://eigen.tuxfamily.org/index.php
Windows での Eigen 3 のインストール: 別ページ »で説明している.
Ubuntu でインストールを行うには,次のコマンドを実行.
sudo apt -y update sudo apt -y install libeigen3-dev
【文献】
Iago Suárez and José M. Buenaposada and Luis Baumela, ELSED: Enhanced Line SEgment Drawing, Pattern Recognition, vol. 127, pages 108619, arXiv:2108.03144, 2022. doi: https://doi.org/10.1016/j.patcog.2022.108619.
arXiv: https://arxiv.org/abs/2108.03144
https://arxiv.org/pdf/2108.03144.pdf
【サイト内の関連ページ】
ELSED のインストールと動作確認(線分検知)(Build Tools, Python を使用)(Windows 上)
【関連する外部ページ】
【関連項目】 線分検知
SanjayMarreddi の Emotion-Investigator は,顔検出 (face detection)と,Happy, Sad, Disgust, Neutral, Fear, Angry, Surprise の表情推定を行う.
【サイト内の関連ページ】
【関連する外部ページ】
超解像 (super resolution) の一手法.2018 年発表.
Wang, Xintao and Yu, Ke and Wu, Shixiang and Gu, Jinjin and Liu, Yihao and Dong, Chao and Qiao, Yu and Loy, Chen Change, ESRGAN: Enhanced super-resolution generative adversarial networks, The European Conference on Computer Vision Workshops (ECCVW), 2018.
【関連項目】 GAN (Generative Adversarial Network), image super resolution, video super resolution, 超解像 (super resolution)
Everything は,Windows で動くファイル検索のソフトウェア.
Everything のページ http://www.voidtools.com/
Windows での cmake のインストールには,複数の方法がある.次のいずれかによりインストールできる.
winget をインストールしたのち,コマンドプロンプトを管理者として開き「winget install Everything」を実行.
詳しくは 別ページ »で説明
FaceForensics++ データセットは,自動合成された顔画像のデータセット
FaceForensics++ データセットは,次の URL で公開されているデータセット(オープンデータ)である.
URL: https://github.com/ondyari/FaceForensics
【関連情報】
性別,年齢,人種に関するバイアス (bias) 等の問題がないとされる顔データセットが発表された.2021年発表. 顔の性別,年齢等の予測の精度向上ができるとされている.
【関連項目】 dlib, 顔のデータベース, 顔ランドマーク (facial landmark), 顔の性別,年齢等の予測
顔の性別,年齢等の予測を行う.
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
!git clone https://github.com/dchen236/FairFace
公式の GitHub のページ: https://github.com/dchen236/FairFace
2つのファイルをダウンロードする.
Google Colaboratory 「fair_face_models」という名前のディレクトリを作る. そして,いまダウンロードしたファイルのファイル名を次のように変えて, 「fair_face_models」ディレクトリの下に置く. (ファイル名については,predict.py の中で指定されているファイル名にあわせる)
%cd FairFace !python3 predict.py --csv test_imgs.csv
test_imgs.csv には,次の画像ファイルのファイル名が設定されている.
自前の画像で動作確認したいときは,画像ファイル名を書いた csv ファイルを準備する
性別,年齢などが推定されている.
!cat test_outputs.csv
顔の性別,年齢等の予測を行う.
Git の公式ページ: https://git-scm.com/を行っておくこと
git clone https://github.com/dchen236/FairFace
公式の GitHub のページ: https://github.com/dchen236/FairFace
2つのファイルをダウンロードする.
「fair_face_models」という名前のディレクトリを作る. そして,いまダウンロードしたファイルのファイル名を次のように変えて, 「fair_face_models」ディレクトリの下に置く. (ファイル名については,predict.py の中で指定されているファイル名にあわせる)
cd FairFace python predict.py --csv test_imgs.csv
test_imgs.csv には,次の画像ファイルのファイル名が設定されている.
自前の画像で動作確認したいときは,画像ファイル名を書いた csv ファイルを準備する
性別,年齢などが推定されている.
type test_outputs.csv
Fashion MNIST データセットは,公開されているデータセット(オープンデータ)である.
Fashion MNIST データセットは,10 種類のモノクロ画像と,各画像に付いた ラベル(10 種類の中の種類を示す)から構成されるデータセットである.
(内訳)70000枚の内訳は次の通りである
60000枚:教師データ
10000枚:検証データ
【文献】
Han Xiao, Kashif Rasul, and Roland Vollgraf, Fashion-MNIST: a Novel Image Dataset for Benchmarking Machine Learning Algorithms, arXiv:1708.07747 [cs.LG], 2017.
【サイト内の関連ページ】
【関連する外部ページ】
【関連項目】 Keras に付属のデータセット, MNIST データセット, TensorFlow データセット, オープンデータ, 画像分類
次の Python プログラムは,TensorFlow データセットから,Fashion MNIST データセットのロードを行う. x_train, y_train が学習用のデータ.x_test, y_test が検証用のデータになる.
次の Python プログラムでは,TensorFlow データセットから,Fashion MNIST データセットのロードを行う. x_train と y_train を 25枚分表示することにより,x_train と y_train が,モノクロ画像であることが確認できる.
tensorflow_datasets の loadで, 「batch_size = -1」を指定して,一括読み込みを行っている.
from __future__ import absolute_import, division, print_function, unicode_literals import tensorflow as tf import numpy as np import tensorflow_datasets as tfds %matplotlib inline import matplotlib.pyplot as plt import warnings warnings.filterwarnings('ignore') # Suppress Matplotlib warnings # MNIST データセットのロード mnist, mnist_metadata = tfds.load('mnist', with_info = True, shuffle_files=True, as_supervised=True, batch_size = -1) x_train, y_train, x_test, y_test = mnist['train'][0], mnist['train'][1], mnist['test'][0], mnist['test'][1] plt.style.use('default') plt.figure(figsize=(10,10)) for i in range(25): plt.subplot(5,5,i+1) plt.xticks([]) plt.yticks([]) plt.grid(False) # squeeze は,サイズ1の次元を削除.numpy は tf.Tensor を numpy に変換 plt.imshow(np.squeeze(x_train[i]), cmap=plt.cm.binary) plt.xlabel(y_train[i].numpy()) # 確認表示 plt.show()
次の Python プログラムは,Keras に付属のデータセットの中にある Fashion MNIST データセットのロードを行う. x_train, y_train が学習用のデータ.x_test, y_test が検証用のデータになる.
from tensorflow.keras.datasets import fashion_mnist (x_train, y_train), (x_test, y_test) = fashion_mnist.load_data()
次の Python プログラムは,Keras に付属のデータセットの中にある Fashion MNIST データセットのロードを行う. x_train と y_train を 25枚分表示することにより,x_train と y_train が,モノクロ画像であることが確認できる.
import tensorflow.keras from tensorflow.keras.datasets import fashion_mnist %matplotlib inline import matplotlib.pyplot as plt import warnings warnings.filterwarnings('ignore') # Suppress Matplotlib warnings # Fashion MNIST データセットのロード (x_train, y_train), (x_test, y_test) = fashion_mnist.load_data() plt.style.use('default') plt.figure(figsize=(10,10)) for i in range(25): plt.subplot(5,5,i+1) plt.xticks([]) plt.yticks([]) plt.grid(False) plt.imshow(x_train[i], cmap=plt.cm.binary) plt.xlabel(y_train[i]) # 確認表示 plt.show()
【TensorFlow データセット から Fashion MNIST データセット をロード】
結果は,TensorFlow の Tensor である.
type は型,shape はサイズ,np.max と np.mi は最大値と最小値.
tensorflow_datasets の loadで, 「batch_size = -1」を指定して,一括読み込みを行っている.
from __future__ import absolute_import, division, print_function, unicode_literals import tensorflow as tf import numpy as np import tensorflow_datasets as tfds %matplotlib inline import matplotlib.pyplot as plt import warnings warnings.filterwarnings('ignore') # Suppress Matplotlib warnings # Fashion MNIST データセットのロード fashion_mnist, fashion_mnist_metadata = tfds.load('fashion_mnist', with_info = True, shuffle_files=True, as_supervised=True, batch_size = -1) x_train, y_train, x_test, y_test = fashion_mnist['train'][0], fashion_mnist['train'][1], fashion_mnist['test'][0], fashion_mnist['test'][1] print(fashion_mnist_metadata) # 【x_train, x_test, y_train, y_test の numpy ndarray への変換と,値の範囲の調整(値の範囲が 0 〜 255 であるのを,0 〜 1 に調整)】 x_train = x_train.numpy().astype("float32") / 255.0 x_test = x_test.numpy().astype("float32") / 255.0 y_train = y_train.numpy() y_test = y_test.numpy() print(type(x_train), x_train.shape, np.max(x_train), np.min(x_train)) print(type(x_test), x_test.shape, np.max(x_test), np.min(x_test)) print(type(y_train), y_train.shape, np.max(y_train), np.min(y_train)) print(type(y_test), y_test.shape, np.max(y_test), np.min(y_test))
ICP の一手法
Fast-Robust-ICP のページ(Git Hub): https://github.com/yaoyx689/Fast-Robust-ICP
【関連項目】 K 近傍探索 (K nearest neighbour), ICP
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
実行でのオプションについては,Fast-Robust-ICP のページ(Git Hub): https://github.com/yaoyx689/Fast-Robust-ICP
Git の公式ページ: https://git-scm.com/
CMake の公式ダウンロードページ: https://cmake.org/download/
c:\Fast-Robust-ICP にインストールされる.
cd %LOCALAPPDATA% rmdir /s /q Fast-Robust-ICP git clone --recursive https://github.com/yaoyx689/Fast-Robust-ICP cd Fast-Robust-ICP rmdir /s /q build mkdir build cd build del CMakeCache.txt cmake -G "Visual Studio 17 2022" -T host=x64 ^ -DCMAKE_INSTALL_PREFIX="c:/Fast-Robust-ICP" ^ -DEIGEN3_INCLUDE_DIRS="c:/eigen/include;c:/eigen/include/eigen3" ^ .. mklink c:\eigen\include\eigen c:\eigen\include\eigen3 cmake --build . --config RELEASE del c:\eigen\include\eigen
FERET データベースは顔のデータベース.詳細情報は,次のWebページにある.
https://www.nist.gov/itl/products-and-services/color-feret-database
【関連項目】 顔のデータベース
FFHQ (Flickr-Faces-HQ) データセット は,70,000枚の顔画像データセット. 機械学習による顔の生成などの学習や検証に利用できるデータセットである.
FFHQ (Flickr-Faces-HQ) データセットは次の URL で公開されているデータセット(オープンデータ)である.
URL: https://github.com/NVlabs/ffhq-dataset
【関連情報】
A Style-Based Generator Architecture for Generative Adversarial Networks, Tero Karras (NVIDIA), Samuli Laine (NVIDIA), Timo Aila (NVIDIA), CoRR, abs/1812.04948
【関連項目】 顔のデータベース
FFmpeg は,動画のデコーダとエンコーダに関するソフトウェア.
【サイト内の関連ページ】
【関連する外部ページ】
FFmpeg の公式ページ: https://ffmpeg.org/
FFTW は, 離散フーリエ変換 (DFT) を行う C のプログラム集.1次元に限らず,より高次元でも動く.
【関連する外部ページ】
FFTW の公式ページ: https://www.fftw.org/
Windows での FFTW3 のインストール(ソースコードを使用)(Build Tools for Visual Studio を利用)
FFTW 3.3.10 の非公式ビルド: fftw3.zip
私がビルドしたもの,非公式,無保証, https://github.com/FFTW/fftw3 の ソースコードを改変せずにビルドした. Windows 10, Visual Build Tools for Visual Studio 2022 を用いてビルドした. FFTW の GPL ライセンスによる.
zip ファイルは C:\ 直下で展開し,C:\fftw3 での利用を想定.
Ubuntu での FFTW3 のインストール(Ubuntu 上)
FIDTM(Focal Inverse Distance Transform Map) は, crowd counting の一手法.2021年発表.
従来の density maps での課題を解決し,従来法よりも精度が上回るとされる. FIDT map を用いて頭部を得る LMDS もあわせて提案されている.
Focal Inverse Distance Transform Maps for Crowd Localization and Counting in Dense Crowd, Liang, Dingkang and Xu, Wei and Zhu, Yingying and Zhou, Yu, arXiv preprint arXiv:2102.07925, 2021.
crowd coungting の結果の例
群衆の数のカウントと位置の把握 (crowd counting) (FIDTM を使用)
このページでは,FIDTMの作者による公式のプログラムおよび学習済みモデルを使用して,群衆の数のカウントと位置の把握 (crowd counting) を行う手順を示している.
手順は,FIDTM 公式ページの説明通りに進める.難しい点はない.このページでは,Google Colaboratory で簡単に実行できるように,いくつかのコマンドを補っている.説明も補っている.
【関連用語】 crowd counting, JHU-CROWD++ データセット, NWPU-Crowd データセット, ShanghaiTech データセット, UCF-QNRF データセット
学習済みモデルを使用する. 学習済みモデルの一部に新しいモデルを合わせた上で,追加のデータを使い学習を行う. このとき,学習済みモデルの部分と,新しいモデルの部分の両方について,パラメータ(重みなど)の調整を行う.
【関連項目】 画像分類 (image classification), 分類, 物体検出
woctezuma の Google Colaboratory のページを使用する
このプログラムは,物体検出等の機能を持つモデルである DETR を使い, fine tuning (ファイン・チューニング)と,物体検出を行う.
COCO データセットで学習済みの DETR について,確認のため, 物体検出を行ったあと, 風船(baloon)についてのfine tuning (ファイン・チューニング)を行い, 風船(baloon)が検出できるようにしている. 風船(baloon)は,COCO データセット には無い.
!pip3 uninstall -y torchtext !pip3 install torch==1.8.0 torchvision==0.9.0 torchtext==0.9.0 import torch, torchvision print(torch.__version__, torch.cuda.is_available()) torch.set_grad_enabled(False);
COCO データセットのクラス名を確認する.
orange, apple, banana, doc, person などがある.baloon は無い.
detr_resnet50 の事前学習済みのモデルをダウンロードしている.
しきい値 0.9, 0.7, 0.0 の 3 通りで実行.しきい値を下げるほど,検出できる物体は増えるが,誤検知も増える傾向にある.
fine tuning を行うため,風船 (baloon) の画像,そして,風船の領域を示した情報(輪郭線,包含矩形)の情報を使う. 画像は複数.そのうち1枚は次の通り.
過学習は起きていないようである
fine tuning により,風船(baloon)を検出できるようになった. しきい値は 0.9, 0.7 の 2通り.
そのフォーマットは,/content/data/custom (Google Colaboratory の data/custom の下のファイル)が参考になる.
自前のデータが準備できたら,Google Colaboratory にアップロードし, 次のコードセルの「/content/data/custom」のところを書き換えて,再度実行する.
最初の物体検知(fine tuning の前)で,別の画像で試したいとき.
画像ファイルをアップロード.プログラムは次のように書き換える.
fname = '/content/5m126sn2pov30qzu3pc49lampcp6.jpg' im = Image.open(fname) scores, boxes = detect(im, detr, transform)
URL: https://github.com/woctezuma/finetune-detr
【サイト内の関連ページ】
【関連項目】 LLVM
flann は近似近傍探索の機能を持ったソフトウェア
Windows での flann のインストール(Windows 上): 別ページ »で説明している.
FlexGen は,大規模言語モデル (large language model)を用いた推論で必要とされる計算とメモリの要求を削減する技術. 実験では,大規模言語モデル OPT を,16GB の単一 GPU で実行したとき 100倍以上の高速化が可能であるとされている.
【文献】 Ying Sheng, Lianmin Zheng, Binhang Yuan, Zhuohan Li, Max Ryabinin, Beidi Chen, Percy Liang, Ce Zhang, Ion Stoica, Christopher Ré., High-throughput Generative Inference of Large Language Model with a Single GPU, 2023.
【サイト内の関連ページ】
【関連する外部ページ】
FlexGen の GitHub のページ: https://github.com/FMInference/FlexGen
【関連項目】 OPT
FLIC は, 5003枚の画像(訓練データ: 3987枚,検証データ: 1016枚)で構成されている. 画像の上半身についてアノテーションが行われている. ほとんどの人物がカメラ正面を向いている.
ディープラーニングにより姿勢推定を行うためのデータとして利用できる.
次の URL で公開されているデータセット(オープンデータ)である. http://bensapp.github.io/flic-dataset.html
【関連情報】
Sapp, B., Taskar, B.: Modec: Multimodal decomposable models for human pose estimation. In: Computer Vision and Pattern Recognition (CVPR), 2013 IEEE Conference on, IEEE (2013) 3674–3681, https://www.cv-foundation.org/openaccess/content_cvpr_2013/papers/Sapp_MODEC_Multimodal_Decomposable_2013_CVPR_paper.pdf
FordA データセットは,時系列データである.
FordA データセットは,公開されているデータセット(オープンデータ)である.
URL: http://www.timeseriesclassification.com/description.php?Dataset=FordA
教師データ数:3601
テストデータ数: 1320
モーターセンサーにより計測されたエンジンノイズの計測値.
20種類, 約 42.5 時間分のサウンドである.
次の URL で公開されているデータセット(オープンデータ)である.
http://www.eduardofonseca.net/FSDnoisy18k/
Eduardo Fonseca, Manoj Plakal, Daniel P. W. Ellis, Frederic Font, Xavier Favory, and Xavier Serra, “Learning Sound Event Classifiers from Web Audio with Noisy Labels”, arXiv preprint arXiv:1901.01189, 2019
【関連項目】 sound data
URL: https://www.iai.kit.edu/1302.php
Windows での FZKViewer のインストールは 別ページ »で説明している.
FZKViewer で CityGML のファイルを開くときは, File, Open, Open GML File... と操作する.
ファイルが読み込まれると,次のように表示される.
【関連項目】 CityGML
帰無仮説: 正規分布に従う2群の標準偏差が等しい . F 検定を,t 検定の行う前の等分散性の検定に使うのは正しくないという指摘もある.
R システム で,2群 s1, s2 の F 検定を行うプログラム
var.test(s1, s2)
【関連項目】 検定
GAN (Generative Adversarial Network) では, 生成器 (generator) でデータを生成し, 識別機 (discriminator) で,生成されたデータが正当か正当でないかを識別する.
Ian J. Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, Yoshua Bengio, Generative Adversarial Networks, Proceedings of the 27th International Conference on Neural Information Processing Systems 2014
【関連項目】 Applications of Deep Neural Networks, Real-ESRGAN, TecoGAN, Wasserstein GAN (WGAN), Wasserstein GAN with Fradient Penalty (WGAN-GP) ディープラーニング
Git はバージョン管理システム.Windows 版の git の1つ「git for Windows」には,MinGWが同封されている.
Git の公式ページ: https://git-scm.com/
Windows での git のインストールには,複数の方法がある.次のいずれかによりインストールできる.
詳しくは 別ページ »で説明
winget をインストールしたのち,コマンドプロンプトを管理者として開き「winget install Git」を実行
Ubuntu での git のインストールは, 端末で,次のコマンドを実行する.
sudo apt -y update sudo apt -y install git
GitHub からのファイルのダウンロードは, curl コマンドで, 次のように行う.
curl -L https://github.com/opencv/opencv/blob/master/samples/data/home.jpg?raw=true -o home.jpg
GlueStick 法はイメージ・マッチングの一手法.2023年発表. 線分を使ったイメージ・マッチングは,照明条件や視点の変化,テクスチャのない領域でもマッチングできるメリットがある. GlueStick 法は,点と線分の両方を利用してイメージ・マッチングを行う. その際にCNNを利用.
【文献】
Rémi Pautrat, Iago Suárez, Yifan Yu, Marc Pollefeys, Viktor Larsson, GlueStick: Robust Image Matching by Sticking Points and Lines Together, ArXiv, 2023. ·
https://arxiv.org/pdf/2304.02008v1.pdf
【関連する外部ページ】
GNN は、グラフ構造を持つデータを用いた学習を可能とする技術である.
【関連項目】 PyTorch Geometric Temporal
GnuWin は, Win32 版の GNU ツールと,その他類似のオープンソースライセンスのツール
【関連する外部ページ】
Google アカウントは,Google のオンラインサービス等の利用のときに使うアカウント. Google オンラインサービスの利用条件などは,利用者で確認すること.
Google アカウントの取得: 別ページ »で説明
Google Colaboratory の利用により, オンラインで,Web ブラウザを用いて,次のことができる.
Google Colaboratory は,オンラインで使用する. Google Colaboratory の使用には,Google アカウントの取得が必要.
詳しくは: 別ページ »で説明
Google Colaboratory のコードセルで,次の Python プログラムを実行
import tensorflow as tf print(tf.__version__) import keras print(keras.__version__)
Google Colaboratory のコードセルで,次の Python プログラムを実行
!nvcc -V
Google Colaboratory のコードセルで,次の Python プログラムを実行
import torch CUDA_VERSION = torch.__version__.split("+")[-1] print(CUDA_VERSION)
!nvidia-smi --query-gpu=gpu_name,driver_version,memory.total --format=csv
try: from google.colab import drive USE_COLAB = True except: USE_COLAB = False
Google Colaboratory での実行結果
GPU は,グラフィックス・プロセッシング・ユニット(Graphics Processing Unit)の略である.現在は,3次元のビデオゲーム,さまざまな計算,ディープラーニングの高速な並列処理などに用いられている.
Graphviz はグラフデータ構造の機能を持ったソフトウェアである.
URL: https://graphviz.gitlab.io/
Windows での Graphviz のインストールには,複数の方法がある.次のいずれかによりインストールできる.
詳しくは 別ページ »で説明
インストールの終了後,C:\Program Files\Graphviz\bin にパスを通す.
Ubuntu での graphviz のインストール
sudo apt -y update sudo apt -y install graphviz libgraphviz-dev python3-graphviz
grep は,正規表現で,テキストファイルの中から行を選択する機能を持つソフトウェア.
Windows での環境変数の設定は,マイコンピュータを右クリック → プロパティ→ 詳細設定 → 環境変数をクリック
Windowsの画面の表示では、「\」(円マーク)が表示される
gsutil は Google Cloud Strage のアクセス機能を持ったアプリケーション
公式ページは https://cloud.google.com/storage/docs/gsutil?hl=ja
Windows では, コマンドプロンプトを管理者として開き, 次のコマンドを実行することにより, gsutil のインストールを行うことができる.
cd %HOMEPATH% curl -L -O https://dl.google.com/dl/cloudsdk/channels/rapid/GoogleCloudSDKInstaller.exe .\GoogleCloudSDKInstaller.exe
He らの方法 (2015年) では,前層のユニット数(ニューロン数)を n とするとき, sqrt( 2 / n ) を標準偏差とする正規分布に初期化する. ただし,この方法は ReLU に特化した手法であるとされている. この方法を使うとき,層の入力は,正規化済みであること.
Kaiming He, Xiangyu hang, Shaoqing Ren and Jian Sun, Delving Deep into Rectifiers: Surpassing Human-Level, Performance on ImageNet Classification, pp. 1026^1-34.
HDF5 は,階層データを扱うライブラリソフトウェア.
Suport th HDF Group の公式ページ: https://support.hdfgroup.org/
Windows での HDF5 のインストール(Windows 上): 別ページ »で説明している.
HELENデータセットは,顔画像と,顔のパーツの輪郭のデータセットである.
次の URL で公開されているデータセット(オープンデータ)である.
http://www.ifp.illinois.edu/~vuongle2/helen/
【関連情報】
【関連項目】 顔のデータベース
HierTextは,文字認識,レイアウト解析,テキスト検出に利用できるデータセットである. このデータセットには,Open Imagesデータセットから選ばれた11639枚の画像が含まれており,これらの画像はテキストコンテンツとレイアウト構造が豊富である. さらに,約120万語の単語が提供されている. HierTextのアノテーションは,単語,行,段落のレベルを含んでいる. 訓練セットには8,281枚の画像が含まれ,検証セットには1,724枚の画像が含まれ,さらにテストセットには1,634枚の画像が含まれている.
【サイト内の関連ページ】
HierText データセットのインストール(テキスト検出,文字認識のデータセット)(Windows 上)
【関連する外部ページ】
公式のGitHub のページ https://github.com/google-research-datasets/hiertext
【関連項目】 Unified Scene Text Detection
HMDB51 (a large human motion database) データセット は,人間の行動データセット. 機械学習による行動分類,行動認識,ビデオ検索などの学習や検証に利用できるデータセットである.
HMDB51 (a large human motion database) データセット >は次の URL で公開されているデータセット(オープンデータ)である.
https://serre-lab.clps.brown.edu/resource/hmdb-a-large-human-motion-database/#introduction
【関連情報】
Hour Grass Network は,stacked hourglass と呼ばれるアーキテクチャを特色とする CNN (convolutional neural network) である.
姿勢推定 (pose estimation) は,画像から,関節 (joint) の (x,y) 座標を得たり, ヒートマップを得る(ヒートマップでは,画素ごとに値を持ち,その値は,関節である確率が高いほど,高い値になる) 姿勢制御では,さまざまなスケールでの情報を扱うことが課題とされ, stacked hourglass で解決できるとされている. hougrass では,最初にプーリングを行い,その後アップサンプリングを行う. hougrass を直接に並べて stacked hourglass を構成する.
Hour Grass Network の文献は次の通りである.
A. Newell, K. Yang, and J. Deng. Stacked hourglass net- works for human pose estimation. In ECCV, 2016, CoRR, abs/1603.06937.
https://arxiv.org/pdf/1603.06937v2.pdf
【関連項目】 姿勢推定
Hour Grass Network を用いた姿勢推定については,次の文献がある.
qhttps://github.com/bearpaw/pytorch-pose
上の文献では,ディープラーニングにより,人体全身の姿勢推定を行っている. その学習は,次の手順で行う
Git の公式ページ: https://git-scm.com/
git clone https://github.com/bearpaw/pytorch-pose py -3.6 -m pip install scipy==1.1.0 imutils easydict progress py -3.6 -m pip install -U torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117 cd pytorch-pose mkdir .\checkpoint mkdir .\checkpoint\mpii mkdir .\checkpoint\mpii\hg_s1_b1 # MPII データセットを用いた学習 py -3.6 .\example\main.py --dataset mpii --arch hg --stack 1 --block 1 --features 256 --checkpoint .\checkpoint\mpii\hg_s1_b1 --anno-path .\data\mpii\mpii_annotations.json --image-path .\mpii\images
HQ-SAMは、既存のSAM(Segment Anything Model)を拡張し、より高精度なゼロショットセグメンテーションを実現する手法である。SAMは、プロンプト(点、バウンディングボックス、粗いマスクなど)を入力として、多様なオブジェクトや視覚構造のセグメンテーションを可能にするモデルである。しかし、SAMは細かい構造を持つオブジェクトに対するセグメンテーションが不十分で、その精度に限界がある。この問題を解決するために、HQ-SAMはSAMを拡張している。HQ-SAMでは、SAMのマスクデコーダに新しい学習可能な「HQ-Output Token」を導入している。さらに、グローバルなセマンティックコンテキストとローカルな境界(バウンダリ)の詳細を両方考慮する「Global-local Feature Fusion」も導入されている。複数のデータセットでの実験により、HQ-SAMが高精度なセグメンテーションマスクを生成できることが確認されている。
【文献】 Ke, Lei and Ye, Mingqiao and Danelljan, Martin and Liu, Yifan and Tai, Yu-Wing and Tang, Chi-Keung and Yu, Fisher, Segment Anything in High Quality, arXiv:2306.01567, 2023.
https://arxiv.org/pdf/2306.01567v1.pdf
【サイト内の関連ページ】
【関連する外部ページ】
【関連項目】 SAM (Segment Anything Model)
姿勢推定(pose estimation) の一手法.
【関連項目】 MMPose, 姿勢推定(pose estimation)
ディープラーニングにより姿勢推定を行うためのデータとして利用できる.
利用には, https://vision.imar.ro/human3.6m/register.php での申請を必要とする.
http://vision.imar.ro/human3.6m/description.php
Catalin Ionescu, Dragos Papava, Vlad Olaru and Cristian Sminchisescu, Human3.6M: Large Scale Datasets and Predictive Methods for 3D Human Sensing in Natural Environments, IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 36, No. 7, July 2014
iBUG 300-W データセットは, 顔の 68 ランドマーク のデータである.7764枚の顔画像について,手作業で,顔の 68 ランドマークのアノテーションとラベル付が行われている.
顔ランドマーク (facial landmark)は,目,眉,鼻,口,あごのラインなど,顔のパーツの構造を特定でぃる形状予測器 (shape predictor) の学習に使うことができる.
iBUG 300-W データセットの URL: https://ibug.doc.ic.ac.uk/resources/300-W/
【関連項目】 顔の 68 ランドマーク, 顔ランドマーク (facial landmark), 顔のデータベース
画像の中で,除去する対象となるオブジェクトの境界などを指定することにより, 指定されたオブジェクトを除去し,除去された部分の画素は, image completion and extrapolation で補う.
次の文献では, 除去する対象となるオブジェクトの境界を正確に指定しなくても, オブジェクトスコアマップ (object score map) を scene parsing network を用いて 推定することにより, image content removal(画像コンテンツの除去)ができるとされている.
この論文の手法の SunkskyF による実装は,次のページで公開されている.
https://github.com/SunskyF/StructCompletion-python
実行の前準備として,「pip install -U opencv-python opencv-contrib-python」を実行する.demo.py の実行結果は次のとおりである.
【関連項目】 image completion and extrapolation
「100x」のように x を付ける.
convert -resize 100x -unsharp -quality 100 fruits.jpg 1.jpg
「100x」のように x を付ける.
こちらは,元ファイルを上書き
mogrify -resize 100x -unsharp -quality 100 fruits.jpg
for i in *.png; do if [ `identify -format "%[width]" $i` -gt 440 ]; then echo $i mogrify -resize 440x -unsharp 0x1+0.5+0 -quality 100 $i fi done
【関連項目】 画像データの形式変換, MagickWand
Windows でのインストールは,別ページ »で説明している.
Ubuntu でインストールを行うには,次のコマンドを実行.
sudo apt -y update sudo apt -y install imagemagick
前景の色を F,背景の色を B とし,元画像の色は I = alpha * F + (1 - alpha) * B とする. 元画像 I は既知であり,F, B, alpha は未知であるとする. このとき alpha を推定することを image matting という(alpha image matting ともいう).
写真や動画の前景背景分離に用いることができる. 物体検出 や salient object detection との違いとしては, ガラスなどの半透明なもの,髪の毛や網のようなもの,そして,前景が必ずしも画面中央に集まっているとは限らず,画面全域にある(網越しに外を見るような場合)を想定していることがある.
【関連情報】
【関連項目】 GCA, IndexNet, DIM, AIM-500 (Automatic Image Matting-500) データセット
trimap では,次の 3つを考える. 前景である画素は白,背景である画素は黒,transaction である画素は灰色の 3通りに 塗り分けた画像を trimap という.
Trimap-based matting では, 元画像と,その trimap を用いて image matting を行う. ディープラーニングによる Trimap-based matting の手法としては,Xu らの Deep Image Matting (DIM) (2017年)(文献 [1]) などが知られている.
【関連情報】
Ning Xu, Brian Price, Scott Cohen, Thomas Huang, Deep Image Matting CVPR 2017, CoRR, https://arxiv.org/abs/1703.03872v3
Backgroud matting は,image matting において背景画像を用いる. つまり,元画像と,追加の背景画像を用いて image matting を行う. 元画像での背景と,追加の背景画像は同一の場所で撮影されたものが想定されている.そのとき,全に一致しなくてもよい(わずかな位置のずれや照明条件の変化は許容される).
ディープラーニングによるbackground matting Shanchuan Lin らの Backgroud Matting (2021年)(文献 [2])などが知られる. Backbone に ResNet50, ASPP (Atrous Spatial Pyramid Pooling, DeepLabv3 のものに従う).
Background matting では,Trimap を必要としない. ZOOM などのビデオ会議などで,グリーンバックを使わずに,前景と背景を分離するとき, 背景の取得は容易であり, Background matting は有用である.
【関連情報】
Shanchuan Lin, Andrey Ryabtsev, Soumyadip Sengupta, Brian Curless, Steve Seitz, Ira Kemelmacher-Shlizerman, Real-Time High-Resolution Background Matting CVPR 2021, also CoRR, abs/2012.07810v1, 2021.
https://arxiv.org/pdf/2012.07810v1.pdf
人物や動物に特化した image matting である. 人物や動物が写った写真や動画に対して,image matting を行う. このとき,Trimap や 背景画像などの追加の情報を準備することなく image matting を行う手法が種々提案されている.
Trimap や 背景画像などの追加の情報を必要とせず, 人物や動物など以外でも(例えば,半透明のコップ,網ごしの風景写真など) image matting を行うもの. Li らの GFM (文献 [3])(2020 年)は,ディープラーニングによる Trimap の推定が行われており, Li らの unified semantic model (文献 [4])(2021 年)は,Salient Opaque, Salient Transparent/Meticulous, Non-Salient の 3種類の画像を扱えるモデルであり,GGM の拡張により,unified semantic model の推定を行っている.
Jizhizi Li, Jing Zhang, Stephen J Maybank, and Dacheng Tao. End-to-end animal image matting. arXiv preprint arXiv:2010.16188, 2020.
Jizhizi Li , Jing Zhang and Dacheng Tao, Deep Automatic Natural Image Matting, 2021. https://arxiv.org/pdf/2107.07235v1.pdf
ImageNet データセット は,画像分類や物体検出 のベンチマークである「ImageNet Large Scale Visual Recognition Challenge(ILSVRC)」で使用されている. 機械学習での画像分類 や物体検出 の学習や検証に利用できるデータセットである.
ImegeNet のクラス: 別ファイルに記載している.
ImageNet データセットは次の URL で公開されているデータセット(オープンデータ)である.
ImageNet データセットの URL: https://image-net.org/
【関連情報】
IMDb の URL: https://www.imdb.com/
IMDb での映画の批評は,批評文とスコア(10点満点)である. IMDb データセットでは,7点以上の批評は positive,4点以下の批評は negative としている.つまり,2種類ある. そして,IMDb データセットには,positive か negative の批評のみが含まれている(中間の点数である 5点,6点のものは含まれていない).そして, positive,negative の批評が同数である. 学習用として,positive,negative がそれぞれ 25000. 検証用として,positive,negative がそれぞれ 25000.
IMDb データセットのURL: https://ai.stanford.edu/%7Eamaas/data/sentiment/
【関連項目】 Keras に付属のデータセット, TensorFlow データセット, オープンデータ,
次の Python プログラムは,TensorFlow データセットから,IMDb データセットのロードを行う. x_train, y_train が学習用のデータ.x_test, y_test が検証用のデータになる.
次のプログラムでは,そして確認表示を行う.
tensorflow_datasets の loadで, 「batch_size = -1」を指定して,一括読み込みを行っている.
from __future__ import absolute_import, division, print_function, unicode_literals import tensorflow as tf import numpy as np import tensorflow_datasets as tfds %matplotlib inline import matplotlib.pyplot as plt import warnings warnings.filterwarnings('ignore') # Suppress Matplotlib warnings imdb_reviews, imdb_reviews_metadata = tfds.load('imdb_reviews', with_info = True, shuffle_files=True, as_supervised=True, batch_size = -1) x_train, y_train, x_test, y_test = imdb_reviews['train'][0], imdb_reviews['train'][1], imdb_reviews['test'][0], imdb_reviews['test'][1] # 確認表示 import pandas as pd display(pd.DataFrame(x_train[0:14], y_train[0:14]))
IMDb データセットは,次のプログラムでロードできる.
【Keras のプログラム】
from tensorflow.keras.datasets import imdb (x_train, y_train), (x_test, y_test) = imdb.load_data()
40種類の人間の顔を撮影した240枚の画像. 58個の顔ランドマークが付いている.
URL: http://www2.imm.dtu.dk/pubdb/pubs/3160-full.html
M. M. Nordstr{\o}m and M. Larsen and J. Sierakowski and M. B. Stegmann, The IMM Face Database - An Annotated Dataset of 240 Face Images
http://www2.imm.dtu.dk/pubdb/edoc/imm3160.pdf
【関連項目】 顔のデータベース
画像のデータセット.アノテーションとしてバウンディングボックスが付けられている.Imbalance の大きさを特徴とする.
次の URL で公開されているデータセット(オープンデータ)である.
URL: https://github.com/visipedia/inat_comp/tree/master/2017
顔検出 (face detection),顔のアラインメント, 顔検証 (face verification), 顔識別 (face identification)の機能を持つ.
InsightFace の GitHub のページ: https://github.com/deepinsight/insightface
【関連項目】 ArcFace 法, Chandrika Deb の顔マスク検出, Dlib の顔検出, face alignment, MobileFaceNets, 顔検出 (face detection)
公式ページ (https://github.com/deepinsight/insightface/tree/master/python-package) に記載の顔検出及び年齢と性別の予測のプログラムを変更して実行.
このプログラムは buffalo_l という名前の事前学習済みモデルを使用している.
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
GPU を使わない場合には「onnxruntime-gpu」でなく,「onnxruntime」をインストールすること.
!pip3 install -U insightface onnxruntime-gpu opencv-python numpy
動作確認のため,公式ページ (https://github.com/deepinsight/insightface/tree/master/python-package) に記載の,顔検出及び年齢と性別の予測のプログラムを実行する.
このプログラムは buffalo_l という名前の事前学習済みモデルを使用している.
このプログラムの実行により,result.jpg ファイルができる.
import cv2 import numpy as np %matplotlib inline import matplotlib.pyplot as plt import warnings warnings.filterwarnings('ignore') # Suppress Matplotlib warnings import insightface from insightface.app import FaceAnalysis from insightface.data import get_image as ins_get_image app = FaceAnalysis(providers=['CUDAExecutionProvider', 'CPUExecutionProvider']) app.prepare(ctx_id=0, det_size=(640, 640)) img = ins_get_image('t1') faces = app.get(img) rimg = app.draw_on(img, faces) for i in faces: print("gender %s, age %d" % (('F' if i['gender'] == 0 else 'M'), i['age'])) plt.style.use('default') plt.imshow(cv2.cvtColor(rimg, cv2.COLOR_BGR2RGB)) plt.show() cv2.imwrite("./result.jpg", rimg)
顔の画像ファイルは何でも良いが,ここでは,画像ファイルをダウンロードしている.
!curl -O https://www.kkaneko.jp/sample/face/3284.png !curl -O https://www.kkaneko.jp/sample/face/3285.png !curl -O https://www.kkaneko.jp/sample/face/3287.png !curl -O https://www.kkaneko.jp/sample/face/3288.png !curl -O https://www.kkaneko.jp/sample/face/3289.png !curl -O https://www.kkaneko.jp/sample/face/3290.png
いま準備した画像ファイルについて,顔検出及び年齢と性別の予測の実行
import cv2 import numpy as np %matplotlib inline import matplotlib.pyplot as plt import warnings warnings.filterwarnings('ignore') # Suppress Matplotlib warnings import insightface from insightface.app import FaceAnalysis from insightface.data import get_image as ins_get_image app = FaceAnalysis(providers=['CUDAExecutionProvider', 'CPUExecutionProvider']) app.prepare(ctx_id=0, det_size=(640, 640)) files = ['3284.png', '3285.png','3287.png', '3288.png', '3289.png', '3290.png'] for f in files: img = cv2.imread(f) faces = app.get(img) for i in faces: print("gender %s, age %d" % (('F' if i['gender'] == 0 else 'M'), i['age'])) rimg = app.draw_on(img, faces) plt.style.use('default') plt.imshow(cv2.cvtColor(rimg, cv2.COLOR_BGR2RGB)) plt.show()
別ページ »で説明している.
別ページ »で説明している.
Iris データセットは公開されているデータセット(オープンデータ)である.
【文献】
R.A. Fisher, The use of multiple measurements in taxonomic problems, Annual Eugenics, 7, Part II, pp. 179-188, 1936.
【サイト内の関連ページ】
【関連する外部ページ】
URL: https://github.com/google/jax
Ubuntu でインストールを行うには,次のコマンドを実行.
sudo apt -y install python3-pip sudo pip3 install -U "jax[cuda111]" -f https://storage.googleapis.com/jax-releases/jax_releases.html
画像数は 4822枚である. 各画像の人物数は 0 から 25791 である.
Vishwanath A Sindagi, Rajeev Yasarla, and Vishal M Pa- tel. Jhu-crowd++: Large-scale crowd counting dataset and a benchmark method. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2020.
【関連用語】 crowd counting, FIDTM, オープンデータ
国別,地域別の感染者データ
URL: https://github.com/CSSEGISandData/COVID-19
次の Python プログラムは, Johns Hopkins 大の COVID-19 データレポジトリからデータをダウンロードし,ロードし,表示する.
!curl -LO https://github.com/CSSEGISandData/COVID-19/raw/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv import pandas as pd df = pd.read_csv("./time_series_covid19_confirmed_global.csv") display(df) display(df.groupby(['Country/Region'], as_index=False).sum())
【関連項目】 時系列データ
Jupyter Lab は Python プログラム作成に関する種々の機能を持ったソフトウェア.
JupyterLab について:別ページ で説明している.
Jupyter Qt Console は Python コンソールの機能を持ったソフトウェア.
Jupyter Qt Console について:別ページ で説明している.
Jupyter ノートブックは,Pythonなどのプログラムのソースコード,実行結果などを1つのノートとして残す機能をもったノートブック.
Jupyter ノートブック について:別ページ で説明している.
Keras は 機械学習のAPI の機能を持つ. Python 言語から利用可能. TensorFlow, CNTK, Theano など,さまざまなディープラーニングのフレームワークの上で動く.
Keras の概要
次のプログラムでは,損失関数を, categorical crossentropy, 最適化法を 確率的勾配降下法 (SGD 法), 尺度を accuracy に設定している.
m.compile(optimizer=tf.keras.optimizers.SGD(lr=0.01, momentum=0.9, nesterov=True), loss='sparse_categorical_crossentropy', metrics=['accuracy'])
※ 目的関数については: https://keras.io/ja/objectives/
【関連する外部ページ】
【サイト内の関連ページ】
【関連項目】 Applications of Deep Neural Networks, TensorFlow, ディープラーニング
Avatar Erik Linder-Norén により GitHub で公開されているKeras-GAN のページ.
URL は次の通り.
Keras-GAN のページ: https://github.com/eriklindernoren/Keras-GAN  
次のプログラムの中の kernel_initializer の部分. 標準偏差を 0.01 になるように重みを設定している.
【Keras のプログラム】
m.add(Dense(units=100, input_dim=len(768[0])), kernel.iniializer.TruncatedNormal(stddev=0.01))
教師データ x_train と y_train (x_train は入力データの numpy 配列もしくは numpy 配列のリスト,y_train はクラス番号の numpy 配列)を用いて, バッチサイズが 32,エポック数を 10 として学習したいときには,次のコマンドを用いる.
【Keras のプログラム】
history = m.fit(x_train, y_train, batch_size=32, epochs=50, validation_data=(x_test, y_test))
Keras での学習において,「validation_data」を付けることで,検証(バリデーション)が行われる.
このとき,検証(バリデーション)に使うデータ(x_test, y_test)をいろいろ変えながら,Kerasでの検証(バリデーション)を行う.
【Keras のプログラム】
history = m.fit(x_train, y_train, batch_size=32, epochs=50, validation_data=(x_test, y_test))
結果(上のプログラムでは history)を見て,過学習や学習不足を判断する.history は次のようなプログラムで表示できる.
【Keras のプログラム】
import pandas as pd h = pd.DataFrame(history.history) h['epoch'] = history.epoch print(h)
Keras のモデルのコンパイルにおいては, オプティマイザ(最適化器)と 損失関数とメトリクスの指定を行う必要がある.
Keras でのモデル m のコンパイルのプログラムは「m.compile」のように書く.
データセットは,データの集まりのこと. Python の keras には,次のデータセットを簡単にダウンロードできる機能がある.
CIFAR-10 データセットは,次のプログラムでロードできる.
【Keras のプログラム】
from tensorflow.keras.datasets import cifar10 (x_train, y_train), (x_test, y_test) = cifar10.load_data()
CIFAR-100 データセットは,次のプログラムでロードできる.
【Keras のプログラム】
from tensorflow.keras.datasets import cifar100 (x_train, y_train), (x_test, y_test) = cifar100.load_data(label_mode='fine')
IMDb データセットは,次のプログラムでロードできる.
【Keras のプログラム】
from tensorflow.keras.datasets import imdb (x_train, y_train), (x_test, y_test) = imdb.load_data()
Reuters newswire topics データセットは,次のプログラムでロードできる.
【Keras のプログラム】
from tensorflow.keras.datasets import reuters (x_train, y_train), (x_test, y_test) = reuters.load_data()
MNIST データセットは,次のプログラムでロードできる.
【Keras のプログラム】
from tensorflow.keras.datasets import mnist (x_train, y_train), (x_test, y_test) = mnist.load_data()
Fashion MNIST データセットは,次のプログラムでロードできる.
【Keras のプログラム】
from tensorflow.keras.datasets import fashion_mnist (x_train, y_train), (x_test, y_test) = fashion_mnist.load_data()
Boston housing price 回帰データセットは,次のプログラムでロードできる.
【Keras のプログラム】
from tensorflow.keras.datasets import boston_housing (x_train, y_train), (x_test, y_test) = boston_housing.load_data()
keras に付属のデータセットを取得するときのオプションについては, https://keras.io/ja/datasets/(日本語版), https://keras.io/api/datasets/(英語版) に説明されている.
【関連項目】 Boston housing price 回帰データセット, CIFAR-10 データセット, CIFAR100 データセット, IMDb データセット, Reuters newswire topics データセット, MNIST データセット, Fashion MNIST データセット  
Keras の応用としては, MobileNetV2, Inception-ResNet, ResNet50, DenseNet121, DenseNet169, NASNetなどの画像分類のモデルがある. (その詳細は,https://keras.io/ja/applications/)
Keras では,これらモデルについて,ImageNet データセット での学習済みモデルを,次のようなプログラムで,簡単に使えるようにすることができる.
【Keras のプログラム】
from tensorflow.keras.applications.mobilenet_v3 import MobileNetV3 m = MobileNetV3(weights='imagenet')
【関連項目】 ResNet50, ResNet101, ResNet152, その他の ResNet, Inception-ResNet, DenseNet121, DenseNet169, NASNet, MobileNetV2
Keras で利用可能な画像分類のモデルは,https://keras.io/api/applications/index.html で説明されている.
400/600/700 種類の人間の行動をカバーする最大65万のビデオクリップの URL リンク集とアノテーションである. それぞれのクリップには,1つの行動クラスがアノテーションされている. ビデオの長さは,約10秒である. 機械学習による行動分類,行動認識,ビデオ検索などの学習や検証に利用できるデータセットである.
ディープラーニングで,人間の行動推定に利用できる.
Kinetics データセット >は次の URL で公開されているデータセット(オープンデータ)である.
https://deepmind.com/research/open-source/kinetics
【関連情報】
W. Kay, J. Carreira, K. Simonyan, B. Zhang, C. Hillier, S. Vijayanarasimhan, F. Viola, T. Green, T. Back, P. Natsev, M. Suleyman, and A. Zisserman. The kinetics human action video dataset. arXiv preprint arXiv:1705.06950, 2017.
次のコマンドは Google Colaboratory で動く(コードセルを作り,実行する).
!curl -O https://storage.googleapis.com/deepmind-media/Datasets/kinetics700_2020.tar.gz !tar -xvzof kinetics700_2020.tar.gz !ls kinetics700_2020
mkdir c:\data mkdir c:\data\kinetics cd c:\data\kinetics curl -O https://storage.googleapis.com/deepmind-media/Datasets/kinetics700_2020.tar.gz "c:\Program Files\7-Zip\7z.exe" x kinetics700_2020.tar.gz "c:\Program Files\7-Zip\7z.exe" x kinetics700_2020.tar
カラーのカメラ,モノクロのステレオカメラ,3次元レーザースキャナなどのさまざまなセンサーのデータから構成される.
http://www.cvlibs.net/datasets/kitti
【関連情報】
車両からの観測画像と車両の自己位置のデータ.ビジュアルオドメトリに使用.
URL: https://github.com/uoip/monoVO-python
テスト画像データをダウンロードしたい.再度,uoip / monoVO-python の Web ページを開く
これは,画像データの .zip ファイルである(多数の .png形式の画像ファイルを zip 形式に固めたものである).
※ ダウンロードには時間がかかる
この .zip ファイルは,C:\data_odometry_gray\dataset に展開(解凍)したものとして,説明を続けるので,適切に読み替えてください.
https://github.com/navoshta/KITTI-Dataset
https://github.com/utiasSTARS/pykitti
K 近傍探索 (K nearest neighbour)のアルゴリズムは,次の性質を持つ.
【関連項目】 Fast-Robust-ICP, libnabo, libpointmatcher
ks_1033_data は,次のページで CSV ファイルと Excel ファイルで公開されているデータセット(オープンデータ)である.
https://github.com/wireservice/csvkit/tree/master/examples/realdata
次のコマンドは Google Colaboratory で動く(コードセルを作り,実行する).
!curl -O https://github.com/wireservice/csvkit/tree/master/examples/realdata/ks_1033_data.csv !ls -al ks_1033_data.csv
正則化の一手法である. L2 正則化では,重みの二乗の合計に比例したペナルティを,重みに与える.
L2 正則化を行う Keras のプログラム
L2 正則化を行いたいときは 次のようにする.
import tensorflow.compat.v2 as tf tf.keras.layers.Dense(128, activation='relu', kernel_regularizer=tf.keras.regularizers.l2(0.001))
LabelMe インタフェースは,アノテーションのツール.
Russell BC, Torralba A, Murphy KP, Freeman WT, Labelme: a database and web-based tool for image annotation. Int’l Journal of Computer Vision, 2008.
【関連項目】 アノテーション (annotation)
公式ページ https://github.com/wkentaro/labelmeの記載に従う.
Windows では,コマンドプロン プトを管理者として実行し, 次のコマンドを実行する.
python -m pip install labelme
LAION-2B の画像数は約20億枚. LAION-5B の画像数は約50億枚.
【関連する外部ページ】
LAION の公式ページ: https://laion.ai/
LaMa は,Image Inpainting (イメージ・インペインティング)のための技術である.2021年発表.
Image Inpainting (イメージ・インペインティング) 画像の欠落部分を補うことで,画像の中の不要な部分を消すときにも役立つ.
LaMa のデモページ
【関連項目】 image inpainting
Windows での Lama Cleaner のインストール: 別ページで説明してリウ.
lapack は,行列に関する種々の問題(連立1次方程式,固有値問題,などなど多数)を解く機能を持つソフトウェア.BLAS の機能を使う.
netlib の lapack のページ: http://www.netlib.org/lapack
lapack 参照実装の Web ページ: https://github.com/Reference-LAPACK/lapack-release
【関連項目】 BLAS, clapack, OpenBLAS
Windows での LAPACK のインストール(Windows 上): 別ページ »で説明している.
Ubuntu でインストールを行うには,次のコマンドを実行.
sudo apt -y update sudo apt -y install libopenblas-dev liblapack-dev
dgeev()関数 (固有値と固有ベクトル)を使用.
#include<stdio.h> // CLAPACK ではなく LAPACK を直接呼び出す. // CLAPACK については,次の URL を見よ. // see http://www.netlib.org/clapack/clapack.h // ?geev : simple driver for eigenvalues/vectors // 決まり文句 (CLAPACK との互換用) #define doublereal double #define integer long int extern integer dgeev_(char *jobvl, char *jobvr, integer *n, doublereal *a, integer *lda, doublereal *wr, doublereal *wi, doublereal *vl, integer *ldvl, doublereal *vr, integer *ldvr, doublereal *work, integer *lwork, integer *info); integer eigenvalues( integer n, doublereal *a, doublereal *wr, doublereal *wi ) { /* LAPACK の _dgeev() を使って固有値(だけ)を求める */ integer n3 = n * n * n; integer info; doublereal *vl = (doublereal *)calloc(sizeof(doublereal), n * n); doublereal *vr = (doublereal *)calloc(sizeof(doublereal), n * n); doublereal *work = (doublereal *)calloc(sizeof(doublereal), n3); (void) dgeev_( /* char *jobvl */ "N", /* "N" なので左固有ベクトルを計算しない */ /* char *jobvr */ "N", /* "N" なので右固有ベクトルを計算しない */ /* integer *n */ &n, /* 正方行列の次数 */ /* doublereal *a, */ a, /* A */ /* integer *lda, */ &n, /* A 用の作業領域 */ /* doublereal *wr, */ wr, /* 固有値の実部 */ /* doublereal *wi, */ wi, /* 固有値の虚部 */ /* doublereal *vl, */ vl, /* 左固有値 */ /* integer *ldvl, */ &n, /* 左固有値の作業用 */ /* doublereal *vr, */ vr, /* 右固有値 */ /* integer *ldvr, */ &n, /* 左固有値の作業用 */ /* doublereal *work, */ work, /* 作業用 */ /* integer *lwork, */ &n3, /* 作業用の行列の次元 */ /* integer *info */ &info); free( work ); free( vr ); free( vl ); return info; } integer eigenvalues_rightvectors( integer n, doublereal *a, doublereal *wr, doublereal *wi, doublereal *vr ) { /* LAPACK の _dgeev() を使って固有値と右固有ベクトルを求める */ /* A * v(j) = lambda(j) * v(j), v(j) is the right eigen vector */ integer n3 = n * n * n; integer info; doublereal *vl = (doublereal *)calloc(sizeof(doublereal), n * n); doublereal *work = (doublereal *)calloc(sizeof(doublereal), n3); (void) dgeev_( /* char *jobvl */ "N", /* "N" なので左固有ベクトルを計算しない */ /* char *jobvr */ "V", /* "V" なので右固有ベクトルを計算する */ /* integer *n */ &n, /* 正方行列の次数 */ /* doublereal *a, */ a, /* A */ /* integer *lda, */ &n, /* A 用の作業領域 */ /* doublereal *wr, */ wr, /* 固有値の実部 */ /* doublereal *wi, */ wi, /* 固有値の虚部 */ /* doublereal *vl, */ vl, /* 左固有値 */ /* integer *ldvl, */ &n, /* 左固有値の作業用 */ /* doublereal *vr, */ vr, /* 右固有値 */ /* integer *ldvr, */ &n, /* 左固有値の作業用 */ /* doublereal *work, */ work, /* 作業用 */ /* integer *lwork, */ &n3, /* 作業用の行列の次元 */ /* integer *info */ &info); free( work ); free( vl ); return info; } int main( integer argc, char **argv ) { int i; integer n = 10; doublereal *a = (doublereal *)calloc(sizeof(doublereal), n * n); doublereal *wr = (doublereal *)calloc(sizeof(doublereal), n); doublereal *wi = (doublereal *)calloc(sizeof(doublereal), n); /* doublereal *vr = (doublereal *)calloc(sizeof(doublereal), n * n); */ eigenvalues( n, a, wr, wi ); for(i = 0; i < n; i++) { printf("%5d %15.7e %15.7e\n", i + 1, *(wr + i), *(wi + i)); } free(wi); free(wr); free(a); return 0; }
スポーツ選手を中心としで,Flickr から収集した2000枚の画像に, 姿勢(ポース)についてのアノテーションを行ったもの. 最も目立つ人物が,およそ150ピクセルになるようにスケーリングされている. 各画像には,14個のジョイント(関節)の位置がアノテーションされている. オリジナル画像の帰属 (attribution) とFlickrのURLは,各画像ファイルのJPEGコメントに記載されている.
ディープラーニングにより姿勢推定を行うためのデータとして利用できる.
次の URL で公開されているデータセット(オープンデータ)である.
URL: https://dbcollection.readthedocs.io/en/latest/datasets/leeds_sports_pose_extended.html
【関連情報】
Sam Johnson, and Mark Everingham. Clustered Pose and Nonlinear Appearance Models for Human Pose Estimation. In Frédéric Labrosse, Reyer Zwiggelaar, Yonghuai Liu, and Bernie Tiddeman, editors, Proceedings of the British Machine Vision Conference, pages 12.1-12.11. BMVA Press, September 2010. doi:10.5244/C.24.12.
http://www.bmva.org/bmvc/2010/conference/paper12/paper12.pdf
https://github.com/open-mmlab/mmpose/blob/master/docs/en/tasks/3d_body_mesh.md#lsp
次のコマンドは Google Colaboratory で動く(コードセルを作り,実行する).
!curl -O http://sam.johnson.io/research/lsp_dataset.zip !curl -O http://sam.johnson.io/research/lspet_dataset.zip !unzip lsp_dataset.zip -d lsp_dataset !unzip lspet_dataset.zip -d lspet_dataset !ls -la lspet_dataset
アノテーションファイルは,次の URL からダウンロードできる.
https://drive.google.com/file/d/1GZxlTLuMfA3VRvz2jyv8fhJDqElNrgKS/view
Windows の場合.次により c:\data\lsp にダウンロードされる.
mkdir c:\data mkdir c:\data\lsp mkdir c:\data\lsp\images cd c:\data\lsp\images curl -O http://sam.johnson.io/research/lsp_dataset.zip curl -O http://sam.johnson.io/research/lspet_dataset.zip powershell -command "Expand-Archive -DestinationPath . -Path lsp_dataset.zip" powershell -command "Expand-Archive -DestinationPath . -Path lspet_dataset.zip"
アノテーションファイルは,次の URL からダウンロードできる.
https://drive.google.com/file/d/1GZxlTLuMfA3VRvz2jyv8fhJDqElNrgKS/view
Ubuntu の場合.次により,/usr/local/data/lsp/images にダウンロードされる.
mkdir -p /usr/local/data/lsp/images cd /usr/local/data/lsp/images curl -O http://sam.johnson.io/research/lsp_dataset.zip curl -O http://sam.johnson.io/research/lspet_dataset.zip unzip lsp_dataset.zip -d lsp_dataset unzip lspet_dataset.zip -d lspet_dataset
アノテーションファイルは,次の URL からダウンロードできる.
https://drive.google.com/file/d/1GZxlTLuMfA3VRvz2jyv8fhJDqElNrgKS/view
LFWデータセットには,「in-the-wild」のラベル付きの顔のデータベースである. 合計で 13,233枚,5,749人の顔画像が含まれている.
機械学習による顔認識の学習や検証に利用できるデータセットである.
Gary B. Huang, Marwan Mattar, Tamara Berg, Eric Learned-Miller. Labeled Faces in the Wild: A Database for Studying Face Recognition in Unconstrained Environments. Workshop on Faces in ’Real-Life’ Images: Detection, Alignment, and Recognition, Erik Learned-Miller and Andras Ferencz and Frdric Jurie, Oct 2008, Marseille, France. inria-00321923
【関連項目】 顔認識 (face recognition), 顔のデータベース
libc++ は,C++ の標準ライブラリである.
【関連する外部ページ】
【関連項目】 LLVM
Windows での libiconv のインストール(Windows 上): 別ページ »で説明している.
libnabo は,K 近傍探索 (K nearest neighbour) の機能を持つライブラリ.
ANN よりも高速だとされている.
Elseberg, J. and Magnenat, S. and Siegwart, R. and N{\"u}chter, A., Comparison of nearest-neighbor-search strategies and implementations for efficient shape registration, Journal of Software Engineering for Robotics (JOSER), pages 2-12, vol. 3, no. 1, 2012.
【関連項目】 K 近傍探索 (K nearest neighbour)
https://github.com/CAOR-MINES-ParisTech/libpointmatcher/blob/master/doc/CompilationWindows.md の手順に従う.
Git の公式ページ: https://git-scm.com/
Visual Studio の x64 Native Tools コマンドプロンプトを管理者として実行する. 次のコマンドを実行する.
c:\libnabo にインストールされる.
cd %LOCALAPPDATA% rmdir /s /q libnabo git clone --recursive https://github.com/ethz-asl/libnabo cd libnabo rmdir /s /q build mkdir build cd build del CMakeCache.txt cmake -G "Visual Studio 17 2022" -T host=x64 ^ -DCMAKE_BUILD_TYPE=Release ^ -DCMAKE_INSTALL_PREFIX="c:/libnabo" ^ -DEIGEN_INCLUDE_DIR="c:/eigen/include/eigen3" ^ -DLIBNABO_BUILD_PYTHON=OFF ^ -DCMAKE_BUILD_TYPE=RelWithDebInfo ^ .. msbuild /m:2 libnabo.sln -p:Configuration=Release
Visual Studio の x64 Native Tools コマンドプロンプトを管理者として実行する. 次のコマンドを実行する.
c:\libnabo にインストールされる.
cd %LOCALAPPDATA%\libnabo\examples del CMakeCache.txt cmake -G "Visual Studio 17 2022" -T host=x64 ^ -DCMAKE_BUILD_TYPE=Release ^ -DCMAKE_INSTALL_PREFIX="c:/libnabo" ^ -DEIGEN_INCLUDE_DIR="c:/eigen/include/eigen3" ^ -DLIBNABO_BUILD_PYTHON=OFF ^ -DCMAKE_BUILD_TYPE=RelWithDebInfo ^ .. msbuild /m:2 libnabo.sln -p:Configuration=Release
Ubuntu でインストールを行うには,次のコマンドを実行.
/usr/local/libnabo にインストールされる.
sudo apt -y update sudo apt -y install libboost-all-dev libeigen3-dev git cmake cmake-curses-gui cmake-gui cd /tmp sudo rm -rf libnabo sudo git clone --recursive https://github.com/ethz-asl/libnabo sudo chown -R $USER libnabo cd /tmp/libnabo mkdir build cd build cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX="/usr/local" \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ .. make sudo make install cd /tmp/libnabo/examples cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX="/usr/local" \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ .. make sudo make install
自分で,C++ のプログラムを書き,liboctave の機能を呼び出すことが簡単にできる.
「clock_t c = clock();」と「fprintf( stderr, "done, elapsed time = %f [sec]", ( (double)clock() - (double)c ) / CLOCKS_PER_SEC ); 」の2行は経過時間の測定のためです.
#include<stdio.h> #include<time.h> #include<octave/config.h> #include<octave/Matrix.h> // 正方行列のサイズを指定 #define DIM 2000 int main( int argc, char **argv ) { fprintf( stderr, "start, \n" ); clock_t c = clock(); // 行列の積と固有値/固有ベクトル Matrix X(DIM, DIM); Matrix Y(DIM, DIM, 1.0); Matrix Z = X * Y; EIG eig(X); fprintf( stderr, "done, elapsed time = %f [sec]", ( (double)clock() - (double)c ) / CLOCKS_PER_SEC ); return 0; }
Octave の 関数 conv2 を用いて,2次元の畳み込み(コンボリューション)を行う.
関数 conv2 は,Octave ソースコードの DLD-FUNCTIONS/conv2.cc で定義されているので,「#include<octave/conv2.cc>」を含める.
「clock_t c = clock();」と「fprintf( stderr, "done, elapsed time = %f [sec]", ( (double)clock() - (double)c ) / CLOCKS_PER_SEC ); 」の2行は経過時間の測定のため.
// liboctave を用いた 2次元畳み込み(コンボリューション) #include<stdio.h> #include<time.h> #include<octave/config.h> #include<octave/Matrix.h> #include<octave/conv2.cc> // 正方行列のサイズを指定 #define DIM 2000 #define DIM2 21 int main( int argc, char **argv ) { printf( "start, \n" ); clock_t c = clock(); MArray2<double> a(DIM, DIM); MArray2<double> b(DIM2, DIM2); MArray<double> r(DIM, DIM); r = conv2(a, b, SHAPE_FULL); printf( "done, elapsed time = %f [sec]", ( (double)clock() - (double)c ) / CLOCKS_PER_SEC ); return 0; }libpointmatcher
Iterative Closest Point (ICP) の機能を持ち, 点群 (point cloud) のアラインメントを行うことができる. point-to-point の ICP と,point-to-plane ICP の機能を持つ. point-to-point の ICP では,剛体変換だけでなく,スケールの変更にも対応している.
François Pomerleau, Francis Colas, Roland Siegwart, Stéphane Magnenat, Comparing ICP Variants on Real-World Data Sets, Autonomous Robots, vol. 34, no. 3, pages: 133-148, 2013.
François Pomerleau, Stéphane Magnenat, Francis Colas, Ming Liu, Roland Siegwart, Tracking a Depth Camera: Parameter Exploration for Fast ICP, Proc. of the IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), IEEE Press, pages: 3824-3829, 2011.
【関連項目】 K 近傍探索 (K nearest neighbour), ICP
https://github.com/CAOR-MINES-ParisTech/libpointmatcher/blob/master/doc/CompilationWindows.md の手順に従う.
Git の公式ページ: https://git-scm.com/
CMake の公式ダウンロードページ: https://cmake.org/download/
次のコマンドで確認する.ここで確認したことは,のちほど,使用する.
dir "c:\boost\build\include"
Visual Studio の x64 Native Tools コマンドプロンプトを管理者として実行する. 次のコマンドを実行する.
エラーを回避するために「/bigobj」を設定.
c:\libpointmatcher にインストールされる.
「boost-1_83」のところは,先ほど確認したインクルードディレクトリに一致させること.
cd %LOCALAPPDATA% rmdir /s /q libpointmatcher git clone --recursive https://github.com/ethz-asl/libpointmatcher cd libpointmatcher rmdir /s /q build mkdir build cd build del CMakeCache.txt cmake -G "Visual Studio 17 2022" -T host=x64 ^ -DCMAKE_BUILD_TYPE=Release ^ -DCMAKE_INSTALL_PREFIX="c:/libpointmatcher" ^ -DEIGEN_INCLUDE_DIR="c:/eigen/include/eigen3" ^ -DBoost_USE_STATIC_LIBS=ON ^ -DBOOST_ROOT="c:/boost/build" ^ -DBoost_INCLUDE_DIR="c:/boost/build/include/boost-1_83" ^ -DBoost_DIR="c:/boost/build" ^ -Dlibnabo_DIR="%LOCALAPPDATA%/libnabo/build" ^ -DCMAKE_BUILD_TYPE=RelWithDebInfo ^ -DCMAKE_C_FLAGS="/DWIN32 /D_WINDOWS /W0 /utf-8 /bigobj" ^ -DCMAKE_CXX_FLAGS="/DWIN32 /D_WINDOWS /GR /EHsc /W0 /utf-8 /bigobj" ^ .. msbuild /m:2 libpointmatcher.sln -p:Configuration=Release
公式ページの https://github.com/CAOR-MINES-ParisTech/libpointmatcher/blob/master/doc/CompilationWindows.md
libnabo のインストール が必要.
Ubuntu でインストールを行うには,次のコマンドを実行.
/usr/local/libpointmatcher にインストールされる.
sudo apt -y update sudo apt -y install libboost-all-dev libeigen3-dev git cmake cmake-curses-gui cmake-gui cd /tmp sudo rm -rf libpointmatcher git clone --recursive https://github.com/ethz-asl/libpointmatcher sudo chown -R $USER libpointmatcher cd /tmp/libpointmatcher mkdir build cd build cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX="/usr/local" \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ .. make sudo make install
librosa は, 音声,音楽の機能をもった Python のパッケージである. 主な機能としては,音源分離(music source separation),スペクトログラム, 音声ファイルの読み込み,テンポ(tempo)の推定がある.
【文献】
McFee, Brian, Colin Raffel, Dawen Liang, Daniel PW Ellis, Matt McVicar, Eric Battenberg, and Oriol Nieto. “librosa: Audio and music signal analysis in python.” In Proceedings of the 14th python in science conference, pp. 18-25. 2015.
【関連する外部ページ】
【関連項目】 short-time Fourier transform, 音声, 音楽, sound, 音データ(sound data)
次のプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
次のプログラムは,librosa に付属の音声データである trumpet について,パワースペクトログラムを表示する. 次のプログラムでは,横軸は時間,縦軸は線形スケール(linear scale)で表された周波数である パワースペクトログラムを表示する. stft は short-time Fourier transform を行う. そして,その振幅により色をプロットする.
ここのプログラムのソースコードは, http://librosa.org/doc/main/auto_examples/plot_display.html#sphx-glr-auto-examples-plot-display-py のものを使用(ISC ライセンス).
import numpy as np %matplotlib inline import matplotlib.pyplot as plt import warnings warnings.filterwarnings('ignore') # Suppress Matplotlib warnings import librosa import librosa.display y, sr = librosa.load(librosa.ex('trumpet')) D = librosa.stft(y) # STFT of y S_db = librosa.amplitude_to_db(np.abs(D), ref=np.max) plt.figure() librosa.display.specshow(S_db, x_axis='time', y_axis='linear', sr=sr) plt.colorbar()
librosa のインストールと動作確認(音声処理)(Python を使用)(Windows 上): 別ページ »で説明している.
Ubuntu での librosa のインストールは,次のようなコマンドで行う.
sudo apt -y install ffmpeg sudo pip3 install -U numba librosa
インストールするバージョンを指定する場合には,次のように操作する. 「==」のあとはバージョン指定であり,使用したいバージョンを指定する.
sudo apt -y install ffmpeg sudo pip3 install -U numba==0.48.0 librosa==0.7.0
ソースコードを使用してインストールする場合には次のように操作する.
sudo apt -y install ffmpeg sudo pip3 install git+https://github.com/librosa/librosa
LLD は,高速に動作するリンカーの機能を持つ.
【関連する外部ページ】
【サイト内の関連ページ】
【関連項目】 LLVM
LLaMA (Large Language Model Meta AI) は,Meta によって開発された大規模言語モデル (large language model) である. LLaMA には,パラメーター数が7B、13B、33B、65B(1Bは10億)の4つのバージョンがある.
【文献】
Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, Aurelien Rodriguez, Armand Joulin, Edouard Grave, Guillaume Lample, LLaMA: Open and Efficient Foundation Language Models, https://arxiv.org/abs/2302.13971v1
【関連する外部ページ】
【関連項目】 大規模言語モデル
LLDB は,デバッガの機能を持つ.
【関連する外部ページ】
【サイト内の関連ページ】
【関連項目】 LLVM
LLVM には,コンパイラ,ツールチェーンに関するさまざまなサブプロジェクトとして, LVM Core, Clang, LLD, LLDB, libc++ などのサブプロジェクトがある.
【サイト内の関連ページ】
【関連する外部ページ】
【関連項目】 Clang, libc++, LLD, LLDB
Windows での LLVM のインストールには,複数の方法がある.次のいずれかによりインストールできる.
12.0.1 のところは,インストールしたいバージョン番号を指定すること.
curl -LO https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.1/LLVM-12.0.1-win64.exe .\LLVM-12.0.1-win64.exe
Ubuntu でインストールを行うには,次のコマンドを実行.
sudo apt -y update sudo apt -y install llvm
Linux では,locate コマンドを用いてファイル検索を行うことができる.
mlocate に m が付いているのは書き間違いではない.
LoRA は大規模言語モデルの学習の手法の1つである. LoRA は, 大規模言語モデルの学習において,ランク分解行列のペアを用いた学習を特徴とする. 学習可能なパラメータの数を削減を可能にしている. 具体的には,ランク分解行列のペアを用いることで,元の重み行列を低ランクな行列の積として近似することができ,これによって,元の重み行列の次元数を削減し,学習可能なパラメータ数を削減することができる.
【関連項目】 大規模言語モデル
画像の類似尺度.Richard Zhang らにより 2018年に提案された.
公式ページには,次の Python プログラムのソースコードが掲載されている.
import lpips loss_fn_alex = lpips.LPIPS(net='alex') # best forward scores loss_fn_vgg = lpips.LPIPS(net='vgg') # closer to "traditional" perceptual loss, when used for optimization import torch img0 = torch.zeros(1,3,64,64) # image should be RGB, IMPORTANT: normalized to [-1,1] img1 = torch.zeros(1,3,64,64) d = loss_fn_alex(img0, img1)
このソースコードの Google Colaboratory での実行結果は次の通りである.
Richard Zhang, Phillip Isola, Alexei A. Efros, Eli Shechtman, Oliver Wang, The Unreasonable Effectiveness of Deep Features as a Perceptual Metric, CVPR 2018, also CORR, abs/1801.03924v2
【関連項目】SSIM
LReLU (Leaky rectified linear unit) は,次の関数である.
f(x) = x (x>=0), alpha * x (x<0)
LReLUは,活性化関数としてよく使用されるもののうちの1つである. 活性化関数は,ニューロンの入力の合計から,そのニューロンの活性度の値を決めるためのもの. (他には,ReLU,シグモイド関数,ステップ関数,ソフトマックス関数などがある.
LS3D-W データセットは,3次元の顔ランドマーク (facial landmark)のデータセット.
これは,AFLW,300VW,iBUG 300-W,FDDB の顔画像から生成されたデータセットである.
利用には, https://www.adrianbulat.com/face-alignment での申請を必要とする.
生成手順については,次の文献に記載されている
Bulat, Adrian and Tzimiropoulos, Georgios, International Conference on Computer Vision, 2017, https://openaccess.thecvf.com/content_ICCV_2017/papers/Bulat_How_Far_Are_ICCV_2017_paper.pdf
【関連項目】 顔ランドマーク (facial landmark)
LSTM 層を含むようなニューラルネットワークは,次の特徴を持つ
【関連項目】 Applications of Deep Neural Networks, ディープラーニング, リカレントニューラルネットワーク
LSTM 層では,内部に「状態」を維持する. 状態は,ニューロンの動作のたびに変化するものである. (ふつうのニューロンでは,入力の値から出力が計算される.「状態」という考え方はない). LSTM 層のニューロンは,今の入力,1つ前の時間の入力,1つ前の時間での状態から出力を求める.
LSUN (Large-scale Scene UNderstanding Challenge) データセット は, ラベル付きの画像データセットである. 機械学習での画像分類や画像生成の学習や検証に利用できるデータセット.
【関連情報】
Fisher Yu, Ari Seff, Yinda Zhang, Shuran Song, Thomas Funkhouser and Jianxiong Xiao, LSUN: Construction of a Large-scale Image Dataset using Deep Learning with Humans in the Loop, arXiv:1506.03365
【関連項目】 顔のデータベース
シーン解析(scene parsing),インスタンス・セグメンテーション (instance segmentation)のデータセット
URL: https://www.lvisdataset.org/
【関連項目】 インスタンス・セグメンテーション (instance segmentation), オープンデータ, シーン解析(scene parsing)
MagickWand プログラムの実行
MagickWand のサイトから wand.c を入手.
このプログラムは,サムネイル画像を生成するプログラム.
以下のコマンドを実行.
gcc `MagickWand-config --cflags --cppflags` -o wand.exe wand.c `MagickWand-config --ldflags --libs`
または
gcc -I/usr/include/ImageMagick -o wand.exe wand.c -L/usr/lib -L/usr/X11R6/lib -lMagickWand -lMagickCore -lfreetype -lz
wand.c は,画像ファイルから,サムネイル(縮小画像)を作るプログラム.
次のコマンドにより実行.
./wand.exe <画像ファイル名> <サムネイル・ファイル名>
【関連項目】 ImageMagick
Whisper でのマイクの使用を可能にする. 利用可能な言語モデルは,tiny,base,small,medium,large
【関連項目】 Whisper
機械学習による物体検出では, 「mAP」は,「mean average precision」の意味である.
ストリート(街角)の25,000 枚の画像. インスタンスレベルのアノテーション, 124 のセマンティッククラス.
次の URL で公開されているデータセット(オープンデータ)である.
URL: https://www.mapillary.com/dataset/vistas
G. Neuhold, T. Ollmann, S. Rota Bulo, and P. Kontschieder. The mapillary vistas dataset for semantic understanding of street scenes. In ICCV, 2017.
【関連項目】 セマンティック・セグメンテーション (semantic segmentation), インスタンス・セグメンテーション (instance segmentation)
セグメンテーション,物体検出,キーポイント検出等に使用されるモデル.
FPN (Feature Pyramid Network), ResNeXt101 や ResNeXt50 や ResNet101 や ResNet50 を使用.
COCO データセットで学習済みのモデル,Jupyter ノートブック (Jupyter Notebook) のデモ demo.ipynb が公開されている.
【関連項目】 Detectron2, MMDetection, PANet (Path Aggregation Network), 物体検出, セグメンテーション (segmentation), keypoint detection
Jupyter ノートブック (Jupyter Notebook) のデモが付属している.主なものは次の通り. 動作させるには,Mask R-CNN のインストールが終わっていること(下に記載). 学習: train_shapes.ipynb 仕組み: inspect_model.ipynb 重みの視覚化: inspect_weights.ipynb
Git の公式ページ: https://git-scm.com/
cd %LOCALAPPDATA% rmdir /s /q Mask_RCNN git clone --recursive https://github.com/matterport/Mask_RCNN cd Mask_RCNN python -m pip install -U -r requirements.txt python setup.py install
sudo apt -y update sudo apt -y install git cd /usr/local sudo rm -rf Mask_RCNN sudo git clone --recursive https://github.com/matterport/Mask_RCNN sudo chown -R $USER Mask_RCNN # システム Python の環境とは別の Python の仮想環境(システム Python を使用)を作成 sudo apt -y update sudo apt -y install python3-venv python3 -m venv ~/a source ~/a/bin/activate cd /usr/local/Mask_RCNN sudo pip3 install -U -r requirements.txt sudo pip3 list python setup.py install
matplotlib は,オープンソースの Python のプロットライブラリ.
matplotlib を用いた散布図の描画は,別ページ »で説明している.
matplotlib を用いたグラフ描画の例は次の通り.
import numpy as np %matplotlib inline import matplotlib.pyplot as plt import warnings warnings.filterwarnings('ignore') # Suppress Matplotlib warnings x = np.linspace(0, 6, 100) plt.style.use('ggplot') plt.plot(x, np.sin(x))
matplotlib を用いて,OpenCV のカラー画像を表示する例は次の通り.
import cv2 %matplotlib inline import matplotlib.pyplot as plt import warnings warnings.filterwarnings('ignore') # Suppress Matplotlib warnings bgr = cv2.imread("126.png") plt.style.use('default') plt.imshow(cv2.cvtColor(bgr, cv2.COLOR_BGR2RGB)) plt.show()
普通に Matplotlib を用いてOpenCV 画像の表示を表示すると,小さく表示される.
「plt.style.use('default')」の実行により,Matplotlib での OpenCV 画像の表示が大きくなる.
【サイト内の関連ページ】 Matplotlib(Python のまとめページ内)
【関連項目】 display
Windows での matplotlib, seaborn のインストールは, コマンドプロンプトを管理者として開き そのコマンドプロンプトで,次のコマンドを実行することで行う.
python -m pip install -U matplotlib seaborn
Ubuntu での matplotlib, seaborn のインストールは, 次のコマンドを実行することで行う.
sudo apt -y update sudo apt -y install python3-matplotlib python3-seaborn
画像からの物体検出 のための学習法である. 当時の,従来の,単純な物体検出 法よりも高速であり, 他の種々の物体検出 法よりも精度が劣らないとされている. サブサンプリングを行わずに,サブウインドウ(画像分類のために使用されるもの)の全体での最適化を行うことを特徴としている.
Davis E. King, Max-Margin Object Detection, CoRR, abs/1502.00046, 2015.
【関連項目】 物体検出
MeCab は,形態素解析の機能を持ったソフトウェア.
公式ページからダウンロードしてインストールする.その詳細は,別ページ »で説明している.
Merkaartor は, OpenStreetMap の編集ソフトウェア. OpenStreetMap,ESRI Shape データ,Bing,Spatialite を扱う機能がある. Windows 版,Linux 版,Mac OS X 版もある.ソースコードは公開されている.
【サイト内の関連ページ】
【関連する外部ページ】
Merkaartor の公式ページ: http://merkaartor.be
GitHub のページ: https://github.com/openstreetmap/merkaartor/
MeshLab は, 3次元データ(3次元点群データや,メッシュデータ)について表示, 簡易編集, データの間引き, 形式変換, 張り合わせ, 分割, 解析などが行えるソフトウェア
URL: http://meshlab.sourceforge.net/
【関連項目】 メッシュ簡略化 (Mesh Simplification) , メッシュ平滑化 (Mesh Smoothing)
Windows での MeshLab のインストールには,複数の方法がある.次のいずれかによりインストールできる.
詳しくは: 別ページ »で説明
Ubuntu でのインストール: 別ページ »で説明している.
Meshroom は フォトグラメトリ のソフトウェアである. Structure from Motion を,GUI を用いて簡単に行うことができる. 動作画面の一部は次の通りである. カメラの撮影位置と,オブジェクトの3次元形状が表示されている.
meshroom の URL (ここから Meshroom をダウンロード可能): https://alicevision.org/
【関連項目】 3次元再構成 (3D reconstruction), OpenMVG, OpenMMLab, Structure from Motion (SfM)
Windows での Metis のインストール: 別ページ »で説明している. Ubuntu での Metis のインストール: 別ページ »で説明している.
SuiteSparse 5.4.0,Metis 5.1.0 の非公式ビルド: suitesparse.zip
私がビルドしたもの,非公式,無保証, https://github.com/jlblancoc/suitesparse-metis-for-windows/releases で公開されているソースコードを改変せずにビルドした. Windows 10, Visual Build Tools for Visual Studio 2022 を用いてビルドした. BSD ライセンスによる.
zip ファイルは C:\ 直下で展開し,C:\suitesparse での利用を想定.
テキスト検知 (text detection), テキスト認識 (text recognition) の機能を持つ.
文献
Liao, Minghui and Wan, Zhaoyi and Yao, Cong and Chen, Kai and Bai, Xiang, Real-time Scene Text Detection with Differentiable Binarization, Proc. AAAI, 2020.
【関連項目】 テキスト検知 (text detection), テキスト認識 (text recognition)
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
%cd /content !rm -rf DB !git clone https://github.com/MhLiao/DB.git %cd DB !pip3 install -r requirement.txt %cd assets/ops/dcn/ !python3 setup.py build_ext --inplace
ADE20K データセット から派生した, シーン解析(scene parsing) のデータと, オブジェクトのパーツ (object parts) のセグメンテーションのデータ.
次の URL で公開されているデータセット(オープンデータ)である.
http://sceneparsing.csail.mit.edu/
【関連情報】
【関連項目】 ADE20K データセット, CASILVision, セマンティック・セグメンテーション (semantic segmentation), シーン解析(scene parsing), インスタンス・セグメンテーション (instance segmentation)
c:\date 下にダウンロード,展開する.
Windows では,コマンドプロン プトを管理者として実行し, 次のコマンドを実行する.
mkdir c:\data cd c:\data curl -O http://data.csail.mit.edu/places/ADEchallenge/ADEChallengeData2016.zip rmdir /s /q ADEChallengeData2016 powershell -command "Expand-Archive -DestinationPath . -Path ADEChallengeData2016.zip"
ファイルの配置は次のようになる.
ADEChallengeData2016/ annotations/ images/ objectInfo150.txt sceneCategories.txt
MiVOSは、対話型のビデオオブジェクトセグメンテーション(interactive video object segmentation)の新しい手法として提案されている。このシステムはユーザーのインタラクションを取り入れつつ、特定のフレームでのセグメンテーション結果を他のフレームに効果的に伝搬させることができる。インタラクションと伝搬を分離するため、MiVOSはInteraction-to-Mask、Propagation、そしてDifference-Aware Fusionの3つの主要モジュールを採用している。2021年発表。
【文献】
Rethinking Space-Time Networks with Improved Memory Coverage for Efficient Video Object Segmentation, Cheng, Ho Kei and Tai, Yu-Wing and Tang, Chi-Keung, NeurIPS, also arXiv:2106.05210v2, 2021.
https://arxiv.org/pdf/2106.05210v2.pdf
Modular Interactive Video Object Segmentation: Interaction-to-Mask, Propagation and Difference-Aware Fusion, Cheng, Ho Kei and Tai, Yu-Wing and Tang, Chi-Keung, CVPR, also, arXiv:2103.07941v3, 2021.
https://arxiv.org/pdf/2103.07941v3.pdf
【サイト内の関連ページ】
【サイト内の関連ページ】
【関連する外部ページ】
キャラクタと動きのアセットを公開しているサイト.fbx形式でダウンロードできる.
【関連用語】 3次元コンピュータグラフィックス, human pose, human motion
MMAction2 は, OpenMMLab の構成物で,動作認識 (action recognition)の機能を提供する.
MMAction2 Contributors, OpenMMLab's Next Generation Video Understanding Toolbox and Benchmark, https://github.com/open-mmlab/mmaction2, 2020.
【関連項目】 AVA, MMCV, OpenMMLab, PoseC3D, Spatio-Temporal Action Recognition, Temporal Segment Networks (TSN), スケルトンベースの動作認識 (skelton-based action recognition), 動作認識 (action recognition)
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
インストール手順は, https://mmcv.readthedocs.io/en/latest/get_started/installation.html に記載の手順による
MMTracking が MMVC 1.6.2 に依存している (2023年4月時点). MMTracking の利用を想定して MMCV 1.6.2 をインストールする.
!python -c "import torch; print(torch.__version__)" !apt remove python3-pycocotools !pip uninstall -y pycocotools !pip install mmpycocotools !apt install -y python3-terminaltables !apt install -y python3-opencv !pip install mmcv-full==1.6.2 !python3 -c "from mmcv.ops import get_compiling_cuda_version, get_compiler_version; print(get_compiling_cuda_version(), get_compiler_version())"
https://github.com/open-mmlab/mmpose/blob/master/docs/en/install.md#install-mmposeに記載の手順による.
MMCV 1.6.2 をインストールしたので,MMDetection は 2系列になる(3系列は動かない)(2023年4月時点).
!python -m pip install -U openmim opencv-python !python -m pip install -U mmcv-full==1.6.2 !python -m pip install -U git+https://github.com/open-mmlab/mmclassification.git !python -m pip install -U mmdet==2.28.2 !python -m pip install -U git+https://github.com/open-mmlab/mmsegmentation.git !python -m pip install -U git+https://github.com/open-mmlab/mmtracking.git !python -m pip install -U git+https://github.com/open-mmlab/mmpose.git !apt -y install python3-numpy !apt -y install python3-scipy !python -c "import mmcls; print(mmcls.__version__)" !python -c "import mmdet; print(mmdet.__version__)" !python -c "import mmseg; print(mmseg.__version__)" !python -c "import mmtrack; print(mmtrack.__version__)" !python -c "import mmpose; print(mmpose.__version__)" !pip3 install git+https://github.com/votchallenge/toolkit.git
!mim install mmaction2 -f https://github.com/open-mmlab/mmaction2.git !pip3 show mmaction2 %cd /content !rm -rf mmaction2 !git clone https://github.com/open-mmlab/mmaction2.git %cd mmaction2 !pip3 install -r requirements/optional.txt
Temporal Segment Networks (TSN), ResNet50, ImageNet, Kinetics-400 のものをダウンロード.
MMAction2 の Temporal Segment Networks (TSN) の説明ページ: https://github.com/open-mmlab/mmaction2/blob/master/configs/recognition/tsn/README.md
!curl -O https://download.openmmlab.com/mmaction/recognition/tsn/tsn_r50_1x1x3_100e_kinetics400_rgb/tsn_r50_1x1x3_100e_kinetics400_rgb_20200614-e508be42.pth !mkdir checkpoints !mv tsn_r50_1x1x3_100e_kinetics400_rgb_20200614-e508be42.pth checkpoints
公式のチュートリアル: https://github.com/open-mmlab/mmaction2/blob/master/demo/mmaction2_tutorial.ipynb に記載のプログラムを使用
このプログラムは,Temporal Segment Networks (TSN), ResNet50, ImageNet, Kinetics-400 を使用
import torch from mmaction.apis import inference_recognizer, init_recognizer # Choose to use a config and initialize the recognizer config = 'configs/recognition/tsn/tsn_r50_video_inference_1x1x3_100e_kinetics400_rgb.py' # Setup a checkpoint file to load checkpoint = 'checkpoints/tsn_r50_1x1x3_100e_kinetics400_rgb_20200614-e508be42.pth' # Initialize the recognizer device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') model = init_recognizer(config, checkpoint, device=device) # Use the recognizer to do inference video = 'demo/demo.mp4' label = 'tools/data/kinetics/label_map_k400.txt' results = inference_recognizer(model, video) labels = open(label).readlines() labels = [x.strip() for x in labels] results = [(labels[k[0]], k[1]) for k in results] # Let's show the results for result in results: print(f'{result[0]}: ', result[1])
PoseC3D, SlowOnly-R50, NTU120_XSub のものをダウンロード.
MMAction2 の PoseC3D の説明ページ: https://github.com/open-mmlab/mmaction2/blob/master/configs/skeleton/posec3d/README.md
!curl -O https://download.openmmlab.com/mmaction/skeleton/posec3d/slowonly_r50_u48_240e_ntu120_xsub_keypoint/slowonly_r50_u48_240e_ntu120_xsub_keypoint-6736b03f.pth !mkdir checkpoints !mv slowonly_r50_u48_240e_ntu120_xsub_keypoint-6736b03f.pth checkpoints
MMAction2 の公式のデモのドキュメント: https://github.com/open-mmlab/mmaction2/blob/master/demo/README.md#skeleton-based-action-recognition-demo に記載のプログラムを使用
このプログラムは, 人物検出(human detection) に Faster RCNN を使用. 姿勢推定(pose estimation) に HRNetw32 を使用. スケルトンベースの動作認識 (skelton-based action recognition)に,PoseC3D, SlowOnly-R50, NTU120_XSub を使用.
!python3 demo/demo_skeleton.py demo/ntu_sample.avi demo/skeleton_demo.mp4 \ --config configs/skeleton/posec3d/slowonly_r50_u48_240e_ntu120_xsub_keypoint.py \ --checkpoint checkpoints/slowonly_r50_u48_240e_ntu120_xsub_keypoint-6736b03f.pth \ --det-config demo/faster_rcnn_r50_fpn_2x_coco.py \ --det-checkpoint http://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_2x_coco/faster_rcnn_r50_fpn_2x_coco_bbox_mAP-0.384_20200504_210434-a5d8aa15.pth \ --det-score-thr 0.9 \ --pose-config demo/hrnet_w32_coco_256x192.py \ --pose-checkpoint https://download.openmmlab.com/mmpose/top_down/hrnet/hrnet_w32_coco_256x192-c78dce93_20200708.pth \ --label-map tools/data/skeleton/label_map_ntu120.txt
mmaction/demo/skeleton_demo.mp4 を確認
AVA, OmniSource, ResNet101 のものをダウンロード.
MMAction2 の AVA の説明ページ: https://github.com/open-mmlab/mmaction2/blob/master/configs/detection/ava/README.md
!curl -O https://download.openmmlab.com/mmaction/detection/ava/slowonly_omnisource_pretrained_r101_8x8x1_20e_ava_rgb/slowonly_omnisource_pretrained_r101_8x8x1_20e_ava_rgb_20201217-16378594.pth !mkdir checkpoints !mv slowonly_omnisource_pretrained_r101_8x8x1_20e_ava_rgb_20201217-16378594.pth checkpoints
MMAction2 の公式のデモのドキュメント: https://github.com/open-mmlab/mmaction2/blob/master/demo/README.md#skeleton-based-action-recognition-demo に記載のプログラムを使用
このプログラムは, 人物検出(human detection) に Faster RCNN を使用. 動作認識 (action recognition)に,SlowOnly-8x8-R101 を使用. 8フレームごとに予測を行い,4フレームごとに1フレームを出力する.
!python3 demo/demo_spatiotemporal_det.py --video demo/demo.mp4 \ --config configs/detection/ava/slowonly_omnisource_pretrained_r101_8x8x1_20e_ava_rgb.py \ --checkpoint checkpoints/slowonly_omnisource_pretrained_r101_8x8x1_20e_ava_rgb_20201217-16378594.pth \ --det-config demo/faster_rcnn_r50_fpn_2x_coco.py \ --det-checkpoint http://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_2x_coco/faster_rcnn_r50_fpn_2x_coco_bbox_mAP-0.384_20200504_210434-a5d8aa15.pth \ --det-score-thr 0.9 \ --action-score-thr 0.5 \ --label-map tools/data/ava/label_map.txt \ --predict-stepsize 8 \ --output-stepsize 4 \ --output-fps 6
mmaction/demo/stdet_demo.mp4 を確認
MMPretrain (MMClassification) は, OpenMMLab の構成物で, 画像分類のツールボックスとベンチマークの機能を提供する.
【文献】
MMClassification Contributors, OpenMMLab's Image Classification Toolbox and Benchmark, https://github.com/open-mmlab/mmclassification, 2020.
【サイト内の関連ページ】
画像分類の実行(MMPretrain,PyTorch,Python を使用)(Windows 上)
【関連する外部ページ】
【関連項目】 OpenMMLab, MMCV, MMFewShot
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
!pip3 install git+https://github.com/open-mmlab/mim.git
https://mmclassification.readthedocs.io/en/latest/install.html の記載の手順による
%cd /content !rm -rf mmclassification !git clone https://github.com/open-mmlab/mmclassification.git %cd mmclassification !git checkout dev !mim install -e . !pip3 show mmcls
ResNet50, ImageNet-1k のものをダウンロード.
MMClassification の ResNet の説明ページ: https://github.com/open-mmlab/mmclassification/tree/master/configs/resnet
!curl -O https://download.openmmlab.com/mmclassification/v0/resnet/resnet50_8xb32_in1k_20210831-ea4938fc.pth !mkdir checkpoints !mv resnet50_8xb32_in1k_20210831-ea4938fc.pth checkpoints
このプログラムは,ResNet50, ImageNet-1k を使用.
import torch from mmcls.apis import inference_model, init_model, show_result_pyplot fimg = 'demo/demo.JPEG' fconfig = 'configs/resnet/resnet50_8xb32_in1k.py' fcheckpoint = 'checkpoints/resnet50_8xb32_in1k_20210831-ea4938fc.pth' device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') model = init_model(fconfig, fcheckpoint, device=device) result = inference_model(model, fimg) print(result) show_result_pyplot(model, fimg, result)
「demo/demo.JPEG」のところに画像ファイル名を指定する.
import torch from mmcls.apis import inference_model, init_model, show_result_pyplot fimg = 'demo/demo.JPEG' fconfig = 'configs/resnet/resnet152_8xb32_in1k.py' fcheckpoint = 'https://download.openmmlab.com/mmclassification/v0/resnet/resnet152_batch256_imagenet_20200708-ec25b1f9.pth' device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') model = init_model(fconfig, fcheckpoint, device=device) result = inference_model(model, fimg) print(result) show_result_pyplot(model, fimg, result)
「demo/demo.JPEG」のところに画像ファイル名を指定する.
import torch from mmcls.apis import inference_model, init_model, show_result_pyplot fimg = 'demo/demo.JPEG' fconfig = 'configs/mobilenet_v2/mobilenet-v2_8xb32_in1k.py' fcheckpoint = 'https://download.openmmlab.com/mmclassification/v0/mobilenet_v2/mobilenet_v2_batch256_imagenet_20200708-3b2dc3af.pth' device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') model = init_model(fconfig, fcheckpoint, device=device) result = inference_model(model, fimg) print(result) show_result_pyplot(model, fimg, result)
「demo/demo.JPEG」のところに画像ファイル名を指定する.
import torch from mmcls.apis import inference_model, init_model, show_result_pyplot fimg = 'demo/demo.JPEG' fconfig = 'configs/resnext/resnext152-32x4d_8xb32_in1k.py' fcheckpoint = 'https://download.openmmlab.com/mmclassification/v0/resnext/resnext152_32x4d_b32x8_imagenet_20210524-927787be.pth' device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') model = init_model(fconfig, fcheckpoint, device=device) result = inference_model(model, fimg) print(result) show_result_pyplot(model, fimg, result)
「demo/demo.JPEG」のところに画像ファイル名を指定する.
import torch from mmcls.apis import inference_model, init_model, show_result_pyplot fimg = 'demo/demo.JPEG' fconfig = 'configs/vision_transformer/vit-base-p32_ft-64xb64_in1k-384.py' fcheckpoint = 'https://download.openmmlab.com/mmclassification/v0/vit/finetune/vit-base-p32_in21k-pre-3rdparty_ft-64xb64_in1k-384_20210928-9cea8599.pth' device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') model = init_model(fconfig, fcheckpoint, device=device) result = inference_model(model, fimg) print(result) show_result_pyplot(model, fimg, result)
MMClassification のインストールと動作確認(画像分類)(PyTorch,Python を使用): 別ページ »で説明している.
MMCV は, OpenMMLab の構成物で,基礎的な機能を提供する.
【文献】
MMCV Contributors, MMCV: OpenMMLab Computer Vision Foundation, https://github.com/open-mmlab/mmcv, 2018.
【関連する外部ページ】
【関連項目】 OpenMMLab, MMAction2, MMClassification MMDetection, MMFewShot, MMFlow, MMGen, MMPose, MMSegmentation, MMSegmentation3D, MMSelfSup, MMTracking
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
PyTorch は,ディープラーニングのフレームワークの 機能を持つ Pythonのパッケージ
次のプログラム実行により,PyTorch のバージョンが「1.10.0+cu111」のように表示される.
import torch print(torch.__version__)
次のプログラム実行により,NVIDIA CUDA ツールキットのバージョンが「cu111」のように表示される.
import torch CUDA_VERSION = torch.__version__.split("+")[-1] print(CUDA_VERSION)
import torch TORCH_VERSION = ".".join(torch.__version__.split(".")[:2]) print(TORCH_VERSION)
インストール手順は, https://mmcv.readthedocs.io/en/latest/get_started/installation.html に記載の手順による
MMTracking が MMVC 1.6.2 に依存している (2023年4月時点). MMTracking の利用を想定して MMCV 1.6.2 をインストールする.
!python -c "import torch; print(torch.__version__)" !apt remove python3-pycocotools !pip uninstall -y pycocotools !pip install mmpycocotools !apt install -y python3-terminaltables !apt install -y python3-opencv !pip install mmcv-full==1.6.2 !python3 -c "from mmcv.ops import get_compiling_cuda_version, get_compiler_version; print(get_compiling_cuda_version(), get_compiler_version())"
MMCV のインストールと動作確認(画像表示など)(PyTorch,Python を使用): 別ページ »で説明している.
MMCV 1.7.1 のインストール
インストール手順は, https://mmcv.readthedocs.io/en/latest/get_started/installation.html に記載の手順による
MMTracking が MMVC 1.6.2 に依存している (2023年4月時点). MMTracking の利用を想定して MMCV 1.6.2 をインストールする.
sudo apt install -y python3-terminaltables sudo apt install -y python3-opencv python3 -m pip uninstall mmcv mmcv-full python3 -m pip install mmcv==1.6.2
MMDetection は, OpenMMLab の構成物で,物体検出, インスタンス・セグメンテーション (instance segmentation), パノプティック・セグメンテーション (panoptic segmentation) の機能を提供する.
【文献】
Chen, Kai and Wang, Jiaqi and Pang, Jiangmiao and Cao, Yuhang and Xiong, Yu and Li, Xiaoxiao and Sun, Shuyang and Feng, Wansen and Liu, Ziwei and Xu, Jiarui and Zhang, Zheng and Cheng, Dazhi and Zhu, Chenchen and Cheng, Tianheng and Zhao, Qijie and Li, Buyu and Lu, Xin and Zhu, Rui and Wu, Yue and Dai, Jifeng and Wang, Jingdong and Shi, Jianping and Ouyang, Wanli and Loy, Chen Change and Lin, Dahua, MMDetection: Open MMLab Detection Toolbox and Benchmark, arXiv:1906.07155, 2019.
【サイト内の関連ページ】
物体検出の実行(MMDetection,PyTorch,Python を使用)(Windows 上)
【関連する外部ページ】
【関連項目】 DETR, Deformable DETR, Mask R-CNN, MMCV, MMFewShot, MMPose, MMSegmentation, MMSegmentation3D, MMSelfSup, MMTracking, OpenMMLab, RetinaNet, Seesaw Loss, SSD, YOLOv3, YOLOv4, YOLOX, インスタンス・セグメンテーション (instance segmentation), パノプティック・セグメンテーション (panoptic segmentation) 物体検出
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
!pip3 install git+https://github.com/open-mmlab/mim.git
https://github.com/open-mmlab/mmdetection/blob/master/docs/en/get_started.md に記載の手順による
!mim install mmdet !pip3 show mmdet
あとで使用する
%cd /content !rm -rf mmdetection !git clone https://github.com/open-mmlab/mmdetection.git %cd mmdetection
Mask R-CNN, FPN (Feature Pyramid Network), Lr schd = 3x のものをダウンロード.
MMDetection の Mask R-CNN の説明ページ: https://github.com/open-mmlab/mmdetection/tree/master/configs/mask_rcnn
!curl -O https://download.openmmlab.com/mmdetection/v2.0/mask_rcnn/mask_rcnn_r50_caffe_fpn_mstrain-poly_3x_coco/mask_rcnn_r50_caffe_fpn_mstrain-poly_3x_coco_bbox_mAP-0.408__segm_mAP-0.37_20200504_163245-42aa3d00.pth !mkdir checkpoints !mv mask_rcnn_r50_caffe_fpn_mstrain-poly_3x_coco_bbox_mAP-0.408__segm_mAP-0.37_20200504_163245-42aa3d00.pth checkpoints
MMDetection の訓練,検証,推論の公式チュートリアル: https://github.com/open-mmlab/mmdetection/blob/master/demo/MMDet_Tutorial.ipynb に記載のプログラムを使用
このプログラムは,Mask R-CNN, FPN (Feature Pyramid Network), Lr schd = 3x を使用.
import torch from mmdet.apis import inference_detector, init_detector, show_result_pyplot fimg = 'demo/demo.jpg' fconfig = 'configs/mask_rcnn/mask_rcnn_r50_caffe_fpn_mstrain-poly_3x_coco.py' fcheckpoint = 'checkpoints/mask_rcnn_r50_caffe_fpn_mstrain-poly_3x_coco_bbox_mAP-0.408__segm_mAP-0.37_20200504_163245-42aa3d00.pth' device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') model = init_detector(fconfig, fcheckpoint, device=device) result = inference_detector(model, fimg) print(result) show_result_pyplot(model, fimg, result, score_thr=0.3)
RetinaNet, R-50-FPN, Lr schd = 1x のものをダウンロード.
MMDetection の RetinaNet の説明ページ: https://github.com/open-mmlab/mmdetection/tree/master/configs/retinanet
!curl -O https://download.openmmlab.com/mmdetection/v2.0/retinanet/retinanet_r50_caffe_fpn_1x_coco/retinanet_r50_caffe_fpn_1x_coco_20200531-f11027c5.pth !mkdir checkpoints !mv retinanet_r50_caffe_fpn_1x_coco_20200531-f11027c5.pth checkpoints
MMDetection の訓練,検証,推論の公式チュートリアル: https://github.com/open-mmlab/mmdetection/blob/master/demo/MMDet_Tutorial.ipynb に記載のプログラムを使用
このプログラムは,RetinaNet, R-50-FPN, Lr schd = 1x を使用.
import torch from mmdet.apis import inference_detector, init_detector, show_result_pyplot fimg = 'demo/demo.jpg' fconfig = 'configs/retinanet/retinanet_r50_caffe_fpn_1x_coco.py' fcheckpoint = 'checkpoints/retinanet_r50_caffe_fpn_1x_coco_20200531-f11027c5.pth' device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') model = init_detector(fconfig, fcheckpoint, device=device) result = inference_detector(model, fimg) print(result) show_result_pyplot(model, fimg, result, score_thr=0.3)
DETR, R-50, Lr schd = 150e のものをダウンロード.
MMDetection の DETR の説明ページ: https://github.com/open-mmlab/mmdetection/blob/master/configs/detr/README.md
!curl -O https://download.openmmlab.com/mmdetection/v2.0/detr/detr_r50_8x2_150e_coco/detr_r50_8x2_150e_coco_20201130_194835-2c4b8974.pth !mkdir checkpoints !mv detr_r50_8x2_150e_coco_20201130_194835-2c4b8974.pth checkpoints
MMDetection の訓練,検証,推論の公式チュートリアル: https://github.com/open-mmlab/mmdetection/blob/master/demo/MMDet_Tutorial.ipynb に記載のプログラムを使用
このプログラムは,DETR, R-50, Lr schd = 150e を使用.
import torch from mmdet.apis import inference_detector, init_detector, show_result_pyplot fimg = 'demo/demo.jpg' fconfig = 'configs/detr/detr_r50_8x2_150e_coco.py' fcheckpoint = 'checkpoints/detr_r50_8x2_150e_coco_20201130_194835-2c4b8974.pth' device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') model = init_detector(fconfig, fcheckpoint, device=device) result = inference_detector(model, fimg) print(result) show_result_pyplot(model, fimg, result, score_thr=0.3)
Deformable DETR, ++ two-stage Deformable DETR, R-50, Lr schd = 50e のものをダウンロード.
MMDetection の Deformable DETR の説明ページ: https://github.com/open-mmlab/mmdetection/blob/master/configs/deformable_detr/README.md
!curl -O https://download.openmmlab.com/mmdetection/v2.0/deformable_detr/deformable_detr_twostage_refine_r50_16x2_50e_coco/deformable_detr_twostage_refine_r50_16x2_50e_coco_20210419_220613-9d28ab72.pth !mkdir checkpoints !mv deformable_detr_twostage_refine_r50_16x2_50e_coco_20210419_220613-9d28ab72.pth checkpoints
MMDetection の訓練,検証,推論の公式チュートリアル: https://github.com/open-mmlab/mmdetection/blob/master/demo/MMDet_Tutorial.ipynb に記載のプログラムを使用
このプログラムは,Deformable DETR, ++ two-stage Deformable DETR, R-50, Lr schd = 50e を使用.
import torch from mmdet.apis import inference_detector, init_detector, show_result_pyplot fimg = 'demo/demo.jpg' fconfig = 'configs/deformable_detr/deformable_detr_twostage_refine_r50_16x2_50e_coco.py' fcheckpoint = 'checkpoints/deformable_detr_twostage_refine_r50_16x2_50e_coco_20210419_220613-9d28ab72.pth' device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') model = init_detector(fconfig, fcheckpoint, device=device) result = inference_detector(model, fimg) print(result) show_result_pyplot(model, fimg, result, score_thr=0.3)
YOLOX のものをダウンロード.
MMDetection の YOLOX の説明ページ: https://github.com/open-mmlab/mmdetection/blob/master/configs/yolox/README.md
!curl -O https://download.openmmlab.com/mmdetection/v2.0/yolox/yolox_x_8x8_300e_coco/yolox_x_8x8_300e_coco_20211126_140254-1ef88d67.pth !mkdir checkpoints !mv yolox_x_8x8_300e_coco_20211126_140254-1ef88d67.pth checkpoints
MMDetection の訓練,検証,推論の公式チュートリアル: https://github.com/open-mmlab/mmdetection/blob/master/demo/MMDet_Tutorial.ipynb に記載のプログラムを使用
このプログラムは,YOLOX を使用.
import torch from mmdet.apis import inference_detector, init_detector, show_result_pyplot fimg = 'demo/demo.jpg' fconfig = 'configs/yolox/yolox_x_8x8_300e_coco.py' fcheckpoint = 'checkpoints/yolox_x_8x8_300e_coco_20211126_140254-1ef88d67.pth' device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') model = init_detector(fconfig, fcheckpoint, device=device) result = inference_detector(model, fimg) print(result) show_result_pyplot(model, fimg, result, score_thr=0.3)
YOLOv3, DarkNet-53, Lr schd = 273e, with mixed precision training のものをダウンロード.
MMDetection の YOLOv3 の説明ページ: https://github.com/open-mmlab/mmdetection/blob/master/configs/yolo/README.md
!curl -O https://download.openmmlab.com/mmdetection/v2.0/yolo/yolov3_d53_fp16_mstrain-608_273e_coco/yolov3_d53_fp16_mstrain-608_273e_coco_20210517_213542-4bc34944.pth !mkdir checkpoints !mv yolov3_d53_fp16_mstrain-608_273e_coco_20210517_213542-4bc34944.pth checkpoints
MMDetection の訓練,検証,推論の公式チュートリアル: https://github.com/open-mmlab/mmdetection/blob/master/demo/MMDet_Tutorial.ipynb に記載のプログラムを使用
このプログラムは,YOLOv3, DarkNet-53, Lr schd = 273e, with mixed precision training を使用.
import torch from mmdet.apis import inference_detector, init_detector, show_result_pyplot fimg = 'demo/demo.jpg' fconfig = 'configs/yolo/yolov3_d53_fp16_mstrain-608_273e_coco.py' fcheckpoint = 'checkpoints/yolov3_d53_fp16_mstrain-608_273e_coco_20210517_213542-4bc34944.pth' device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') model = init_detector(fconfig, fcheckpoint, device=device) result = inference_detector(model, fimg) print(result) show_result_pyplot(model, fimg, result, score_thr=0.3)
Seesaw Loss,Cascade Mask R-CNN, R-101-FPN, Lr schd = 2x, LVIS v1 データセットのものをダウンロード.
MMDetection の Seesaw Loss の説明ページ: https://github.com/open-mmlab/mmdetection/blob/master/configs/seesaw_loss/README.md
!curl -O https://download.openmmlab.com/mmdetection/v2.0/seesaw_loss/cascade_mask_rcnn_r101_fpn_sample1e-3_seesaw_loss_normed_mask_mstrain_2x_lvis_v1-c8551505.pth !mkdir checkpoints !mv cascade_mask_rcnn_r101_fpn_sample1e-3_seesaw_loss_normed_mask_mstrain_2x_lvis_v1-c8551505.pth checkpoints
MMDetection の訓練,検証,推論の公式チュートリアル: https://github.com/open-mmlab/mmdetection/blob/master/demo/MMDet_Tutorial.ipynb に記載のプログラムを使用
このプログラムは,Seesaw Loss,Cascade Mask R-CNN, R-101-FPN, Lr schd = 2x, LVIS v1 データセットを使用.
import torch from mmdet.apis import inference_detector, init_detector, show_result_pyplot fimg = 'demo/demo.jpg' fconfig = 'configs/seesaw_loss/cascade_mask_rcnn_r101_fpn_sample1e-3_seesaw_loss_normed_mask_mstrain_2x_lvis_v1.py' fcheckpoint = 'checkpoints/cascade_mask_rcnn_r101_fpn_sample1e-3_seesaw_loss_normed_mask_mstrain_2x_lvis_v1-c8551505.pth' device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') model = init_detector(fconfig, fcheckpoint, device=device) result = inference_detector(model, fimg) print(result) show_result_pyplot(model, fimg, result, score_thr=0.3)
SSD,size=512, Lr schd = 120x, COCO データセットのものをダウンロード.
MMDetection の SSD の説明ページ: https://github.com/open-mmlab/mmdetection/blob/master/configs/ssd/README.md
!curl -O https://download.openmmlab.com/mmdetection/v2.0/ssd/ssd512_coco/ssd512_coco_20210803_022849-0a47a1ca.pth !mkdir checkpoints !mv ssd512_coco_20210803_022849-0a47a1ca.pth checkpoints
MMDetection の訓練,検証,推論の公式チュートリアル: https://github.com/open-mmlab/mmdetection/blob/master/demo/MMDet_Tutorial.ipynb に記載のプログラムを使用
このプログラムは,SSD,size=512, Lr schd = 120x, COCO データセットを使用.
import torch from mmdet.apis import inference_detector, init_detector, show_result_pyplot fimg = 'demo/demo.jpg' fconfig = 'configs/configs/ssd/ssd512_coco.py' fcheckpoint = 'checkpoints/ssd512_coco_20210803_022849-0a47a1ca.pth' device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') model = init_detector(fconfig, fcheckpoint, device=device) result = inference_detector(model, fimg) print(result) show_result_pyplot(model, fimg, result, score_thr=0.3)
MMDetection のインストールと動作確認(物体検出)(PyTorch,Python を使用): 別ページ »で説明している.
「git checkout v0.14.0」は,バージョン 2.14.0 を指定している. これは,https://mmdetection3d.readthedocs.io/en/latest/get_started.html での2021/08 時点の説明による.将来はバージョン番号が変わる可能性があり,このページを確認してから,インストールを行うこと.
Ubuntu でインストールを行うには,次のコマンドを実行.
sudo apt -y update sudo apt -y install git cd /usr/local sudo git clone https://github.com/open-mmlab/mmdetection.git sudo chown -R $USER mmdetection cd mmdetection git checkout v2.14.0 sudo pip3 install -r requirements\build.txt python3 setup.py develop pip3 install instaboostfast # for panoptic segmentation pip3 install git+https://github.com/cocodataset/panopticapi.git # for LVIS dataset pip3 install git+https://github.com/lvis-dataset/lvis-api.git
Ubuntu の場合は, mmcv のドキュメント: https://mmcv.readthedocs.io/en/latest/ の手順がそのまま使えそうである.
MMEditing は, OpenMMLab の構成物で, イメージ・インペインティング(image inpainting),画像のノイズ除去 (画像のノイズ除去 (image restoration)), イメージ・マッティング (image matting), 超解像 (super resolution), 画像生成の機能を持つ.
MMEditing Contributors, OpenMMLab Editing Estimation Toolbox and Benchmark, https://github.com/open-mmlab/mmediting, 2020.
【関連項目】 MMCV, OpenMMLab, SRCNN, ESRGAN, EDvR, BasicVSR image inpainting, 画像のノイズ除去 (image restoration), イメージ・マッティング (image matting), 超解像 (super resolution), generation
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
PyTorch は,ディープラーニングのフレームワークの 機能を持つ Pythonのパッケージ
次のプログラム実行により,PyTorch のバージョンが「1.10.0+cu111」のように表示される.
import torch print(torch.__version__)
次のプログラム実行により,NVIDIA CUDA ツールキットのバージョンが「cu111」のように表示される.
import torch CUDA_VERSION = torch.__version__.split("+")[-1] print(CUDA_VERSION)
import torch TORCH_VERSION = ".".join(torch.__version__.split(".")[:2]) print(TORCH_VERSION)
インストール手順は, https://mmcv.readthedocs.io/en/latest/get_started/installation.html に記載の手順による
MMTracking が MMVC 1.6.2 に依存している (2023年4月時点). MMTracking の利用を想定して MMCV 1.6.2 をインストールする.
!python -c "import torch; print(torch.__version__)" !apt remove python3-pycocotools !pip uninstall -y pycocotools !pip install mmpycocotools !apt install -y python3-terminaltables !apt install -y python3-opencv !pip install mmcv-full==1.6.2 !python3 -c "from mmcv.ops import get_compiling_cuda_version, get_compiler_version; print(get_compiling_cuda_version(), get_compiler_version())"
!python -m pip install -U openmim opencv-python %cd /content !rm -rf mmediting !git clone https://github.com/open-mmlab/mmediting.git %cd mmediting !pip3 install -r requirements/build.txt !pip3 install .
%cd /content/mmediting !curl -O https://download.openmmlab.com/mmediting/demo_files.zip !rm -rf demo_files !unzip demo_files
学習済みモデルを使用.
MMEditing の SRCNN の説明ページ: https://github.com/open-mmlab/mmediting/blob/master/configs/restorers/srcnn/README.md
コマンドの説明: https://github.com/open-mmlab/mmediting/blob/master/docs/en/getting_started.md
!python3 demo/restoration_demo.py ./configs/restorers/srcnn/srcnn_x4k915_g1_1000k_div2k.py https://download.openmmlab.com/mmediting/restorers/srcnn/srcnn_x4k915_1x16_1000k_div2k_20200608-4186f232.pth ./demo_files/lq_images/bird.png ./outputs/bird_SRCNN.png from PIL import Image Image.open('./demo_files/lq_images/bird.png').show() Image.open('./outputs/bird_SRCNN.png').show()
学習済みモデルを使用.
MMEditing の ESRGAN の説明ページ: https://github.com/open-mmlab/mmediting/blob/master/configs/restorers/esrgan/README.md
コマンドの説明: https://github.com/open-mmlab/mmediting/blob/master/docs/en/getting_started.md
!python3 demo/restoration_demo.py ./configs/restorers/esrgan/esrgan_x4c64b23g32_g1_400k_div2k.py https://download.openmmlab.com/mmediting/restorers/esrgan/esrgan_x4c64b23g32_1x16_400k_div2k_20200508-f8ccaf3b.pth ./demo_files/lq_images/bird.png ./outputs/bird_ESRGAN.png from PIL import Image Image.open('./demo_files/lq_images/bird.png').show() Image.open('./outputs/bird_ESRGAN.png').show()
学習済みモデルを使用.
MMEditing の EDVR の説明ページ: https://github.com/open-mmlab/mmediting/blob/master/configs/restorers/edvr/README.md
コマンドの説明: https://github.com/open-mmlab/mmediting/blob/master/docs/en/getting_started.md
!python3 demo/restoration_video_demo.py ./configs/restorers/edvr/edvrm_wotsa_x4_g8_600k_reds.py https://download.openmmlab.com/mmediting/restorers/edvr/edvrm_wotsa_x4_8x4_600k_reds_20200522-0570e567.pth demo_files/lq_sequences/city/ ./outputs/city_EDVR --window_size=5 from PIL import Image Image.open('./demo_files/lq_sequences/city/00000000.png').show() Image.open('./outputs/city_EDVR/00000000.png').show() Image.open('./demo_files/lq_sequences/city/00000001.png').show() Image.open('./outputs/city_EDVR/00000001.png').show() Image.open('./demo_files/lq_sequences/city/00000002.png').show() Image.open('./outputs/city_EDVR/00000002.png').show() Image.open('./demo_files/lq_sequences/city/00000003.png').show() Image.open('./outputs/city_EDVR/00000003.png').show() Image.open('./demo_files/lq_sequences/city/00000004.png').show() Image.open('./outputs/city_EDVR/00000004.png').show() Image.open('./demo_files/lq_sequences/city/00000005.png').show() Image.open('./outputs/city_EDVR/00000005.png').show()
学習済みモデルを使用.
MMEditing の EDVR の説明ページ: https://github.com/open-mmlab/mmediting/blob/master/configs/restorers/edvr/README.md
コマンドの説明: https://github.com/open-mmlab/mmediting/blob/master/docs/en/getting_started.md
!python3 demo/restoration_video_demo.py ./configs/restorers/basicvsr/basicvsr_reds4.py https://download.openmmlab.com/mmediting/restorers/basicvsr/basicvsr_reds4_20120409-0e599677.pth demo_files/lq_sequences/city/ ./outputs/city_BasicVSR from PIL import Image Image.open('./demo_files/lq_sequences/city/00000000.png').show() Image.open('./outputs/city_BasicVSR/00000000.png').show() Image.open('./demo_files/lq_sequences/city/00000001.png').show() Image.open('./outputs/city_BasicVSR/00000001.png').show() Image.open('./demo_files/lq_sequences/city/00000002.png').show() Image.open('./outputs/city_BasicVSR/00000002.png').show() Image.open('./demo_files/lq_sequences/city/00000003.png').show() Image.open('./outputs/city_BasicVSR/00000003.png').show() Image.open('./demo_files/lq_sequences/city/00000004.png').show() Image.open('./outputs/city_BasicVSR/00000004.png').show() Image.open('./demo_files/lq_sequences/city/00000005.png').show() Image.open('./outputs/city_BasicVSR/00000005.png').show()
学習済みモデルを使用.
MMEditing の DeepFillv2 の説明ページ: https://github.com/open-mmlab/mmediting/blob/master/configs/inpainting/deepfillv2/README.md
コマンドの説明: https://github.com/open-mmlab/mmediting/blob/master/docs/en/getting_started.md
!python3 demo/inpainting_demo.py configs/inpainting/deepfillv2/deepfillv2_256x256_8x2_celeba.py https://download.openmmlab.com/mmediting/inpainting/deepfillv2/deepfillv2_256x256_8x2_celeba_20200619-c96e5f12.pth tests/data/image/celeba_test.png tests/data/image/bbox_mask.png tests/data/pred/inpainting_celeba.png from PIL import Image Image.open('./tests/data/image/celeba_test.png').show() Image.open('./tests/data/pred/inpainting_celeba.png').show()
学習済みモデルを使用.
MMEditing の Global&Local の説明ページ: https://github.com/open-mmlab/mmediting/blob/master/configs/inpainting/global_local/README.md
コマンドの説明: https://github.com/open-mmlab/mmediting/blob/master/docs/en/getting_started.md
!python3 demo/inpainting_demo.py configs/inpainting/global_local/gl_256x256_8x12_celeba.py https://download.openmmlab.com/mmediting/inpainting/global_local/gl_256x256_8x12_celeba_20200619-5af0493f.pth tests/data/image/celeba_test.png tests/data/image/bbox_mask.png tests/data/pred/inpainting_celeba.png from PIL import Image Image.open('./tests/data/image/celeba_test.png').show() Image.open('./tests/data/pred/inpainting_celeba.png').show()
学習済みモデルを使用.
MMEditing の GCA の説明ページ: https://github.com/open-mmlab/mmediting/blob/master/configs/mattors/gca/README.md
コマンドの説明: https://github.com/open-mmlab/mmediting/blob/master/docs/en/getting_started.md
!python3 demo/matting_demo.py configs/mattors/gca/gca_r34_4x10_200k_comp1k.py https://download.openmmlab.com/mmediting/mattors/gca/gca_r34_4x10_200k_comp1k_SAD-34.77_20200604_213848-4369bea0.pth tests/data/merged/GT05.jpg tests/data/trimap/GT05.png tests/data/pred/GT05.png from PIL import Image Image.open('./tests/data/merged/GT05.jpg')) Image.open('./tests/data/trimap/GT05.png').show() Image.open('./tests/data/pred/GT05.png').show()
学習済みモデルを使用.
MMEditing の IndexNet の説明ページ: https://github.com/open-mmlab/mmediting/blob/master/configs/mattors/indexnet/README.md
コマンドの説明: https://github.com/open-mmlab/mmediting/blob/master/docs/en/getting_started.md
!python3 demo/matting_demo.py configs/mattors/indexnet/indexnet_mobv2_1x16_78k_comp1k.py https://download.openmmlab.com/mmediting/mattors/indexnet/indexnet_mobv2_1x16_78k_comp1k_SAD-45.6_20200618_173817-26dd258d.pth tests/data/merged/GT05.jpg tests/data/trimap/GT05.png tests/data/pred/GT05.png from PIL import Image Image.open('./tests/data/merged/GT05.jpg')) Image.open('./tests/data/trimap/GT05.png').show() Image.open('./tests/data/pred/GT05.png').show()
学習済みモデルを使用.
MMEditing の DIM の説明ページ: https://github.com/open-mmlab/mmediting/blob/master/configs/mattors/dim/README.md
コマンドの説明: https://github.com/open-mmlab/mmediting/blob/master/docs/en/getting_started.md
!python3 demo/matting_demo.py configs/mattors/dim/dim_stage3_v16_pln_1x1_1000k_comp1k.py https://download.openmmlab.com/mmediting/mattors/dim/dim_stage3_v16_pln_1x1_1000k_comp1k_SAD-50.6_20200609_111851-647f24b6.pth tests/data/merged/GT05.jpg tests/data/trimap/GT05.png tests/data/pred/GT05.png from PIL import Image Image.open('./tests/data/merged/GT05.jpg')) Image.open('./tests/data/trimap/GT05.png').show() Image.open('./tests/data/pred/GT05.png').show()
demos URL: https://github.com/open-mmlab/mmediting/blob/master/docs/en/getting_started.md
!python3 demo/generation_demo.py configs/example_config.py work_dirs/example_exp/example_model_20200202.pth demo/demo.jpg demo/demo_out.jpg
!python3 demo/generation_demo.py configs/example_config.py work_dirs/example_exp/example_model_20200202.pth demo/demo.jpg demo/demo_out.jpg --unpaired_path demo/demo_unpaired.jpg
MMFewShot は, OpenMMLab の構成物で, Few Shot Classification, Few Shot Detection の機能を提供する.
【文献】
mmfewshot Contributors, OpenMMLab Few Shot Learning Toolbox and Benchmark, https://github.com/open-mmlab/mmfewshot, 2021.
【関連する外部ページ】
【関連項目】 Few Shot Detection, OpenMMLab, MMClassification, MMCV, MMDetection,
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
!pip3 install git+https://github.com/open-mmlab/mim.git
https://mmclassification.readthedocs.io/en/latest/install.html, https://github.com/open-mmlab/mmdetection/blob/master/docs/en/get_started.md に記載の手順による
!mim install mmdet !pip3 show mmdet cd /content !rm -rf mmclassification !git clone https://github.com/open-mmlab/mmclassification.git %cd mmclassification !git checkout dev !mim install -e . !pip3 show mmcls
https://github.com/open-mmlab/mmfewshot/blob/main/docs/en/install.md に記載の手順による.
%cd /content !rm -rf mmfewshot !git clone https://github.com/open-mmlab/mmfewshot.git %cd mmfewshot !pip3 install -r requirements/build.txt !python3 setup.py develop !pip3 show mmfewshot
%cd /content/mmfewshot import os from mmdet.apis import show_result_pyplot from mmfewshot.detection.apis import (inference_detector, init_detector, process_support_images) %matplotlib inline import matplotlib.pyplot as plt import torch import torchvision.models as models from IPython.display import display fconfig = 'configs/detection/attention_rpn/coco/attention-rpn_r50_c4_4xb2_coco_base-training.py' fcheckpoint = 'https://download.openmmlab.com/mmfewshot/detection/attention_rpn/coco/attention-rpn_r50_c4_4xb2_coco_base-training_20211102_003348-da28cdfd.pth' device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') fsupport_images_dir = 'demo/demo_detection_images/support_images' model = init_detector(fconfig,fcheckpoint, device=device) files = os.listdir(fsupport_images_dir) support_images = [ os.path.join(fsupport_images_dir, file) for file in files ] classes = [file.split('.')[0] for file in files] support_labels = [[file.split('.')[0]] for file in files] print("support_images") display(support_images) print("classes") display(classes) print("support_labels") display(support_labels) process_support_images(model, support_images, support_labels, classes=classes) # single image fimage = 'demo/demo_detection_images/query_images/demo_query.jpg' fscore_thr = 0.3 result = inference_detector(model, fimage) show_result_pyplot(model, fimage, result, score_thr=fscore_thr)
MMCV 1.6.0, MMDetection 2.25.0,MMFewShot のインストールと動作確認(画像分類,物体検出)(PyTorch,Python を使用): 別ページ »で説明している.
MMFlow は, OpenMMLab の構成物で,オプティカルフローの機能を提供する.
【文献 】
MMFlow Contributors, MMFlow: OpenMMLab Optical Flow Toolbox and Benchmark, https://github.com/open-mmlab/mmflow, 2021.
【関連する外部ページ 】
【関連項目】 OpenMMLab, MMCV, optical flow
MMFlow のインストールと動作確認(オプティカルフロー)(PyTorch,Python を使用): 別ページ »で説明している.
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
PyTorch は,ディープラーニングのフレームワークの 機能を持つ Pythonのパッケージ
次のプログラム実行により,PyTorch のバージョンが「1.10.0+cu111」のように表示される.
import torch print(torch.__version__)
次のプログラム実行により,NVIDIA CUDA ツールキットのバージョンが「cu111」のように表示される.
import torch CUDA_VERSION = torch.__version__.split("+")[-1] print(CUDA_VERSION)
import torch TORCH_VERSION = ".".join(torch.__version__.split(".")[:2]) print(TORCH_VERSION)
!rm -rf mmflow !git clone https://github.com/open-mmlab/mmflow.git %cd mmflow !pip3 install -r requirements/build.txt !pip3 install .
学習済みモデルを使用.
!curl -O https://download.openmmlab.com/mmflow/raft/raft_8x2_100k_mixed_368x768.pth !python3 demo/video_demo.py demo/demo.mp4 \ configs/raft/raft_8x2_100k_mixed_368x768.py \ raft_8x2_100k_mixed_368x768.pth \ raft_demo.mp4 --gt demo/demo_gt.mp4
結果として raft_demo_gt.mp4 ができるので,ダウンロードして,表示して確認する.
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
PyTorch は,ディープラーニングのフレームワークの 機能を持つ Pythonのパッケージ
次のプログラム実行により,PyTorch のバージョンが「1.10.0+cu111」のように表示される.
import torch print(torch.__version__)
次のプログラム実行により,NVIDIA CUDA ツールキットのバージョンが「cu111」のように表示される.
import torch CUDA_VERSION = torch.__version__.split("+")[-1] print(CUDA_VERSION)
import torch TORCH_VERSION = ".".join(torch.__version__.split(".")[:2]) print(TORCH_VERSION)
インストール手順は, https://mmcv.readthedocs.io/en/latest/get_started/installation.html に記載の手順による
MMTracking が MMVC 1.6.2 に依存している (2023年4月時点). MMTracking の利用を想定して MMCV 1.6.2 をインストールする.
!python -c "import torch; print(torch.__version__)" !apt remove python3-pycocotools !pip uninstall -y pycocotools !pip install mmpycocotools !apt install -y python3-terminaltables !apt install -y python3-opencv !pip install mmcv-full==1.6.2 !python3 -c "from mmcv.ops import get_compiling_cuda_version, get_compiler_version; print(get_compiling_cuda_version(), get_compiler_version())"
!python -m pip install -U openmim opencv-python !rm -rf mmgeneration !git clone https://github.com/open-mmlab/mmgeneration.git %cd mmgeneration !pip3 install -r requirements/build.txt !pip3 install .
https://github.com/open-mmlab/mmgeneration/blob/master/docs/en/get_started.md に記載のプログラムを使用
学習済みモデルを使用.
from mmgen.apis import init_model, sample_uncoditional_model config_file = 'configs/styleganv2/stylegan2_c2_lsun-church_256_b4x8_800k.py' # you can download this checkpoint in advance and use a local file path. checkpoint_file = 'https://download.openmmlab.com/mmgen/stylegan2/official_weights/stylegan2-church-config-f-official_20210327_172657-1d42b7d1.pth' device = 'cuda:0' # init a generatvie model = init_model(config_file, checkpoint_file, device=device) # sample images fake_imgs = sample_uncoditional_model(model, 4) import numpy as np import matplotlib.pyplot as plt plt.style.use('default') for i in fake_imgs: plt.imshow(np.stack([i[2], i[1], i[0]], axis=2)) plt.show()
MMPose は, OpenMMLab の構成物で,2次元の姿勢推定,3次元の姿勢推定の機能を提供する.
【関連項目】 OpenMMLab, MMCV, MMDetection, MMTracking, 物体検出 2次元の姿勢推定, 姿勢推定, 人体の姿勢推定, 手の姿勢推定,
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
インストール手順は, https://mmcv.readthedocs.io/en/latest/get_started/installation.html に記載の手順による
MMTracking が MMVC 1.6.2 に依存している (2023年4月時点). MMTracking の利用を想定して MMCV 1.6.2 をインストールする.
!python -c "import torch; print(torch.__version__)" !apt remove python3-pycocotools !pip uninstall -y pycocotools !pip install mmpycocotools !apt install -y python3-terminaltables !apt install -y python3-opencv !pip install mmcv-full==1.6.2 !python3 -c "from mmcv.ops import get_compiling_cuda_version, get_compiler_version; print(get_compiling_cuda_version(), get_compiler_version())"
https://github.com/open-mmlab/mmpose/blob/master/docs/en/install.md#install-mmposeに記載の手順による.
MMCV 1.6.2 をインストールしたので,MMDetection は 2系列になる(3系列は動かない)(2023年4月時点).
!python -m pip install -U openmim opencv-python !python -m pip install -U mmcv-full==1.6.2 !python -m pip install -U git+https://github.com/open-mmlab/mmclassification.git !python -m pip install -U mmdet==2.28.2 !python -m pip install -U git+https://github.com/open-mmlab/mmsegmentation.git !python -m pip install -U git+https://github.com/open-mmlab/mmtracking.git !python -m pip install -U git+https://github.com/open-mmlab/mmpose.git !apt -y install python3-numpy !apt -y install python3-scipy !python -c "import mmcls; print(mmcls.__version__)" !python -c "import mmdet; print(mmdet.__version__)" !python -c "import mmseg; print(mmseg.__version__)" !python -c "import mmtrack; print(mmtrack.__version__)" !python -c "import mmpose; print(mmpose.__version__)" !pip3 install git+https://github.com/votchallenge/toolkit.git
公式のデモプログラム(https://github.com/open-mmlab/mmpose/blob/master/demo/docs/2d_human_pose_demo.md)を使用.
公式ページの https://github.com/open-mmlab/mmpose/blob/master/demo/docs/2d_human_pose_demo.md で説明されているプログラムを使用.
人体の検出 (human detection) に,MMDetection を使用し, 姿勢推定に,MMPoseを使用.
!python3 demo/top_down_img_demo_with_mmdet.py \ demo/mmdetection_cfg/faster_rcnn_r50_fpn_coco.py \ https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth \ configs/body/2d_kpt_sview_rgb_img/topdown_heatmap/coco/hrnet_w48_coco_256x192.py \ https://download.openmmlab.com/mmpose/top_down/hrnet/hrnet_w48_coco_256x192-b9e0b3ab_20200708.pth \ --img-root tests/data/coco/ \ --img 000000000785.jpg \ --out-img-root vis_results from PIL import Image Image.open('./vis_results/vis_000000000785.jpg').show() !python3 demo/top_down_img_demo_with_mmdet.py \ demo/mmdetection_cfg/faster_rcnn_r50_fpn_coco.py \ https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth \ configs/body/2d_kpt_sview_rgb_img/topdown_heatmap/coco/hrnet_w48_coco_256x192.py \ https://download.openmmlab.com/mmpose/top_down/hrnet/hrnet_w48_coco_256x192-b9e0b3ab_20200708.pth \ --img-root tests/data/coco/ \ --img 000000040083.jpg \ --out-img-root vis_results from PIL import Image Image.open('./vis_results/vis_000000040083.jpg').show() !python3 demo/top_down_img_demo_with_mmdet.py \ demo/mmdetection_cfg/faster_rcnn_r50_fpn_coco.py \ https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth \ configs/body/2d_kpt_sview_rgb_img/topdown_heatmap/coco/hrnet_w48_coco_256x192.py \ https://download.openmmlab.com/mmpose/top_down/hrnet/hrnet_w48_coco_256x192-b9e0b3ab_20200708.pth \ --img-root tests/data/coco/ \ --img 000000196141.jpg \ --out-img-root vis_results from PIL import Image Image.open('./vis_results/vis_000000196141.jpg').show() !python3 demo/top_down_img_demo_with_mmdet.py \ demo/mmdetection_cfg/faster_rcnn_r50_fpn_coco.py \ https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth \ configs/body/2d_kpt_sview_rgb_img/topdown_heatmap/coco/hrnet_w48_coco_256x192.py \ https://download.openmmlab.com/mmpose/top_down/hrnet/hrnet_w48_coco_256x192-b9e0b3ab_20200708.pth \ --img-root tests/data/coco/ \ --img 000000197388.jpg \ --out-img-root vis_results from PIL import Image Image.open('./vis_results/vis_000000197388.jpg').show()
公式ページの https://github.com/open-mmlab/mmpose/blob/master/demo/docs/2d_wholebody_pose_demo.md で説明されているプログラムを使用.
人体の検出 (human detection) に,MMDetection を使用し, 姿勢推定に,MMPoseを使用.
1つ上の結果(人体の2次元姿勢推定)と比べて,顔の部分に違いがある.
!python3 demo/top_down_img_demo_with_mmdet.py \ demo/mmdetection_cfg/faster_rcnn_r50_fpn_coco.py \ https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth \ configs/wholebody/2d_kpt_sview_rgb_img/topdown_heatmap/coco-wholebody/hrnet_w48_coco_wholebody_384x288_dark_plus.py \ https://download.openmmlab.com/mmpose/top_down/hrnet/hrnet_w48_coco_wholebody_384x288_dark-f5726563_20200918.pth \ --img-root tests/data/coco/ \ --img 000000000785.jpg \ --out-img-root vis_results from PIL import Image Image.open('./vis_results/vis_000000000785.jpg').show() !python3 demo/top_down_img_demo_with_mmdet.py \ demo/mmdetection_cfg/faster_rcnn_r50_fpn_coco.py \ https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth \ configs/wholebody/2d_kpt_sview_rgb_img/topdown_heatmap/coco-wholebody/hrnet_w48_coco_wholebody_384x288_dark_plus.py \ https://download.openmmlab.com/mmpose/top_down/hrnet/hrnet_w48_coco_wholebody_384x288_dark-f5726563_20200918.pth \ --img-root tests/data/coco/ \ --img 000000040083.jpg \ --out-img-root vis_results from PIL import Image Image.open('./vis_results/vis_000000040083.jpg').show() !python3 demo/top_down_img_demo_with_mmdet.py \ demo/mmdetection_cfg/faster_rcnn_r50_fpn_coco.py \ https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth \ configs/wholebody/2d_kpt_sview_rgb_img/topdown_heatmap/coco-wholebody/hrnet_w48_coco_wholebody_384x288_dark_plus.py \ https://download.openmmlab.com/mmpose/top_down/hrnet/hrnet_w48_coco_wholebody_384x288_dark-f5726563_20200918.pth \ --img-root tests/data/coco/ \ --img 000000196141.jpg \ --out-img-root vis_results from PIL import Image Image.open('./vis_results/vis_000000196141.jpg').show() !python3 demo/top_down_img_demo_with_mmdet.py \ demo/mmdetection_cfg/faster_rcnn_r50_fpn_coco.py \ https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth \ configs/wholebody/2d_kpt_sview_rgb_img/topdown_heatmap/coco-wholebody/hrnet_w48_coco_wholebody_384x288_dark_plus.py \ https://download.openmmlab.com/mmpose/top_down/hrnet/hrnet_w48_coco_wholebody_384x288_dark-f5726563_20200918.pth \ --img-root tests/data/coco/ \ --img 000000197388.jpg \ --out-img-root vis_results from PIL import Image Image.open('./vis_results/vis_000000197388.jpg').show()
公式ページの https://github.com/open-mmlab/mmpose/blob/master/demo/docs/2d_hand_demo.md で説明されているプログラムを使用.
人体の検出 (human detection) に,MMDetection を使用し, 姿勢推定に,MMPoseを使用.
!python3 demo/top_down_img_demo_with_mmdet.py demo/mmdetection_cfg/cascade_rcnn_x101_64x4d_fpn_1class.py \ https://download.openmmlab.com/mmpose/mmdet_pretrained/cascade_rcnn_x101_64x4d_fpn_20e_onehand10k-dac19597_20201030.pth \ configs/hand/2d_kpt_sview_rgb_img/topdown_heatmap/onehand10k/res50_onehand10k_256x256.py \ https://download.openmmlab.com/mmpose/top_down/resnet/res50_onehand10k_256x256-e67998f6_20200813.pth \ --img-root tests/data/onehand10k/ \ --img 1402.jpg \ --out-img-root vis_results from PIL import Image Image.open('./vis_results/vis_1402.jpg').show() !python3 demo/top_down_img_demo_with_mmdet.py demo/mmdetection_cfg/cascade_rcnn_x101_64x4d_fpn_1class.py \ https://download.openmmlab.com/mmpose/mmdet_pretrained/cascade_rcnn_x101_64x4d_fpn_20e_onehand10k-dac19597_20201030.pth \ configs/hand/2d_kpt_sview_rgb_img/topdown_heatmap/onehand10k/res50_onehand10k_256x256.py \ https://download.openmmlab.com/mmpose/top_down/resnet/res50_onehand10k_256x256-e67998f6_20200813.pth \ --img-root tests/data/onehand10k/ \ --img 784.jpg \ --out-img-root vis_results from PIL import Image Image.open('./vis_results/vis_784.jpg').show() !python3 demo/top_down_img_demo_with_mmdet.py demo/mmdetection_cfg/cascade_rcnn_x101_64x4d_fpn_1class.py \ https://download.openmmlab.com/mmpose/mmdet_pretrained/cascade_rcnn_x101_64x4d_fpn_20e_onehand10k-dac19597_20201030.pth \ configs/hand/2d_kpt_sview_rgb_img/topdown_heatmap/onehand10k/res50_onehand10k_256x256.py \ https://download.openmmlab.com/mmpose/top_down/resnet/res50_onehand10k_256x256-e67998f6_20200813.pth \ --img-root tests/data/onehand10k/ \ --img 9.jpg \ --out-img-root vis_results from PIL import Image Image.open('./vis_results/vis_9.jpg').show()
公式ページの https://github.com/open-mmlab/mmpose/blob/master/demo/docs/2d_face_demo.md で説明されているプログラムを使用.
顔検出 に,Dlib と ageitgey/face_recognition (https://github.com/ageitgey/face_recognition) を使用. 顔のランドマーク検出に,MMPoseを使用.
公式ページの https://github.com/open-mmlab/mmpose/blob/master/demo/docs/3d_human_pose_demo.md で説明されているプログラムを使用.
!python3 demo/body3d_two_stage_video_demo.py \ demo/mmdetection_cfg/faster_rcnn_r50_fpn_coco.py \ https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth \ configs/body/2d_kpt_sview_rgb_img/topdown_heatmap/coco/hrnet_w48_coco_256x192.py \ https://download.openmmlab.com/mmpose/top_down/hrnet/hrnet_w48_coco_256x192-b9e0b3ab_20200708.pth \ configs/body/3d_kpt_sview_rgb_vid/video_pose_lift/h36m/videopose3d_h36m_243frames_fullconv_supervised_cpn_ft.py \ https://download.openmmlab.com/mmpose/body3d/videopose/videopose_h36m_243frames_fullconv_supervised_cpn_ft-88f5abbb_20210527.pth \ --video-path demo/resources/demo.mp4 \ --out-video-root vis_results \ --rebase-keypoint-height
MMPose のインストールと動作確認(姿勢推定,関節角度の推定)(PyTorch,Python を使用)(Windows 上): 別ページ »で説明している.
MMSegmentation は, OpenMMLab の構成物で,セグメンテーションの機能を提供する.
【文献】
MMSegmentation Contributors, MMSegmentation: OpenMMLab Semantic Segmentation Toolbox and Benchmark, https://github.com/open-mmlab/mmsegmentation, 2020.
【サイト内の関連ページ】
セマンティック・セグメンテーションの実行(MMSegmentation,PyTorch,Python を使用)(Windows 上)
【関連する外部ページ】
【関連項目】 OpenMMLab, MMCV, MMSelfSup
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
PyTorch は,ディープラーニングのフレームワークの 機能を持つ Pythonのパッケージ
次のプログラム実行により,PyTorch のバージョンが「1.10.0+cu111」のように表示される.
import torch print(torch.__version__)
次のプログラム実行により,NVIDIA CUDA ツールキットのバージョンが「cu111」のように表示される.
import torch CUDA_VERSION = torch.__version__.split("+")[-1] print(CUDA_VERSION)
import torch TORCH_VERSION = ".".join(torch.__version__.split(".")[:2]) print(TORCH_VERSION)
インストール手順は, https://mmcv.readthedocs.io/en/latest/get_started/installation.html に記載の手順による
MMTracking が MMVC 1.6.2 に依存している (2023年4月時点). MMTracking の利用を想定して MMCV 1.6.2 をインストールする.
!python -c "import torch; print(torch.__version__)" !apt remove python3-pycocotools !pip uninstall -y pycocotools !pip install mmpycocotools !apt install -y python3-terminaltables !apt install -y python3-opencv !pip install mmcv-full==1.6.2 !python3 -c "from mmcv.ops import get_compiling_cuda_version, get_compiler_version; print(get_compiling_cuda_version(), get_compiler_version())"
MMCV 1.7.1 をインストールしたので,MMDetection は 2系列になる(3系列は動かない)(2023年4月時点).
!python -m pip install -U openmim opencv-python !python -m pip install -U mmcv-full==1.7.1 !python -m pip install -U mmdet==2.28.2 !python -m pip install -U git+https://github.com/open-mmlab/mmsegmentation.git !python -c "import mmdet; print(mmdet.__version__)" !python -c "import mmseg; print(mmseg.__version__)"
次のプログラムは,MMSegmentation の機能を利用して,DeepLabv3+ を用いたセマンティック・セグメンテーションを行う.
詳しくは,MMSegmentation の DeepLabv3+ のページ: https://github.com/open-mmlab/mmsegmentation/tree/master/configs/deeplabv3plus
セマンティック・セグメンテーションの結果として得られる クラスが,色分けで表示される.
import torch from mmseg.apis import inference_segmentor, init_segmentor, show_result_pyplot import mmcv fimg = 'demo/demo.png' # DeepLabv3 fconfig = 'configs/deeplabv3/deeplabv3_r101-d8_fp16_512x1024_80k_cityscapes.py' fcheckpoint = 'https://download.openmmlab.com/mmsegmentation/v0.5/deeplabv3/deeplabv3_r101-d8_fp16_512x1024_80k_cityscapes/deeplabv3_r101-d8_fp16_512x1024_80k_cityscapes_20200717_230920-774d9cec.pth' # DeepLabv3+ fconfig = 'configs/deeplabv3plus/deeplabv3plus_r101-d8_fp16_512x1024_80k_cityscapes.py' fcheckpoint = 'https://download.openmmlab.com/mmsegmentation/v0.5/deeplabv3plus/deeplabv3plus_r101-d8_fp16_512x1024_80k_cityscapes/deeplabv3plus_r101-d8_fp16_512x1024_80k_cityscapes_20200717_230920-f1104f4b.pth' # OCRNet #fconfig = 'configs/ocrnet/ocrnet_hr48_512x1024_40k_cityscapes.py' #fcheckpoint = 'https://download.openmmlab.com/mmsegmentation/v0.5/ocrnet/ocrnet_hr48_512x1024_40k_cityscapes/ocrnet_hr48_512x1024_40k_cityscapes_20200601_033336-55b32491.pth' # SegFormer #fconfig = 'configs/segformer/segformer_mit-b2_8x1_1024x1024_160k_cityscapes.py' #fcheckpoint = 'https://download.openmmlab.com/mmsegmentation/v0.5/segformer/segformer_mit-b2_8x1_1024x1024_160k_cityscapes/segformer_mit-b2_8x1_1024x1024_160k_cityscapes_20211207_134205-6096669a.pth' device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') model = init_segmentor(fconfig, fcheckpoint, device=device) result = inference_segmentor(model, fimg) print(result) show_result_pyplot(model, fimg, result, opacity=0.5)
別ページ »で説明している.
「git checkout v0.14.1」は,バージョン 0.14.1 を指定している. これは,https://mmdetection3d.readthedocs.io/en/latest/get_started.html での2021/08 時点の説明による.将来はバージョン番号が変わる可能性があり,このページを確認してから,インストールを行うこと.
Ubuntu でインストールを行うには,次のコマンドを実行.
sudo apt -y update sudo apt -y install git cd /usr/local sudo git clone https://github.com/open-mmlab/mmsegmentation.git sudo chown -R $USER mmsegmentation cd mmsegmentation git checkout v0.14.1 python3 setup.py develop
Ubuntu の場合は, MMCV のドキュメント: https://mmsegmentation.readthedocs.io/en/latest/get_started.html#verification の手順がそのまま使えそうである.
Google Colaboratory でのインストールは,次のような手順になるようである(未確認).
%cd /content !rm -rf mmdetection3d.git !git clone https://github.com/open-mmlab/mmdetection3d.git %cd mmdetection3d !pip3 install importlib-metadata==4.2 !python3 setup.py develop !apt install -y python3-numba %cd mmdetection3d !python3 demo/pcd_demo.py demo/data/kitti/kitti_000008.bin configs/second/hv_second_secfpn_6x8_80e_kitti-3d-car.py checkpoints/hv_second_secfpn_6x8_80e_kitti-3d-car_20200620_230238-393f000c.pth
MMSelfSup は, OpenMMLab の構成物で, Self-Supervised Representation Learning の機能を提供する.
MMSelfSup Contributors, MMSelfSup: OpenMMLab Self-Supervised Learning Toolbox and Benchmark, https://github.com/open-mmlab/mmselfsup, 2021.
【関連項目】 MMCV, MMDetection, MMSegmentation, OpenMMLab, Self-Supervised Representation Learning, 物体検出
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
MMSelfSup のインストール(公式ページ): https://github.com/open-mmlab/mmselfsup/blob/master/docs/en/install.md
!pip3 install git+https://github.com/open-mmlab/mim.git
https://github.com/open-mmlab/mmdetection/blob/master/docs/en/get_started.md に記載の手順による
!mim install mmdet !pip3 show mmdet
次のプログラム実行により,MMSegmentation がインストールされる.
!rm -rf mmsegmentation.git !git clone https://github.com/open-mmlab/mmsegmentation.git %cd mmsegmentation !python3 setup.py develop
%cd /content rm -rf mmselfsup !git clone https://github.com/open-mmlab/mmselfsup.git %cd mmselfsup !python3 setup.py develop
公式ページ https://github.com/open-mmlab/mmselfsup/blob/master/docs/en/install.md に記載のプログラムを実行してみる.
エラーメッセージが出なければ OK.
import torch from mmselfsup.models import build_algorithm model_config = dict( type='Classification', backbone=dict( type='ResNet', depth=50, in_channels=3, num_stages=4, strides=(1, 2, 2, 2), dilations=(1, 1, 1, 1), out_indices=[4], # 0: conv-1, x: stage-x norm_cfg=dict(type='BN'), frozen_stages=-1), head=dict( type='ClsHead', with_avg_pool=True, in_channels=2048, num_classes=1000)) model = build_algorithm(model_config).cuda() image = torch.randn((1, 3, 224, 224)).cuda() label = torch.tensor([1]).cuda() loss = model.forward_train(image, label) print(loss)
MMTracking は, OpenMMLab の構成物で,トラッキング・ビジョンの機能を提供する.
【関連項目】 OpenMMLab, MMCV, MMDetection, MMPose, 物体検出
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
!pip3 install git+https://github.com/open-mmlab/mim.git
https://github.com/open-mmlab/mmdetection/blob/master/docs/en/get_started.md に記載の手順による
!mim install mmdet !pip3 show mmdet
!rm -rf mmtracking !git clone https://github.com/open-mmlab/mmtracking.git %cd mmtracking !pip3 install -r requirements/build.txt !pip3 install . !pip3 show mmtrack !pip3 install git+https://github.com/votchallenge/toolkit.git
!python3 demo/demo_mot_vis.py configs/mot/deepsort/sort_faster-rcnn_fpn_4e_mot17-private.py --input demo/demo.mp4 --output mot.mp4
mot.mp4 というファイルができるので,ダウンロードして表示
MMTracking のインストールと動作確認(トラッキングビジョン)(PyTorch,Python,MMCV,MMDetection を使用)(Windows 上): 別ページ »で説明している.
MNIST データセットは,公開されているデータセット(オープンデータ)である.
0 から 9 までの 10 種類の手書き文字についての, モノクロ画像と,各画像に付いた「0から9までの数値」のラベルから構成されるデータセットである.
(内訳)70000枚の内訳は次の通りである
60000枚:教師データ
10000枚:検証データ
【文献】
Y. Lecun, L. Bottou, Y. Bengio and P. Haffner, Gradient-based learning applied to document recognition, vol. 86, no. 11, pp. 2278-2324, 1998.
【サイト内の関連ページ】
【関連する外部ページ】
【関連項目】 Keras に付属のデータセット, Fashion MNIST データセット, TensorFlow データセット, オープンデータ, 画像分類
顔検証 (face verification) を,その当時の従来の mobile networks よりも高速で高精度で実行できるとされている.
InsightFace などで実装されている.
Sheng Chen, Yang Liu, Xiang Gao, Zhen Han, MobileFaceNets: Efficient CNNs for Accurate Real-Time Face Verification on Mobile Devices, CCBR 2018, also CoRR, abs/1804.07573v, 2018. https://arxiv.org/ftp/arxiv/papers/1804/1804.07573.pdf
【関連項目】 InsightFace, 顔検証 (face verification), 顔に関する処理
MobileNet は,separable convolution を特徴としている.ResNet の高速化が達成できたとされている.
MobileNetV2 は,conv 1x1, depthsise conv, conv 1x1 を特徴としている.高速化が達成できたとされている.
MobileNetV2 は,ディープラーニングでの画像分類などの高速化,精度向上のため Depthwise Separable Convolution という考え方が導入されていることが特徴である.
物体検出や セマンティック・セグメンテーションなどでのバックボーンでの利用も行われている.
Keras の MobileNetV2 を用いて MobileNetV2 を作成するプログラムは次のようになる. 「weights=None」を指定することにより,最初,重みをランダムに設定する.
【Keras のプログラム】
Keras の応用のページ: https://keras.io/ja/applications/
from tensorflow.keras.applications.mobilenet_v3 import MobileNetV3 m = MobileNetV3(input_shape=INPUT_SHAPE, weights=None, classes=NUM_CLASSES)
【サイト内の関連ページ】
物体検出や セマンティック・セグメンテーションなどでのバックボーンでの利用も行われている.
Andrew Howard, Mark Sandler, Grace Chu, Liang-Chieh Chen, Bo Chen, Mingxing Tan, Weijun Wang, Yukun Zhu, Ruoming Pang, Vijay Vasudevan, Quoc V. Le, Hartwig Adam, Searching for MobileNetV3, ICCV 2019
関連項目: 画像分類
Google Colab あるいはパソコン(Windows あるいは Linux)を使用.
前準備として,Python のインストール: 別項目で説明している., PyTorch のインストール を行う.
Google Colaboratory では, Python, PyTorch はインストール済みなので,インストール操作は不要.
次に,pip を用いて,pillow のインストールを行う.
pip install -U pillow
PyTorch, torchvision のモデルについては: https://pytorch.org/vision/stable/models.html に説明がある.
import torch import torchvision.models as models device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') m = models.mobilenet_v3_large(pretrained=True).to(device)
from PIL import Image import requests from IPython.display import display # ダウンロードとロード url = 'https://github.com/pytorch/hub/raw/master/images/dog.jpg' response = requests.get(url) img = Image.open(requests.get(url, stream=True).raw) # 確認表示 display(img)
from PIL import Image from torchvision import transforms img = Image.open(filename) preprocess = transforms.Compose([ transforms.Resize(256), transforms.CenterCrop(224), transforms.ToTensor(), transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]), ]) input_tensor = preprocess(img) input_batch = input_tensor.unsqueeze(0)
「m.eval()」は,推論を行うときのためのもの.これを行わないと訓練(学習)が行われる.
import torch if torch.cuda.is_available(): input_batch = input_batch.to('cuda') m.eval() with torch.no_grad(): output = m(input_batch)
import urllib url, filename = ("https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt", "imagenet_classes.txt") try: urllib.URLopener().retrieve(url, filename) except: urllib.request.urlretrieve(url, filename) with open("imagenet_classes.txt", "r") as f: categories = [s.strip() for s in f.readlines()] # The output has unnormalized scores. To get probabilities, you can run a softmax on it. probabilities = torch.nn.functional.softmax(output[0], dim=0) print(probabilities) top5_prob, top5_catid = torch.topk(probabilities, 5) for i in range(top5_prob.size(0)): print(categories[top5_catid[i]], top5_prob[i].item())
Google Colaboratory での結果
Windows での結果
Linux での結果
MongoDB は,ドキュメントデータモデルの機能をもつデータベース管理システム
【サイト内の関連ページ】
【関連する外部ページ】
MPII Human Pose データセット は, 人体全身の画像と姿勢のデータセットである. ディープラーニングにより姿勢推定を行うためのデータとして利用できる.
40,000人以上の人間を含む約25,000枚の画像が含まれている. (28,000 が訓練データ,11,000 が検証データである). 画像のアノテーションが行われている. 410 種類の人間の活動を網羅している. 各画像については,活動名のラベルが付いている. 画像はYouTubeの動画から抽出されたものである. テストデータセットでは,体のオクルージョン,胴体や頭の3次元での向きなど, より豊富なアノテーションが行われている.
次の URL で公開されているデータセット(オープンデータ)である.
URL: http://human-pose.mpi-inf.mpg.de/
ライセンス: BSD ライセンス.利用条件等は,利用者で確認すること.
【関連情報】
https://openaccess.thecvf.com/content_cvpr_2014/papers/Andriluka_2D_Human_Pose_2014_CVPR_paper.pdf
mkdir c:\data mkdir c:\data\mpii cd c:\data\mpii curl -O https://datasets.d2.mpi-inf.mpg.de/andriluka14cvpr/mpii_human_pose_v1_u12_2.zip powershell -command "Expand-Archive -DestinationPath . -Path mpii_human_pose_v1_u12_2.zip" curl -O https://datasets.d2.mpi-inf.mpg.de/andriluka14cvpr/mpii_human_pose_v1.tar.gz "c:\Program Files\7-Zip\7z.exe" x mpii_human_pose_v1.tar.gz mkdir images cd images "c:\Program Files\7-Zip\7z.exe" x ..\mpii_human_pose_v1.tar
Mykhaylo Andriluka and Leonid Pishchulin and Peter Gehler and Schiele, Bernt, 2D Human Pose Estimation: New Benchmark and State of the Art Analysis, IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2014, https://openaccess.thecvf.com/content_cvpr_2014/papers/Andriluka_2D_Human_Pose_2014_CVPR_paper.pdf
MS-Celeb-1M データセット を洗浄 (clean) したデータ. 画像サイズは 112x112. RetinaFace を用いて推定された,5点の顔ランドマーク (facial landmark)が付いている.
人物数は 94,682 (94,682 identities), 画像数は 6,464,018 枚 (6,464,018 images)
次の URL で公開されているデータセット(オープンデータ)である.
https://github.com/EB-Dodo/C-MS-Celeb
【関連項目】 InsightFace, MS-Celeb-1M データセット, RetinaFace, 顔のデータベース, 顔ランドマーク (facial landmark), 顔検出 (face detection)
MS-Celeb-1M は,顔のデータセット. このデータセットは,公開が撤回されている.
人物数は約 100,000 (100K identities), 画像数は約 8,000,000 枚 (8M images)
Yandong Guo, Lei Zhang, Yuxiao Hu, Xiaodong He, and Jianfeng Gao, MS-Celeb-1M: A Dataset and Benchmark for Large-Scale Face Recognition, In ECCV, 2016. arXiv:1607.08221
【関連項目】 C-MS-Celeb Cleaned データセット , InsightFace, 顔のデータベース, 顔検出 (face detection)
MUCT 顔データベースは,3755名の顔のデータベース.手作業で 76個の顔ランドマーク (facial landmark)が付けらている.
MUCT 顔データベースは次の URL で公開されているデータセット(オープンデータ)である.
URL: https://www.cs.columbia.edu/CAVE/software/curet/html/about.php
URL: http://www.milbo.org/muct/index.html
S. Milborrow and J. Morkel and F. Nicolls, The MUCT Landmarked Face Database, Pattern Recognition Association of South Africa, 2010.
Git の公式ページ: https://git-scm.com/
git clone https://github.com/StephenMilborrow/muct
【関連項目】 顔のデータベース, 顔ランドマーク (facial landmark)
顔の 68 ランドマーク は,顔ランドマーク (facial landmark)の一種であり,68 組の数値で構成されている.68 組のそれぞれは,(x, y) 座標値である.
R. Gross, I. Matthews, J. Cohn, T. Kanade, and S. Baker, Multi-pie, Image and Vision Computing, 28(5):807–813, 2010.
【関連項目】 顔の 68 ランドマーク の検出, 顔ランドマーク (facial landmark)
Multi View Stereo は,オブジェクトの特徴点である低密度の3次元点群と,オブジェクトを周囲から撮影した多数の画像から,高密度の3次元点群を生成する. 色付き3次元点群を生成する場合もある.「Dense Recontruction」ともいう.
meshroom,OpenMVS などのソフトウェアがある. Ubuntu での OpenMVS のインストールは 別ページ »で説明している.
【関連用語】 3次元再構成 (3D reconstruction), meshroom, OpenMVS, Structure from Motion
MusicGen は, 単一ステージのトランスフォーマー言語モデル(transformer language model)を特徴とする。 フレシェオーディオ距離 (FAD)、クルバック・ライブラーダイバージェンス (KL)、CLAPスコア (CLAP)という客観的指標ならびに、 全体的な品質および(ii)テキスト入力への関連性の主観的指標について、 baselines for text-to-music generation: Riffusion [Forsgren and Martiros] and Mousai [Schneider et al., 2023]をベースラインとして 評価が行われている。
【文献】
Jade Copet and Felix Kreuk and Itai Gat and Tal Remez and David Kant and Gabriel Synnaeve and Yossi Adi and Alexandre Défossez, Simple and Controllable Music Generation, arXiv preprint arXiv:2306.05284, 2023.
https://arxiv.org/pdf/2306.05284v1.pdf
【サイト内の関連ページ】
MusicGen のインストールと動作確認(作曲)(Python,PyTorch を使用)(Windows 上)
【関連する外部ページ】
Keras の NASNet を用いて NASNet を作成するプログラムは次のようになる. 「weights=None」を指定することにより,最初,重みをランダムに設定する.
【Keras のプログラム】
m = tf.keras.applications.nasnet.NASNetMobile(input_shape=INPUT_SHAPE, weights=None, classes=NUM_CLASSES)
CoRR, abs/1707.07012
Keras の応用のページ: https://keras.io/ja/applications/
参考文献: http://www.cs.toronto.edu/~fritz/absps/momentum.pdf
Ninja はビルドシステム.
Ninja の利用では,次のように操作する.
rmdir /s /q build mkdir build cd build del CMakeCache.txt cmake .. -G "Ninja" ^ -DCMAKE_C_COMPILER=clang-cl ^ -DCMAKE_CXX_COMPILER=clang-cl ^ -DCMAKE_BUILD_TYPE=Release ninja ninja install
【関連する外部ページ】
【インストール手順の詳細(別ページ) 】
【インストール手順の概要 】
rmdir /s /q ninja git clone https://github.com/ninja-build/ninja.git cd ninja git checkout release rmdir /s /q build mkdir build cd build del CMakeCache.txt cmake .. -G "Visual Studio 17 2022" -A x64 -T host=x64 ^ -DCMAKE_BUILD_TYPE=Release ^ -DCMAKE_INSTALL_PREFIX="C:/ninja" cmake --build. --config RELEASE cmake --build. --config RELEASE --target INSTALL .\Release\ninja_test.exe
Windows の システム環境変数 Pathに,C:\ninja\bin次を追加することにより,パスを通す.
コマンドプロンプトを管理者として実行: 別ページ »で説明
次のコマンドを実行
powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";C:\ninja\bin\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"
NumPy は,オープンソースの Python のライブラリ.数値計算,行列の機能を持つ.
配列では,添え字が複数になる. 下に,Python の numpy 配列のコンストラクタの例を示す.
import numpy as np M = np.array([[1, 2, 3], [4, 5, 6]]) print(M) print(M[0,], M[1,]) print(M[1,0], M[1,1], M[1,2])
numpy 配列の形は shape 属性である. numpy 配列の次元は ndim 属性である.
import numpy as np a = np.array([8,5,4,1,3]) print( a.shape ) print( a.ndim ) print(a) x = np.array([[1,2,3,4], [10,20,30,40], [100,200,300,400]]) print( x.shape ) print( x.ndim ) print(x)
Windows での numpy のインストールは, コマンドプロンプトを管理者として開き 次のコマンドを実行する.
python -m pip install -U numpy
Ubuntu での numpy のインストールは, 次のコマンドで行う.
sudo apt -y update sudo apt -y install python3-numpy
【サイト内の関連ページ】
Nteractは,Pythonなどのプログラムのソースコード,実行結果などを1つのノートとして残す機能をもったノートブック.
Windows で, コマンドプロンプトを管理者として開き次のようなコマンドを実行することにより, アンインストールできるようになる場合がある.
regsvr32.exe "C:\Program Files\NVIDIA Corporation\NVIDIA Nsight Systems 2019.3.7\Host-x86_64\msdia140.dll"
NVIDIA CUDA ツールキット は,NVIDIA社が提供する GPU 用のツールキットである.GPU を用いた演算のプログラム作成や動作のための各種機能を備えている.ディープラーニングでも利用されている.
【NVIDIA CUDA ツールキットの動作に必要なもの】
Windows で,NVIDIA グラフィックス・カードの種類を調べたいときは, hwinfo (URL: https://www.hwinfo.com) を使って調べることができる.
Windows のユーザ名が日本語のとき,nvcc がうまく動作しないエラーを回避するためである.
ユーザ環境変数 TEMP に「C:\TEMP」を設定するために, コマンドプロンプトで,次のコマンドを実行する.
mkdir C:\TEMP powershell -command "[System.Environment]::SetEnvironmentVariable(\"TEMP\", \"C:\TEMP\", \"User\")"
【サイト内の関連ページ】
【関連する外部ページ】
ZLIB DLL をインストールする.
NVIDIA CUDA ツールキットの nvcc の動作に必要.
Windows での Visual Studio Community 2022 のインストール: 別ページ »で説明している.
Build Tools for Visual Studio 2022 (ビルドツール for Visual Studio 2022) のインストール: 別ページ »で説明
但し,最新版ではない NVIDIA CUDA ツールキットのインストーラに同封されている NVIDIA ドライバは古いので, 最新版ではない NVIDIA CUDA ツールキットのインストーラを使うときは,別に, NVIDIA ドライバのダウンロードとインストールを行う.
次のページから,最新版の NVIDIA ドライバをダウンロードできる.
他のウインドウを開いている場合,NVIDIA CUDA ツールキットのインストールが失敗する場合がある.
NVIDIA CUDA ツールキットのアーカイブの公式ページ: https://developer.nvidia.com/cuda-toolkit-archive
NVIDIA cuDNN のページ: https://developer.nvidia.com/cudnn
必ず,使用する NVIDIA CUDA ツールキットにあう NVIDIA cuDNN を使うこと.
zip ファイルを展開したら,展開先の下の bin にパスを通す.
.exe ファイルの実行により「C:\Program Files\NVIDIA\CUDNN\v8.3 」にインストールされるので,C:\Program Files\NVIDIA\CUDNN\v8.3\bin に パスを通す.
zip ファイルを展開したら,展開先の下の bin にパスを通す.
NVIDIA CUDA ツールキットのインストールは,公式ページからインストール用のプログラムをダウンロードして実行. NVIDIA cuDNN は,公式ページから ZIP ファイルをダウンロード,展開(解凍)し,パスを通す.
【サイト内の関連ページ】
関連 Web ページ
Ubuntu でのインストールは,次のページで説明している.
NVIDIA CUDA ツールキット のバージョンは何でも良いと言う場合には,apt を用いて,次の操作でインストールすることができる. Ubuntu 20.04 では,NVIDIA CUDA バージョン 10.1 がインストールされる.
sudo apt -y update sudo apt -y install nvidia-cuda-dev nvidia-cuda-toolkit nvidia-cuda-toolkit-gcc
NVIDIA CUDA ツールキット,NVIDIA cuDNN については,次で情報を得ることができる.
次の公式ページを活用できる
Windows の場合は,コマンドプロンプトを管理者として開き次のコマンドを実行する.
python -m pip install tensorflow python -c "from tensorflow.python.client import device_lib; print(device_lib.list_local_devices())"
Ubuntu のシステム Python を使う場合は,次のコマンドを実行
sudo pip3 install tensorflow python3 -c "from tensorflow.python.client import device_lib; print(device_lib.list_local_devices())"
NVIDIA cuDNN は, NVIDIA CUDA ツールキット上で動作するディープラーニング・ライブラリである. 畳み込みニューラルネットワークや リカレントニューラルネットワークなど,さまざまなディープラーニングで利用されている.
Windows で,NVIDIA cuDNN の利用時に 「Could not locate zlibwapi.dll. Please make sure it is in your library path!」と表示されるときは, ZLIB DLL をインストールすること.
【関連する外部ページ】
【NVIDIA cuDNN の動作に必要なもの】
Windows で,NVIDIA グラフィックス・カードの種類を調べたいときは, hwinfo (URL: https://www.hwinfo.com) を使って調べることができる.
最新のNVIDIA CUDA ツールキットでは動かないということもあるので注意.
ZLIB DLL は,データの圧縮と展開(解凍)の機能を持ったライブラリ.
ZLIB DLL のインストールを行うため, Windows で,コマンドプロンプトを管理者として実行
コマンドプロンプトを管理者として実行: 別ページ »で説明
次のコマンドを実行.
但し,「v11.8」のところは,実際にインストールされている NVIDIA CUDA ツールキットのバージョンを確認し,読み替えてください.
cd "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin" curl -O http://www.winimage.com/zLibDll/zlib123dllx64.zip powershell -command "Expand-Archive -DestinationPath . -Path zlib123dllx64.zip" copy zlib123dllx64\dll_x64\zlibwapi.dll .
NVIDIA Developer Program の公式ページ: https://developer.nvidia.com/developer-program
NVIDIA Developer Program の公式ページ: https://developer.nvidia.com/developer-program
NVIDIA ドライバ, NVIDIA CUDA ツールキット, NVIDIA cuDNN のインストールは, NVIDIA グラフィックスボードを搭載しているパソコンであることが前提である.
Windows で NVIDIA グラフィックスボード の有無を確認するための手順は次の通りである.
Window のスタートメニューを開き,検索窓に「デバイスマネージャー」と入れることでアクセスできる
ここに「NVIDIA」の名前が含まれる項目の有無により, NVIDIA グラフィックスボード の有無を確認する.
NVIDIA ドライバは,NVIDIA 社製の GPU を動作させるのに必要なドライバである.次の NVIDIA の公式サイトからダウンロードできる.ダウンロードのときは,使用しているオペレーティングシステムとGPUに適したものを選ぶこと.
【関連する外部ページ】
NVIDIA ドライバのダウンロードの公式ページ: https://www.nvidia.co.jp/Download/index.aspx?lang=jp
画像数は 5019枚である.アノテーションされたインスタンスのインスタンス数は 2133375個である.
文献
Qi Wang, Junyu Gao, Wei Lin, and Xuelong Li. Nwpu- crowd: A large-scale benchmark for crowd counting and lo- calization. IEEE Transactions on Pattern Analysis and Ma- chine Intelligence, 2020.
【関連用語】 crowd counting, FIDTM, オープンデータ
Objectron は,3次元姿勢推定 (3D pose estimation) の機能を持つ. Objectron は,次の公式ページで,プログラムとデータセットが配布されている.
https://github.com/google-research-datasets/Objectron
次は,Objectron の動作画面.
Objectron は,Google Colaboratory で動かすことができる. Google Colaboratory で動かすときは,コードセルに,次の3行を張り付けて実行. あとは,公式ページのプログラムのコピー&ペーストで動く.
!pip3 install frozendict !git clone --recursive https://github.com/google-research-datasets/Objectron %cd Objectron
【関連項目】 Objectron データセット , 3次元姿勢推定 (3D pose estimation)
Objectron データセット は,15000のビデオと400万の画像を含む. これらはバイク,本,ボトル,カメラ,シリアルボックス,椅子,カップ,ラップトップ,靴といったカテゴリでアノテーションされている. Objectron データセットは,ビデオ,画像,オブジェクトの姿勢,カメラの姿勢,点群,平面のデータが含まれている. 各ビデオは同じオブジェクトを異なる角度から観察している.
【関連する外部ページ】
公式の GitHub のページ: https://github.com/google-research-datasets/Objectron
【関連項目】 Objectron
cd %HOMEPATH% curl -L -O https://dl.google.com/dl/cloudsdk/channels/rapid/GoogleCloudSDKInstaller.exe .\GoogleCloudSDKInstaller.exe
cd %HOMEPATH% mkdir records_shuffled gsutil cp -r gs://objectron/v1/records_shuffled records_shuffled
Objects365 データセットは,アノテーション済みの画像である. 機械学習での物体検出 の学習や検証に利用できるデータセット.
Objects365 データセットは次の URL で公開されているデータセット(オープンデータ)である.
https://www.objects365.org/overview.html
【関連情報】
セマンティック・セグメンテーションのモデル. 2020年発表.
Yuhui Yuan and Xilin Chen and Jingdong Wang, Object-Contextual Representations for Semantic Segmentation, ECCV, 2020.
【関連項目】 モデル, セマンティック・セグメンテーション
Octave の公式ページ: https://www.gnu.org/software/octave/
【サイト内の関連ページ】
one-hot エンコーディング (one-hot encodinng は,クラス番号を,長さがクラス数であるような数値ベクトルで,うち,1つだけが 1,残りが全て 0 になっているようなベクトルで表すこと. 1-of-k representation ともいう. クラス番号が 0, 1, 2, 3 の 4通りであるとき,one hot 表現では [1 0 0 0] [0 1 0 0] [0 0 1 0] [0 0 0 1] のように表す. Keras では,クラス番号を one hot 表現に変換するとき to_categorical 関数を用いる.
from tensorflow.keras.utils.np_utils import to_categorical print( to_categorical(0, 4) ) print( to_categorical(1, 4) ) print( to_categorical(2, 4) ) print( to_categorical(3, 4) )
次の Python プログラムは,Iris データセットのロードを行う.配列 X, y にロードしている. その後,訓練用データと検証用データへの分割と,one-hot エンコーディングを行っている. 確認表示で display を用いている.
import pandas as pd import sklearn.model_selection from sklearn.datasets import load_iris import tensorflow as tf from IPython.display import display iris = load_iris() x = iris.data y = iris.target x_train, x_test, y_train, y_test = sklearn.model_selection.train_test_split(x.reshape(x.shape[0], -1), y, train_size=0.5) y_train = tf.keras.utils.to_categorical(y_train) y_test = tf.keras.utils.to_categorical(y_test) display(x_train) display(y_train)
帰無仮説: パラメトリック検定.等分散である多群の検定.平均に差がない.
R システム で, one-way ANOVA (One-way analysis of variance) を行うプログラム.
one-way (一元配置) と言っているように, x は必ず 1 つの数値である. y は 1つの数値(カテゴリカル変数など)である.
anova(aov(x ~ y))
【関連項目】 検定
ONNX のインストールは,複数の方法がある.
ここでは, vcpkg を使う方法を使う方法を説明する.
c:\vcpkg\vcpkg search onnx c:\vcpkg\vcpkg install onnx[pybind11]:x64-windows c:\vcpkg\vcpkg install onnxruntime-gpu:x64-windows python -m pip install -U onnxruntime
Windows では,コマンドプロン プトを管理者として実行し, 次のコマンドを実行する.
c:\vcpkg\installed\x64-windows\bin
Open3D は,3次元データに関する種々の機能を Python, C から扱うことができるソフトウェア. 次の機能を持つ.
http://www.open3d.org/docs/release/compilation.html に記載の手順による.
コマンドプロンプトを管理者として実行: 別ページ »で説明
python -m pip install -U open3d
関連ファイルのインストールを行いたいので,下に書いた手順を進める.
Git の公式ページ: https://git-scm.com/
CMake の公式ダウンロードページ: https://cmake.org/download/
エラーを回避するために「/utf-8」を設定.
python -m pip install -U --ignore-installed numpy scikit-image cd %LOCALAPPDATA% rmdir /s /q Open3D git clone --recursive https://github.com/isl-org/Open3D cd Open3D del CMakeCache.txt cmake -G "Visual Studio 17 2022" -A x64 -T host=x64 ^ -DCMAKE_C_FLAGS="/DWIN32 /D_WINDOWS /W0 /utf-8" ^ -DCMAKE_CXX_FLAGS="/DWIN32 /D_WINDOWS /GR /EHsc /W0 /utf-8" ^ -DCMAKE_INSTALL_PREFIX="c:/Open3D" . cmake --build . --config Release --target ALL_BUILD cmake --build . --config Release --target INSTALL
起動ができれば OK とする.
%LOCALAPPDATA%\Open3D\bin\Open3D\Release\Open3DViewer.exe
ここは書きかけ.動作未検証です.
cd %LOCALAPPDATA% rmdir /s /q Open3D-ML git clone --recursive https://github.com/isl-org/Open3D-ML cd Open3D-ML python -m pip install -r requirements.txt python -m pip install -r requirements-torch.txt python -m pip install -U numpy chumpy json-tricks munkres xtcocotools yapf cd ..\Open3D del CMakeCache.txt cmake -G "Visual Studio 17 2022" -A x64 -T host=x64 ^ -DBUILD_PYTORCH_OPS=ON ^ -DBUILD_TENSORFLOW_OPS=OFF ^ -DBUNDLE_OPEN3D_ML=ON ^ -DOPEN3D_ML_ROOT=%LOCALAPPDATA%\Open3D-ML ^ -DGLIBCXX_USE_CXX11_ABI=OFF ^ -DCMAKE_C_FLAGS="/DWIN32 /D_WINDOWS /W0 /utf-8" ^ -DCMAKE_CXX_FLAGS="/DWIN32 /D_WINDOWS /GR /EHsc /W0 /utf-8" ^ -DUSE_SYSTEM_EIGEN3=ON ^ -DEigen3_DIR="c:/eigen/share/eigen3" ^ -DCMAKE_INSTALL_PREFIX="c:/Open3D" . cmake --build . --config Release --target ALL_BUILD cmake --build . --config Release --target INSTALL
前の手順でエラーメッセージを確認し,エラーメッセージが出ていないときは,続行することにして,次を実行する. (確認のときは,エラーメッセージを見落とさないように,表示を確認する.)
cmake --build . --config Release --target install-pip-package python -m pip show open3d
次を実行し,エラーメッセージが出ないことを確認する.
エラーメッセージが出た場合には, Open3D-ML 関連ファイルのインストールは断念する.
python -c "import open3d.ml.torch"
Open 3D Engine は,オープンソースの3次元ゲームエンジン.Amazon の Amazon Lumberyard の後継である.
o3de の URL: https://github.com/o3de/o3de
Windows での Open 3D Engine のインストール: 別ページ »で説明している.
【関連する外部ページ】
BLAS(Basic Linear Algebra Subprograms)は,行列演算,ベクトル演算の機能をもったプログラム群である.
OpenBLAS の Web ページ: https://www.openblas.net/
BLAS を用いたプログラムは,
https://gist.github.com/xianyi/6930656 などで公開されている.その実行手順は,で説明している.
Windows での OpenBLAS のインストール(Windows 上): 別ページ »で説明している.
Ubuntu でインストールを行うには,次のコマンドを実行.
OpenCLIP は,CLIP のオープンソース版である
【文献】
Mehdi Cherti, Romain Beaumont, Ross Wightman, Mitchell Wortsman, Gabriel Ilharco, Cade Gordon, Christoph Schuhmann, Ludwig Schmidt, Jenia Jitsev, Reproducible scaling laws for contrastive language-image learning, arXiv:2212.07143, 2022.
【サイト内の関連ページ】
OpenCLIP のインストールと動作確認(Image-Text)(Python,PyTorch を使用)(Windows 上): 別ページ »で説明している.
【関連する外部ページ】
OpenCV は,実時間コンピュータビジョン (real time computer vision) の アルゴリズムと文書とサンプルコードの集まり.
【サイト内の OpenCV 関連ページ】
【OpenCV の公式情報】
【関連項目】
OpenCV Python,
OpenCV のサンプルデータ ,
OpenCV のインストールと,C++ プログラムの実行,
Google Colaboratory でのインストールは,コードセルで次を実行
不具合を避けるため,headless 版をインストールしている.
Windows でのインストールは,コマンドプロンプトを管理者として開き次を実行
Ubuntu でのインストールは,次を実行
Ubuntu でのインストールは,次を実行
OpenCV の Python のサンプルプログラム
画像ファイルを準備しておく(ここでは,プログラム内でファイル名をfruits.jpg にしている).
Windows では,次のように実行して,Python のプログラムファイル a.py を作り,実行する.
Ubuntu では,Python のプログラムファイル(ファイル名は /tmp/a.py とする)を作成したのち,次のような手順で実行する.
OpenCV の C++ のサンプルプログラム
画像ファイルを準備しておく(ここでは,プログラム内でファイル名をfruits.jpg にしている).
別ページ »で説明している.
Ubuntu では,C++ のプログラムファイル(ファイル名は /tmp/a.cpp とする)を作成したのち,次のような手順で実行する.
以下,Windows と Ubuntu について説明.
【関連項目】
OpenCV,
OpenCV Python,
OpenCV のサンプルデータ
OpenCV 4.7.0 のインストール,動作確認(Windows 上): 別ページ »で説明している.
ソースコードからビルドして,インストールする.その詳細は: 別ページ »で説明公式ページhttps://docs.opencv.org/4.5.2/d3/d52/tutorial_windows_install.html
に説明がある.
インストールは複数の方法があるが,ここでは最も単純,確実な方法を案内する.
ファイル名 a.cpp で保存.
画像ファイルを準備しておく(ここでは,プログラム内でファイル名をfruits.jpg にしている).
画像表示が行われる.画面をクリックし,なにかのキーを押して閉じる.
ソースコードを用いてインストールすることにより,
最新版の機能を確認できる.
ソースコードの中にはデモプログラムやデータが付属しており便利である.
インストール時に,CUDA 対応などの設定ができる.
OpenCV, OpenCV Contrib のインストール,CUDA 対応可能(ソースコードを使用)(Ubuntu 上): 別ページ »で説明している.
ファイル名 a.cpp で保存.
次のようなコマンドで実行
ソースコードからビルドするときに「-D BUILD_opencv_world=ON」を付けなかったときは,
次のようなコマンドで実行
画像表示が行われる.画面をクリックし,なにかのキーを押して閉じる.
OpenCV のサンプルデータ (samples/data) は,インターネットで公開されているデータセット(オープンデータ)である.(他のオープンデータと同様に,利用条件は利用者で確認すること).
curl を用いて,次のような操作でダウンロードできる.
Python プログラム例
次は,パソコンに接続された USB カメラなどのカメラ画像表示を行う Python プログラムである.
「cv2.VideoCapture(0)」の0は,カメラの意味.(動画ファイルを表示したいときは,0の変わりにファイル名を書く)
カメラ画像表示が行われる.画面をクリックし「q」キーで終了.
Python プログラム例
次の CSV ファイルを作り,1.csv のようなファイル名で保存する.
Python プログラム例
画像に CSV ファイル内の x, y 値をプロット.
OpenFace の Web ページ: https://cmusatyalab.github.io/openface/
GitHub のページ:
https://github.com/cmusatyalab/openface
OpenGV は
Absolute camera pose computation,
Relative camera-pose computation,
Two methods for point-triangulation,
Arun's method for aligning point clouds
の機能を持つ.
Matlab, Python のインタフェースを持つ.
URL: https://laurentkneip.github.io/opengv/
論文:
L. Kneip, P. Furgale, “OpenGV: A unified and generalized approach to real-time calibrated geometric vision”, Proc. of The IEEE International Conference on Robotics and Automation (ICRA), Hong Kong, China. May 2014.
Ubuntu でインストールを行うには,次のコマンドを実行.
OpenMMLab の URL: https://openmmlab.com/
OpenMMLab の GitHub のページ: https://github.com/open-mmlab
関連項目:
MMAction2,
MMClassification,
MMCV,
MMDetection,
MMFewShot,
MMFlow,
MMGen,
MMPose,
MMSegmentation,
MMSegmentation3D
MMSelfSup,
MMTracking
OpenMVG は Structure from Motion の機能を持つソフトウェアソフトウェア.
OpenMVG が持っている Structure from Motion (SfM) の機能に,
Global Structure from Motion がある.
Global Structure from Motion は,
多数の視点からの画像を使う SfM において,視点の位置と向きの推定を(当時の手法よりも)より頑健かつ正確に推定できるとされている.
(その論文:
P. Moulon, P. Monasse and R. Marlet, "Global Fusion of Relative Motions for Robust, Accurate and Scalable Structure from Motion," 2013 IEEE International Conference on Computer Vision, 2013, pp. 3248-3255, doi: 10.1109/ICCV.2013.403.
https://www.researchgate.net/publication/261622957_Global_Fusion_of_Relative_Motions_for_Robust_Accurate_and_Scalable_Structure_from_Motion)
Windows での OpenMVG のインストールは,複数の方法がある.
ここでは,
vcpkg を使う方法と,
ソースコードからビルドする方法を説明する.
前準備として次を行う.
Git の公式ページ: https://git-scm.com/,
CMake の公式ダウンロードページ: https://cmake.org/download/
Windows では,コマンドプロン
プトを管理者として実行し,
次のコマンドを実行する.
c:\openmvg にインストールされる.
OpenMVG (2021/08/21 時点) Windows 10 64 ビット版の非公式ビルド: openMVG.zip
私がビルドしたもの,非公式,無保証,ソースコードを改変せずにビルドした.OpenMVG の MPL2 ライセンスによる.
Ubuntu でインストールを行うには,次のコマンドを実行.
デモプログラムとして,
所定の画像データセットをダウンロードし,SfM を実行する Python プログラムが付属している.
Windows では次の手順で行う.
デモプログラムの実行でできるファイルのうち,ply 形式ファイルの1つを MeshLabを用いて表示すると次のようになる.色付きの3次元点群である.
いくつかのコマンドを順に実行する.
Windows では次のような手順で行う.
最後の処理でできた,色付きの3次元点群のファイル(ply 形式ファイル)を MeshLabを用いて表示すると次のようになる.
続けて,次を実行する.上の結果を,OpenMVS を用いて処理している.実行には OpenMVS のインストールが必要
参考ページ: https://openmvg.readthedocs.io/en/latest/software/MVS/OpenMVS/ (公式の資料)
デモプログラムの実行でできるファイルのうち,ply 形式ファイルの1つを MeshLabを用いて表示すると次のようになる.色付きの3次元点群である.
OpenMVS は,Multi View Stereo の機能を持ったソフトウェア
【関連項目】
meshroom,
Multi View Stereo,
OpenMVG,
OpenMVS,
Structure from Motion (SfM)
Windows での OpenMVS のインストールは,複数の方法がある.
ここでは,
vcpkg を使う方法を説明する.
OpenStreetMap のデータは,Node, Way, Relation の 2種類である.
テキスト検知 (text detection), テキスト認識 (text recognition) の機能を持つ.
Yuning Du, Chenxia Li, Ruoyu Guo, Cheng Cui, Weiwei Liu, Jun Zhou, Bin Lu, Yehua Yang, Qiwen Liu, Xiaoguang Hu, Dianhai Yu, Yanjun Ma,
PP-OCRv2: Bag of Tricks for Ultra Lightweight OCR System,
CoRR, abs/2109.03144v2, 2021.
【関連項目】
テキスト検知 (text detection),
テキスト認識 (text recognition)
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.4/doc/doc_en/quickstart_en.md に記載の手順による.
あとで使用する.
説明は https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.4/doc/doc_en/models_list_en.md
https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.4/doc/doc_en/inference_ppocr_en.md で説明の手順による.
https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.4/doc/doc_en/inference_ppocr_en.md で説明の手順による.
https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.4/doc/doc_en/inference_ppocr_en.md で説明の手順による.
https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.4/doc/doc_en/inference_ppocr_en.md で説明の手順による.
https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.4/doc/doc_en/inference_ppocr_en.md で説明の手順による.
https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.4/doc/doc_en/inference_ppocr_en.md で説明の手順による.
OPT (Open Pre-Trained Transformer) は,事前学習済みの大規模言語モデル (large language model) である.GitHub のページでは,OPT-125M, OPT-350M, OPT-1.3B, OPT-2.7B, OPT-6.7B, OPT-13B, OPT-30B, OPT-66B, OPT-175B が公開されている.
【文献】
Susan Zhang, Stephen Roller, Naman Goyal, Mikel Artetxe, Moya Chen, Shuohui Chen, Christopher Dewan, Mona Diab, Xian Li, Xi Victoria Lin, Todor Mihaylov, Myle Ott, Sam Shleifer, Kurt Shuster, Daniel Simig, Punit Singh Koura, Anjali Sridhar, Tianlu Wang, Luke Zettlemoyer,
OPT: Open Pre-trained Transformer Language Models,
arXiv:2205.01068, 2022.
https://arxiv.org/pdf/2205.01068.pdf
【関連する外部ページ】
GitHub のページ: https://github.com/facebookresearch/metaseq/tree/main/projects/OPT
【関連項目】
FlexGen
TensorFlow 2 で訓練ループのプログラムを書くときに利用できるソフトウェア.
Orbit の GitHub のページ:
https://github.com/tensorflow/models/tree/master/orbit
関連項目: TensorFlow
Oxford-IIIT ペット データセットは、
は約200枚の画像と37の異なるカテゴリで構成されている。
主に犬と猫の画像とそれに対応するアノテーションデータが含まれており、
物体検出やセグメンテーションのタスクに利用できる.
【関連する外部ページ】
Windows でのダウンロード手順
Panda3D は,オープンソースのソフトウェア,3次元ゲームエンジン (3-D game engine),可視化,シミュレーションの機能を持つ.
Panda3D の URL: https://www.panda3d.org/
【サイト内の関連ページ】
TensorFlow などの機械学習フレームワークでは,入力として pandas のデータ構造をサポートしていることが多い.
【関連項目】
Iris データセット
次のようなプログラムでは,displayを用いて,Pandas のデータフレームを整形して表示している.
次の Python プログラムは,Iris データセットのロードと確認表示を行う.
Pandas データフレームの df にロードしている.
確認表示で display を用いている.
次の Python プログラムでは,次のことを行っている.
次の Python プログラムでは,to_numpy() を用いて,
Pandas データフレームを numpy.ndarray へ変換している.
Pandas のある特定の列(カラム)のデータについて,処理を繰り返したいときの書き方.iris は Iris データセットである.
Pandas のある特定の列(カラム)のデータについて,処理を繰り返すとき,ある条件(例えば 7 より大)のものだけ処理対象にしたいときの書き方
物体検出とインスタンス・セグメンテーション (instance segmentation)のためのネットワーク.
Mask R-CNN をもとに改善を行っている.
PANet のネットワークは,FPN バックボーンののち,
Bottom-up Path Augmentation を行い,
Adaptive Feature Pooling を行っている.
COCO データセット, Cityscapes データセット, MVD データセットでの実験から,物体検出とインスタンス・セグメンテーション (instance segmentation)の精度が向上したとされている.
CSPNet の公式の実装 (GitHub) のページでは,
PANetを用いた物体検出として,
CSPDarknet53-PANet-SPP,
CSPResNet50-PANet-SPP,
CSPResNeXt50-PANet-SPP
等の実装が公開されている.
Shu Liu, Lu Qi, Haifang Qin, Jianping Shi, Jiaya Jia,
Path Aggregation Network for Instance Segmentation,
CVPR 2018, also CoRR, https://arxiv.org/abs/1803.01534v4,
【関連項目】
Mask R-CNN
物体検出, インスタンス・セグメンテーション (instance segmentation), YOLOv5
PARE は,3次元人体姿勢推定(3D human pose estimation)の技術である.
オクルージョンの問題を解決するために,
Part Attention REgressor (PARE) が提案されている.
multi person tracker を用いて実装されており,画像の中に複数の人物がいても動くようになっている.
PARE のデモプログラムの実行結果を次に示す.
この実行結果を得るためのもととなる動画: kaneko_sample_video.mp4
実行結果の動画: kaneko_sample_video__result.mp4
Kocabas, Muhammed and Huang, Chun-Hao P. and Hilliges, Otmar and Black, Michael J.,
PARE: Part Attention Regressor for {3D} Human Body Estimation,
Proc. International Conference on Computer Vision (ICCV),
also CoRR, abs/2104.08527v2, 2021.
【関連項目】
3D pose estimation,
3D human pose estimation,
YOLOv3,
multi person tracker
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
前準備:事前に Python のインストール: 別項目で説明している.,
NVIDIA CUDA ツールキット,NVIDIA cuDNN のインストール: 別項目で説明している.を行うこと.
出来た動画を表示すると,次のように表示される.
Pascal VOC データセットは,アノテーション済みの画像データ.
機械学習での物体検出 ,画像分類,セマンテック・セグメンテーションに利用できるデータセットである.
Pascal VOC 2007, Pascal VOC 2012 などいくつかの種類がある.
Pascal VOC 2012 データセット
vehicles, household, animals, and other: aeroplane, bicycle, boat, bus, car, motorbike, train, bottle, chair, dining table, potted plant, sofa, TV/monitor, bird, cat, cow, dog, horse, sheep, person
Pascal VOC データセットは次の URL で公開されているデータセット(オープンデータ)である.
http://host.robots.ox.ac.uk/pascal/VOC/
【関連情報】
Everingham, M., Van Gool, L., Williams, C. K. I., Winn, J. and Zisserman, A.,
The Pascal Visual Object Classes (VOC) Challenge,
International Journal of Computer Vision, 88(2), 303-338, 2010
Everingham, M., Eslami, S. M. A., Van Gool, L., Williams, C. K. I., Winn, J. and Zisserman, A.,
The Pascal Visual Object Classes Challenge: A Retrospective,
International Journal of Computer Vision, 111(1), 98-136, 2015.
【関連項目】
Detectron2,
MMSegmentation,
セマンティック・セグメンテーション (semantic segmentation),
画像分類,
物体検出
processed Pascal VOC 2007, 2012 データセットは,VOS の成果物.
VOS の GitHub のページ: https://github.com/deeplearning-wisc/vos
Windows での展開手順は次の通り.
https://drive.google.com/file/d/1n9C4CiBURMSCZy2LStBQTzR17rD_a67e/view
Photo Tourism データセットは次の URL で公開されているデータセット(オープンデータ)である.
http://phototour.cs.washington.edu/datasets/
【関連情報】
Noah Snavely, Steven M. Seitz, Richard Szeliski, "Photo tourism: Exploring photo collections in 3D," ACM Transactions on
Graphics (SIGGRAPH Proceedings), 25(3), 2006, 835-846.
Places365 データセットは,シーンクラスに分類済みの画像データ.
機械学習での画像分類の学習や検証に利用できるデータセット.
Places365 データセットは次の URL で公開されているデータセット(オープンデータ)である.
【関連情報】
https://github.com/PointCloudLibrary/data
では,
3次元点群データ (3-D point cloud data) が公開されている(オープンデータである).
Windows では,次のような手順でダウンロードできる.
Git の公式ページ: https://git-scm.com/
Ubuntu では,次のようなコマンドでダウンロードできる.
3次元点群データ (3-D point cloud data) を扱うには,MeshLab や CloudCompare が便利である.
スケルトンベースの動作認識 (skelton-based action recognition) の一手法.2021年発表
Haodong Duan and Yue Zhao and Kai Chen and Dian Shao and Dahua Lin and Bo Dai,
Revisiting Skeleton-based Action Recognition,
arXiv, 2104.13586, 2021.
【関連項目】
MMAction2,
スケルトンベースの動作認識 (skelton-based action recognition),
動作認識 (action recognition)
【サイト内の主な PostgreSQL 関連ページ】
【関連する外部ページ】
PyCharm は Python プログラム作成に関する種々の機能を持ったソフトウェア.
PyCharm について:別ページ で説明している.
pycocotools は,COCO データセットを Python から扱う機能を持ったソフトウェア.
pycocotools の GitHub のページ: https://github.com/cocodataset/cocoapi/tree/master/PythonAPI/pycocotools
関連項目: COCO (Common Object in Context) データセット
オリジナルの pycocotools から分岐 (fork) したレポジトリがある.
Python 3 や Windows に対応.オリジナルの方は開発が休止しているようである.
Git の公式ページ: https://git-scm.com/
Ubuntu でインストールを行うには,次のコマンドを実行.
関連項目: COCO (Common Object in Context) データセット
PyMVPAは,大規模データセットに対する統計的学習解析の
機能を持つ Pythonのパッケージ
PyMVPA の URL: http://www.pymvpa.org/index.html
PyCharm は Python プログラム作成に関する種々の機能を持ったソフトウェア.
PyScripter について:別ページ で説明している.
Python のまとめ: 別ページ に Python をまとめている.
Python の公式ページ">https://www.python.org/
Python 3.6 は scipy 1.1.0 が動く最新バージョン.
Python の公式ページ">https://www.python.org/
Python 3.7 は TensorFlow 1.15,TensorFlow 1.14 が動く最新バージョン.
Python の公式ページ">https://www.python.org/
Python の公式ページ">https://www.python.org/
ベクトルは,要素の並び.各要素の添字は 0, 1, 2... のようになる.
下に,Python の numpy ベクトルのコンストラクタの例を示す.
reshape の例は次の通り
Python の公式ページ: https://www.python.org/
Windows での Python 3.10 のインストール,pip と setuptools の更新: 別ページ »で説明している.
Ubuntu のシステム Python,Ubuntu での Python のインストール,pip と setuptools の更新: 別ページ »で説明している.
Python の隔離された環境: 別ページ »で説明している.
Python, pip, Python 開発環境,Python コンソールのコマンドでの起動: 別ページ »で説明している.
Python, pip, Python 開発環境,Python コンソールのコマンドでの起動: 別ページ »で説明している.
Windows での Python 開発環境として,Python コンソール(Jupyter Qt Console), Jupyter ノートブック (Jupyter Notebook), Jupyter Lab, Nteract, spyder のインストール: 別ページ »で説明している.
Ubuntu での Python 開発環境として,Python コンソール(Jupyter Qt Console), Jupyter ノートブック (Jupyter Notebook), Jupyter Lab, Nteract, spyder のインストール: 別ページ »で説明している.
PyTorchは,ディープラーニングのフレームワークの
機能を持つ Pythonのパッケージ
【関連する外部ページ】
【関連項目】
PyCharm,
Python のインストール,pip と setuptools の更新,
Python 開発環境
PyTorch の Stable が対応している Python のバージョン:
https://pytorch.org/
の表示や,
https://download.pytorch.org/whl/lts/1.8/torch_lts.html,
https://download.pytorch.org/whl/cu117/torch_stable.html
で確認できる.
2022年12月時点では次の通りである.
PyTorch のページで確認ののち,次のようなコマンドを実行(実行するコマンドは,PyTorch のページの表示されるコマンドをそのまま使う).
PyTorch のページ: https://pytorch.org/index.html
次のコマンドは,
PyTorch 2.0 (NVIDIA CUDA 11.8 用) をインストールする.
但し,Anaconda3を使いたい場合には別手順になる.
事前に NVIDIA CUDA のバージョンを確認しておくこと(ここでは,NVIDIA CUDA ツールキット 11.8 が前もってインストール済みであるとする).
PyTorch で,GPU が動作している場合には,「torch.cuda.is_available()」により,True が表示される.
以上のことについて,詳しくは: 別ページ »で説明している.
【サイト内の関連ページ】
PyTorch のインストールは,
公式 (https://pytorch.org/) の手順で行う.
NVIDIA CUDA ツールキット を使うときは,
NVIDIA ドライバは別途インストールすることと,CUDA のバージョン選択では「CUDA 同封の PyTorch を選択する」ことを心に留める.次の手順になる.
次の Python プログラムを実行
次の Python プログラムを実行
GPU マシン (cuda の動くマシン)で PyTorch を動かす可能性を想定している.
GPU マシン (cuda の動くマシン)でも,そうでなくても,正しく動くようにしている.
前準備: torchsummary をインストールする.
Windows ではコマンドプロンプトを管理者として開き次のコマンドを実行する.
ResNet50 モデルのロードと確認表示
公式ページ(GitHub): https://github.com/facebookresearch/pytorch3d
次のコマンドは Google Colaboratory で動く(コードセルを作り,実行する).
Avatar Erik Linder-Norén により GitHub で公開されているPyTorch-GAN のページ.
URL は次の通り.
PyTorch-GAN のページ: https://github.com/eriklindernoren/PyTorch-GAN
【文献】
Benedek Rozemberczki and Paul Scherer and Yixuan He and George Panagopoulos and Alexander Riedel and Maria Astefanoaei and Oliver Kiss and Ferenc Beres and Guzman Lopez and Nicolas Collignon and Rik Sarkar,
PyTorch Geometric Temporal: Spatiotemporal Signal Processing with Neural Machine Learning Models,
Proceedings of the 30th ACM International Conference on Information and Knowledge Management,
pp. 4564-4573, 2021.
【サイト内の関連ページ】
PyTorch Geometric Temporal のインストールと動作確認(予測)(Python,PyTorch を使用)(Windows 上)別ページ »で説明している.
【関連する外部ページ】
https://github.com/benedekrozemberczki/pytorch_geometric_temporal
https://pytorch-geometric-temporal.readthedocs.io/en/latest/
https://github.com/benedekrozemberczki/pytorch_geometric_temporal/tree/master/notebooks
【関連項目】
GNN (グラフニューラルネットワーク)
URL: https://pytorch.org/vision/stable/models.html に説明がある.
【関連項目】
PyTorch, torchvision の DenseNet121 学習済みモデルのロード,画像分類のテスト実行,
PyTorch, torchvision の DenseNet169 学習済みモデルのロード,画像分類のテスト実行,
PyTorch, torchvision の MobileNetV3 large 学習済みモデルのロード,画像分類のテスト実行,
PyTorch, torchvision の ResNet50 学習済みモデルのロード,画像分類のテスト実行,
PyTorch, torchvision の ResNet101 学習済みモデルのロード,画像分類のテスト実行,
PyTorch, torchvision の ResNet152 学習済みモデルのロード,画像分類のテスト実行,
PyTorch, torchvision の ResNeXt51 32x4d 学習済みモデルのロード,画像分類のテスト実行,
PyTorch, torchvision の ResNeXt101 32x8d 学習済みモデルのロード,画像分類のテスト実行,
PyTorch, torchvision の Wide ResNet50 学習済みモデルのロード,画像分類のテスト実行,
PyTorch, torchvision の Wide ResNet101 学習済みモデルのロード,画像分類のテスト実行,
rwightman の PyTorch Image Models (TIMM)
URL: https://github.com/ray-cast/RabbitToolbox
【関連用語】
MMD
Git の公式ページ: https://git-scm.com/
ソースコードからビルドして,インストールする.
画像タグ付けの学習は画像とテキストのペアを訓練データとして使用する。
Recognize Anything Model(RAM)は、画像タグ付けのためのモデルで、手動でのアノテーションではなく、テキストのセマンティック解析を自動化することでラベルを取得することを特徴とする。
Recognize Anything Model(RAM)のラベルシステムは、6,449の一般的なラベルを含んでいる。
また、データエンジンは、欠落しているラベルを追加し、誤ったラベルをクリーニングするために使用される。
データエンジンは既存のモデルを用いて追加のタグを生成し、画像内の特定のカテゴリに対応する領域を特定します。その後、同じカテゴリ内の領域を処理し、異常値を排除します。
さらに、Recognize Anything Model(RAM)は画像タグ付けとキャプションのタスクを統合し、その結果、ゼロショット画像タグ付けを可能にしている。これにより、未見のカテゴリについての処理が可能になる。また、学習のコストを抑制するために、Recognize Anything Model(RAM)はオープンソースでアノテーションフリーのデータセットを使用する。これらの特性により、Recognize Anything Model(RAM)はゼロショットの画像タグ付けだけでなく、学習済みモデルを用いた画像タグ付けでも高い性能を示すとされる。これは、OpenImages V6、COCO、ADE20kなどの一連のベンチマークデータセットでの評価により裏付けられている。
【文献】
Recognize Anything: A Strong Image Tagging Model
6 Jun 2023 · Youcai Zhang, Xinyu Huang, Jinyu Ma, Zhaoyang Li, Zhaochuan Luo, Yanchun Xie, Yuzhuo Qin, Tong Luo, Yaqian Li, Shilong Liu, Yandong Guo, Lei Zhang ·
https://arxiv.org/pdf/2306.03514v3.pdf
【サイト内の関連ページ】
Recognize Anything のインストールと動作確認(ゼロショットの画像タグ付け)(Python,PyTorch を使用)(Windows 上)
【関連する外部ページ】
Raspberry Pi は小型コンピュータ,Raspbian (Debian ベース) や Ubuntu が動く.
Rapberry Pi のシステムは,SD カードに入っている.
SD カードの所定のファイルを編集することで,パスワードを
リセットできる.
(このことからも,Raspberry Pi で大事なファイルを保持することは考えにくい
超解像 (super resolution) の一手法.2021 年発表.
【文献】
Xintao Wang and Liangbin Xie and Chao Dong and Ying Shan,
Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data,
International Conference on Computer Vision Workshops (ICCVW), https://arxiv.org/abs/2107.10833, 2021.
【関連する外部ページ】
処理前の画像
処理結果
【関連項目】
APA,
GAN (Generative Adversarial Network),
image super resolution,
video restoration,
video super resolution,
超解像 (super resolution),
Real-ESRGAN のインストールと動作確認(超解像)(Python,PyTorch を使用)(Windows 上): 別ページ »で説明している.
Redis は,インメモリ・データストアである.文字列,リスト,集合,ハッシュなどを扱う機能を持つ.
【サイト内の関連ページ】
【関連する外部ページ】
Redis の公式ページ: https://redis.io/
Redis の GitHub のページ: https://github.com/redis/redis/tags
ReLU (rectified linear unit) は,次の関数である.
f(x) = 0 for x < 0, f(x) = x for x >= 0
ReLUは,活性化関数としてよく使用されるもののうちの1つである.
活性化関数は,ニューロンの入力の合計から,そのニューロンの活性度の値を決めるためのもの.
(他には,LReLU,シグモイド関数,ステップ関数,ソフトマックス関数などがある.
residual function (残余関数)を特徴とするニューラルネットワーク
画像分類のための利用,
物体検出や
セマンティック・セグメンテーションなどでのバックボーンでの利用などが行われている.
Residual Networks は
DeepLabv3,
Inception-v4, Inception-ResNet,
ResNet50, ResNet101, ResNet152, その他の ResNet,
ResNeXt,
RetinaNet,
SpineNet
など,種々のモデルで使用されている.
Vighnesh Birodkar, Zhichao Lu, Siyang Li, Vivek Rathod, Jonathan Huang,
The surprising impact of mask-head architecture on novel class segmentation,
2021.
Xianzhi Du, Tsung-Yi Lin, Pengchong Jin, Golnaz Ghiasi, Mingxing Tan, Yin Cui, Quoc V. Le, Xiaodan Song,
SpineNet: Learning Scale-Permuted Backbone for Recognition and Localization, CVPR 2020, 2020.
Meta Pseudo Labels,
Hieu Pham, Zihang Dai, Qizhe Xie, Minh-Thang Luong, Quoc V. Le,
CVPR 2021, 2021.
https://arxiv.org/pdf/2003.10580v4.pdf
Liang-Chieh Chen, George Papandreou, Florian Schroff, Hartwig Adam,
Rethinking Atrous Convolution for Semantic Image Segmentation,
2017.
Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, Piotr Dollár,
Focal Loss for Dense Object Detection,
ICCV 2017, 2017.
Christian Szegedy, Sergey Ioffe, Vincent Vanhoucke, Alex Alemi,
Inception-v4, Inception-ResNet and the Impact of Residual Connections on Learning, 2016.
Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun,
Deep Residual Learning for Image Recognition,
CVPR 2016, 2016.
https://arxiv.org/pdf/1512.03385v1.pdf
【関連項目】
DeepLabv3,
ResNet50, ResNet101, ResNet152, その他の ResNet,
ResNeXt,
RetinaNet,
セマンティック・セグメンテーション (semantic segmentation),
画像分類
物体検出,
Keras の ResNet50 を用いて ResNet50 のモデルを作成するプログラムは次のようになる.
「weights=one」を指定することにより,最初,重みをランダムに設定する.
【Keras のプログラム】
CoRR, abs/1512.03385
Keras の応用のページ: https://keras.io/ja/applications/
【関連項目】
Residual Networks (ResNets),
モデル,
画像分類
PyTorch HUB のページ:
https://pytorch.org/hub/pytorch_vision_resnet/ を参考にした.
Google Colab あるいはパソコン(Windows あるいは Linux)を使用.
前準備として,Python のインストール: 別項目で説明している.,
PyTorch のインストール を行う.
Google Colaboratory では,
Python, PyTorch はインストール済みなので,インストール操作は不要.
次に,pip を用いて,pillow のインストールを行う.
PyTorch, torchvision のモデルについては: https://pytorch.org/vision/stable/models.html に説明がある.
「m.eval()」は,推論を行うときのためのもの.これを行わないと訓練(学習)が行われる.
Google Colaboratory での結果
Windows での結果
Linux での結果
PyTorch HUB のページ:
https://pytorch.org/hub/pytorch_vision_resnet/ を参考にした.
Google Colab あるいはパソコン(Windows あるいは Linux)を使用.
前準備として,Python のインストール: 別項目で説明している.,
PyTorch のインストール を行う.
Google Colaboratory では,
Python, PyTorch はインストール済みなので,インストール操作は不要.
次に,pip を用いて,pillow のインストールを行う.
PyTorch, torchvision のモデルについては: https://pytorch.org/vision/stable/models.html に説明がある.
「m.eval()」は,推論を行うときのためのもの.これを行わないと訓練(学習)が行われる.
Google Colaboratory での結果
Windows での結果
Linux での結果
PyTorch HUB のページ:
https://pytorch.org/hub/pytorch_vision_resnet/ を参考にした.
Google Colab あるいはパソコン(Windows あるいは Linux)を使用.
前準備として,Python のインストール: 別項目で説明している.,
PyTorch のインストール を行う.
Google Colaboratory では,
Python, PyTorch はインストール済みなので,インストール操作は不要.
次に,pip を用いて,pillow のインストールを行う.
PyTorch, torchvision のモデルについては: https://pytorch.org/vision/stable/models.html に説明がある.
「m.eval()」は,推論を行うときのためのもの.これを行わないと訓練(学習)が行われる.
Google Colaboratory での結果
Windows での結果
Linux での結果
ResNeXt は,ResNet の redidual unit で grouped conv3x3 を使うとともに,conv2x1 の次元削減率を抑制することにより,速度を低下させず,精度を向上させるものである.
物体検出や
セマンティック・セグメンテーションなどでのバックボーンでの利用も行われている.
Saining Xie, Ross B. Girshick, Piotr Doll{\'{a}}r, Zhuowen Tu, Kaiming He,
Aggregated Residual Transformations for Deep Neural Networks,
CoRR, abs/1611.05431, 2016.
【関連項目】
PyTorch, torchvision のモデル,
Residual Networks (ResNets),
SE ResNeXt,
モデル,
画像分類
PyTorch HUB のページ:
https://pytorch.org/hub/pytorch_vision_resnext/ を参考にした.
Google Colab あるいはパソコン(Windows あるいは Linux)を使用.
前準備として,Python のインストール: 別項目で説明している.,
PyTorch のインストール を行う.
Google Colaboratory では,
Python, PyTorch はインストール済みなので,インストール操作は不要.
次に,pip を用いて,pillow のインストールを行う.
PyTorch, torchvision のモデルについては: https://pytorch.org/vision/stable/models.html に説明がある.
「m.eval()」は,推論を行うときのためのもの.これを行わないと訓練(学習)が行われる.
Google Colaboratory での結果
Windows での結果
Linux での結果
PyTorch HUB のページ:
https://pytorch.org/hub/pytorch_vision_resnext/ を参考にした.
Google Colab あるいはパソコン(Windows あるいは Linux)を使用.
前準備として,Python のインストール: 別項目で説明している.,
PyTorch のインストール を行う.
Google Colaboratory では,
Python, PyTorch はインストール済みなので,インストール操作は不要.
次に,pip を用いて,pillow のインストールを行う.
PyTorch, torchvision のモデルについては: https://pytorch.org/vision/stable/models.html に説明がある.
「m.eval()」は,推論を行うときのためのもの.これを行わないと訓練(学習)が行われる.
Google Colaboratory での結果
Windows での結果
Linux での結果
focal loss 関数を特徴とする物体検出のモデルである.
Lin, Tsung-Yi and Goyal, Priya and Girshick, Ross and He, Kaiming and Doll\'ar, Piotr,
Focal loss for dense object detection,
Proceedings of the IEEE international conference on computer vision,
also CoRR, abs/1708.02002v2
2017.
【関連項目】
AlexeyAB darknet,
Detectron,
Detectron2,
OpenMMLab,
MMDetection,
Residual Networks (ResNets),
SpineNet,
TensorFlow,
YOLOv3,
モデル,
物体検出
Reuters newswire topics データセットは,公開されているデータセット(オープンデータ)である.
Reuters newswire topics データセットは,次のプログラムでロードできる.
【関連項目】
Keras に付属のデータセット,
RIB ファイルは,RenderMan で使用されているシーン記述ファイルである.
より詳しい説明は: 別ページ »で説明している.
ある層でのニューロンでの結果を,1つ前の層が受け取ったり,
その層が受け取ったりするようにニューラルネットワークを作る場合もある.
そのようなニューラルネットワークを「リカレントニューラルネットワーク」という.
リカレントニューラルネットワークは,フィードフォワードではない.
リカレントニューラルネットワークでは,前回の実行時での結果の一部が,次の実行に反映される.
【関連項目】
GRU (Gated Recurrent Neural Networks),
LSTM (Long Short-Term Memory),
フィードフォワード
学習,検証,推論を行うスクリプトは,
https://github.com/rwightman/pytorch-image-models
で説明が行われている.
【関連項目】
PyTorch, torchvision のモデル,
モデル,
画像分類 (image classification)
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
画像ファイルは複数でも良い.下の図では,img を作り,そこに画像ファイルを1つ置いている.
画像分類の結果が表示される.
事前学習済みの MobileNetV3 を使用している.
画像分類の結果が表示される.
事前学習済みの SE ResNeXt を使用している.
Git の公式ページ: https://git-scm.com/,
コマンドプロンプトを管理者として実行: 別ページ »で説明
PyTorch のページで確認ののち,次のようなコマンドを実行(実行するコマンドは,PyTorch のページの表示されるコマンドをそのまま使う).
PyTorch のページ: https://pytorch.org/index.html
次のコマンドは,
PyTorch 2.0 (NVIDIA CUDA 11.8 用) をインストールする.
但し,Anaconda3を使いたい場合には別手順になる.
事前に NVIDIA CUDA のバージョンを確認しておくこと(ここでは,NVIDIA CUDA ツールキット 11.8 が前もってインストール済みであるとする).
PyTorch で,GPU が動作している場合には,「torch.cuda.is_available()」により,True が表示される.
画像ファイルは複数でも良い.下の図では,img を作り,そこに画像ファイルを1つ置いている.
画像分類の結果が表示される.
事前学習済みの MobileNetV3 を使用している.
画像分類の結果が表示される.
事前学習済みの SE ResNeXt を使用している.
R システムは,統計計算とグラフィックスのソフトウェアで,多数の機能を持つ.
R システムの詳細は,そのホームページ
https://www.r-project.org/
に記載されている.
【関連する外部ページ】
R システムの CRAN の URL: https://cran.r-project.org/
【サイト内の主な R 関連ページ】
R システムの運用(パッケージのインストール,タスク・ビューのインストール,パッケージの更新など
タスク・ビューの詳細については,CRAN Task View のページ: https://cran.r-project.org/web/views/
【関連項目】
R データセット
R データセット (Rdatasets)は,
1700 を超えるデータセットの集まり.
R データセット (Rdatasets) の URL:
https://vincentarelbundock.github.io/Rdatasets
Python で
R データセット (Rdatasets)を用いる場合には,
次のように,データ名とパッケージを指定する.
データ名とパッケージは,https://vincentarelbundock.github.io/Rdatasets で確認できる.
Segment Anything(SA)は、画像セグメンテーションのための基盤モデルを構築することを目的としたプロジェクトである。このプロジェクトでは、新しいデータ分布とタスクに一般化できるプロンプト可能なセグメンテーションモデルSegment Anything Model(SAM)が開発された。Segment Anything Model(SAM)はゼロショットでのセグメンテーションが可能である。さらに、1100万枚以上の画像と、それらの画像に対する10億以上のマスクを含むセグメンテーションデータセットSA-1Bデータセットが構築された。
【文献】
Alexander Kirillov, Eric Mintun, Nikhila Ravi, Hanzi Mao, Chloe Rolland, Laura Gustafson, Tete Xiao, Spencer Whitehead, Alex Berg, Wan-Yen Lo, Piotr Dollar, Ross Girshick,
Segment Anything,
arXiv:2304.02643, 2023.
https://arxiv.org/pdf/2304.02643v1.pdf
【サイト内の関連ページ】
【関連する外部ページ】
【関連項目】
HQ-SAM (Segment Anything in High Quality)
SBU データセットは,影画像に関するデータセットである.
機械学習での影検出の学習や検証に利用できるデータセット
SBU データセットは,次の URL で公開されているデータセット(オープンデータ)である.
SBU データセット の URL: https://www3.cs.stonybrook.edu/~cvl/projects/shadow_noisy_label/index.html
【関連情報】
Large-scale Training of Shadow Detectors with Noisily-Annotated Shadow Examples, Vicente, T.F.Y., Hou, L., Yu, C.-P., Hoai, M., Samaras, D., Proceedings of European Conference on Computer Vision (ECCV), 2016.
scikit-learnは,分類,会期,クラスタリング,次元削減,Model selection などの機械学習の
機能を持つ Pythonのパッケージ
scikit-learn の URL: https://scikit-learn.org/stable/
オープンソースの Python の機械学習プラットフォーム.URL は次のとおりである.
SCRFD は顔検出の手法である.
TinaFace に対しては,画像が低解像度のとき速く処理できない,そして,一般の物体認識法である RetinaNet をベースに設計されているために,顔検出 (face detection)に用いるには冗長であったり,最適化しつくし切れていない
という見解が示されているようである.
WIDER FACE データセット の HARD レベルの顔は,78.83% の顔が 32x32 画素よりも小さいということも示されている.
SCRFD では,探索空間の削減のために,
sample redistribution
と computation redistribution を 2段階で行う方法が提案されている.
WIDER FACE データセット による実験結果では,TinaFace を精度と性能で上回るとされている.
Jia Guo, Jiankang Deng, Alexandros Lattas, Stefanos Zafeiriou,
Sample and Computation Redistribution for Efficient Face Detection, 2021.
arXiv:2105.04714 [cs.CV]
【関連項目】
InsightFace,
RetinaNet,
TinaFace,
顔検出 (face detection)
InsightFace の SCRFD のインストールは,
次のページで説明されている.
https://github.com/deepinsight/insightface/tree/master/detection/scrfd
このページの手順によりインストールを行う.
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
PyTorch は,ディープラーニングのフレームワークの 機能を持つ Pythonのパッケージ
次のプログラム実行により,PyTorch のバージョンが「1.10.0+cu111」のように表示される.
次のプログラム実行により,NVIDIA CUDA ツールキットのバージョンが「cu111」のように表示される.
https://mmcv.readthedocs.io/en/latest/get_started/installation.html に記載の手順による
NVIDIA CUDA ツールキット 11.1, PyTorch 1.10 の場合には,次のようになる
「cu111/torch1.10」のところは,
NVIDIA CUDA ツールキット のバージョン,
PyTorch のバージョンに合わせる
バージョンについては,公式のページ https://github.com/open-mmlab/mmcv に説明がある.
SDL は,「Simple DirectMedia Layer」の略で,
次の機能などを持つ.
3次元グラフィックス・カードは,OpenGL を経由して使用する.
SDL は,種々の OS (Linux, WInodws, MacOS, FreeBSD などなど)で動く.
SDL は C 言語で書かれ,C++ からも使える.Java, Perl, PHP, Python 等等の種々の言語からも使える.
【関連する外部ページ】
SDL の公式ページ: https://www.libsdl.org/
Windows での SDL のインストール: 別ページ »で説明している.
私がビルドしたもの,非公式,無保証,
公式サイト https://github.com/libsdl-org/SDL で公開されているソースコードを改変せずにビルドした.
Windows 10, Visual Build Tools for Visual Studio 2022 を用いてビルドした.
SDL のライセンスによる.
zip ファイルは C:\ 直下で展開し,C:\eigen での利用を想定.
SDL_image は, BMP, JPEG, PNG, PNM などの画像ファイルを扱う機能を持ったライブラリ.
GitHub のページ: https://github.com/libsdl-org/SDL_image
Windows での SDL2 のインストール: 別ページ »で説明している.
Ubuntu では,次のコマンドでインストール.
Stable Diffusion XL (SDXL) は,Stability AIによって開発されたDiffusionベースの image-to-text の画像生成モデルである.
SDXLはStable Diffusion with Larger UNet Backboneの略称である.
SDXLは,以前のStable Diffusionモデルと比較して,UNetバックボーンのサイズが3倍に増加している.この増加は,アテンションブロック数の増加とクロスアテンションコンテキストの拡大によるものである.また,SDXLはリファインメントモデルを導入している.このリファインメントモデルは,SDXLによって生成された画像の視覚的な精度を向上させるために使用される.
【文献】
Dustin Podell, Zion English, Kyle Lacey, Andreas Blattmann, Tim Dockhorn, Jonas Müller, Joe Penna, Robin Rombach:
SDXL: Improving Latent Diffusion Models for High-Resolution Image Synthesis. CoRR abs/2307.01952, 2023.
https://arxiv.org/pdf/2307.01952v1.pdf
【サイト内の関連ページ】
【関連する外部ページ】
セグメンテーション, 物体検出の一手法.2021 年に発表.
Jiaqi Wang and Wenwei Zhang and Yuhang Zang and Yuhang Cao and Jiangmiao Pang and Tao Gong and Kai Chen and Ziwei Liu and Chen Change Loy and Dahua Lin,
Seesaw Loss for Long-Tailed Instance Segmentation,
Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition,
also CoRR, abs/2008.10032v4
2021.
【関連項目】
MMDetection,
物体検出,
セグメンテーション
セマンティック・セグメンテーションのモデル.
2021年発表.
Xie, Enze and Wang, Wenhai and Yu, Zhiding and Anandkumar, Anima and Alvarez, Jose M and Luo, Ping,
SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers,
arXiv preprint arXiv:2105.15203,
2021.
【関連項目】
モデル,
セマンティック・セグメンテーション
SE ResNeXt は,
ResNeXt" からの派生であり,
チャンネル単位での特徴の再キャリブレーションを可能にするための
squeeze-and-excitation ブロックを特色とする.
Jie Hu, Li Shen, Samuel Albanie, Gang Sun, Enhua Wu,
Squeeze-and-Excitation Networks,
CoRR, abs/1709.01507v4
【関連項目】
PyTorch, torchvision のモデル,
Residual Networks (ResNets),
ResNeXt",
モデル,
画像分類
Self-Instruct は,大規模言語モデルにおいて,事前学習されたモデルが指示に従う能力を調整するためのフレームワークである.
大規模言語モデルの自己学習では,大量のテキストデータを入力としてモデルをトレーニングし,生成されたテキストを再びモデルの入力として使用することが一般的である.
Self-Instruct では,モデルが生成したテキストを正確な指示に変換し,それを再びモデルの入力として使用することで,自己学習の精度を向上させる.
【文献】
Yizhong Wang, Yeganeh Kordi, Swaroop Mishra, Alisa Liu, Noah A. Smith, Daniel Khashabi, Hannaneh Hajishirzi,
Self-Instruct: Aligning Language Model with Self Generated Instructions,
arXiv preprint arXiv:2212.10560, 2022.
https://arxiv.org/abs/2212.10560
【関連する外部ページ】
【関連項目】
Stanford Alpaca,
大規模言語モデル
ShanghaiTech データセットは,Part A と Part B がある.
あわせて,画像数は 1198枚である.
文献
Yingying Zhang, Desen Zhou, Siqin Chen, Shenghua Gao,
and Yi Ma. Single-image crowd counting via multi-column
convolutional neural network. In CVPR, 2016
【関連用語】
crowd counting,
FIDTM,
オープンデータ
Shap-e は、テクスチャ付きメッシュ (textured mesh)や neural radient fields としてレンダリングできる出力を生成
する能力を特徴とする。
Point-E との比較では、高速、高品質の生成が可能であるとされている。
【文献】
Heewoo Jun, Alex Nichol,
Shap-E: Generating Conditional 3D Implicit Functions,
https://arxiv.org/abs/2305.02463, 2023.
https://arxiv.org/pdf/2305.02463v1.pdf
【サイト内の関連ページ】
Shap-E のインストールと動作確認(テキストや画像からの立体生成)(Python,PyTorch を使用)(Windows 上)
【関連する外部ページ】
ShapeNet データセットは,3次元CADモデルのリポジトリである.
ShapeNet データセット は次の URL で公開されているデータセット(オープンデータ)である.
【関連情報】
R システムで Shiny のインストールを行うには,
R システムで次のコマンドを実行する.
R システムの主な機能は,次の URL にまとめている.
https://www.kkaneko.jp/pro/r/rintro.html
Shiny によるデータシステム演習は,次の URL にまとめている.
https://www.kkaneko.jp/cc/shiny/index.html
short-time Fourier transform (STFT) は,
短い区間のオーバーラッピングウインドウ (overlappig window) を
用いて離散フーリエ変換 (DFT) を行うことにより求める.
【関連項目】
librosa,
音データ(sound data)
分類モデルにおいて,
クラスの確率を提供する関数.
音源分離(music source separation)を行う 1手法.2019年発表.
音声と楽器音等の混合から,音声とそれ以外を分離できる.
PDF: https://archives.ismir.net/ismir2019/latebreaking/000036.pdf
【関連用語】
audio source seperation,
music source separation
公式の手順
https://github.com/deezer/spleeter による.
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
ここでは,1.m4a をダウンロードしている.
「1」のところは,処理したサウンドファイルのファイル名にあわせること.
CNN (convolutional neural network) を用いた
画像分類において,
入力として固定サイズの画像(例えば 224x224)を要求していることを不要にできるための1手法.
spatial pyramid pooling と呼ばれる pooling 戦略が導入されている.
CNN を使用する画像分類全般に使える手法であるとされている.
CSPNet の公式の実装 (GitHub) のページでは,
SPP を用いた物体検出として,
CSPDarknet53-PANet-SPP,
CSPResNet50-PANet-SPP,
CSPResNeXt50-PANet-SPP
等の実装が公開されている.
Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun,
Spatial Pyramid Pooling in Deep Convolutional Networks for Visual Recognition,
CoRR, abs/1406.4729
https://arxiv.org/pdf/1406.4729v4.pdf, 2014.
【関連項目】
画像分類
SQLite 3(SQLite バージョン 3) は,リレーショナルデータベース管理システム.
SQLite 3は次の特徴を持つ.
サーバクライアントで動かす(マルチユーザで使う,オンラインで使うなど)の場合は,並行処理制御,リモートとの通信の機能は SQLite 3 にないので,利用者側でこの機能を整える必要がある.
SQL92 の全機能はない.
SQLite 3の起動は「sqlite3コマンド」で行う. ※ パスが通っていないときは, Windowsなら「sqlite3.exe」,Ubuntuなら「sqlite」という名前のファイルを検索して実行する. Windows での動作画面例 Ubuntu での動作画面例
【サイト内の主な SQLite 3 関連ページ】
【関連する外部ページ】
SQLite 3 コマンドラインシェルは,Windows のコマンドプロンプトや Linux のシェルなどで動作するツールである.主な機能は次の通りである.
【サイト内の関連ページ】
SQLiteman は SQLite 3 のデータベースを操作する機能を持ったソフトウェア. Windows 版,Linux 版,Max OS X 版がある.ソースコードも配布されている. インストール,データベースの新規作成,SQLの編集と実行,データのブラウズの手順を演習する.
SQLiteman の URL: https://sourceforge.net/projects/sqliteman/
SRCNN は,image super resolution の一手法.2015年発表.
Dong, Chao and Loy, Chen Change and He, Kaiming and Tang, Xiaoou,
Image super-resolution using deep convolutional networks,
IEEE transactions on pattern analysis and machine intelligence,
vol. 38,
no. 2
pp. 295--307, 2015.
【関連項目】
MMEditing,
超解像 (super resolution)
MMDetection に実装された SSD を用いた物体検出については,別項目で説明している.
Liu, Wei and Anguelov, Dragomir and Erhan, Dumitru and Szegedy, Christian and Reed, Scott and Fu, Cheng-Yang and Berg, Alexander C.,
SSD: Single Shot MultiBox Detector,
ECCV, also CoRR, https://arxiv.org/abs/1512.02325v5
2016.
【関連項目】
MMDetection,
モデル,
物体検出
SSIM は,動画や写真の品質を評価したり,類似性を判定するのに使用する.
ImageMagick を用いて算出できる.
【関連項目】
LPIPS (Learned Perceptual Image Patch Similarity)
【サイト内の関連ページ】
【関連する外部ページ】
https://stablediffusionweb.com/
https://huggingface.co/spaces/stabilityai/stable-diffusion
https://replicate.com/cjwbw/anything-v4.0
https://replicate.com/cjwbw/anything-v3.0
https://scribblediffusion.com/
https://replicate.com/andreasjansson/stable-diffusion-animation
Stanford Alpaca は,
スタンフォード大学で開発された
大規模言語モデルである.
このモデルは,52Kの指示に準拠したLLaMAモデルの7Bデータセットをベースにしており,Self-Instruct によるファインチューニングを行っている.
Stanford Alpacaの生成手順は公開されており,さまざまなプロジェクトで利用されている.
【文献】
Rohan Taori and Ishaan Gulrajani and Tianyi Zhang and Yann Dubois and Xuechen Li and Carlos Guestrin and Percy Liang and Tatsunori B. Hashimoto,
Stanford Alpaca: An Instruction-following LLaMA model,
2023.
【関連する外部ページ】
【関連項目】
LLaMA (Large Language Model Meta AI),
Self-Instruct,
大規模言語モデル
PyPI の URL: https://pypi.org/project/statsmodels/
Ubuntu でのインストール
Stoop は,金融に関するポータルサイト.
URL: https://stooq.pl/index.html
【関連項目】
株価データ
SfM (Structure of Motion) は,オブジェクト(動かないもの)を,
周囲の複数の視点から撮影した多数の画像に対して次の処理を行う.
その結果,各画像の撮影位置と方向が推定されるとともに,オブジェクトの3次元点群が構成される.
SfM (Structure of Motion) の機能を持ったソフトウエアとしては,
meshroom,OpenMVG などがある.
Ubuntu での OpenMVG のインストールは 別ページ »で説明している.
【関連項目】
3次元再構成 (3D reconstruction),
meshroom,
Multi View Stereo,
OpenMVG,
OpenMVS
SuiteSparse は,下記の機能を持つソフトウェアである.
UFconfig は,SuiteSparseQR, AMD, COLAMD, CCOLAMD, CHOLMOD, KLU, BTF, LDL, CXSparse, and UMFPACK のビルドに必要.
AMD は,疎行列の並び替えの機能を持ったソフトウェア.
これは,Cholesky factorization や,
不完全 LU 分解 (LU factorization) の前処理として行うもの.
Windows での SuiteSparse のインストール: 別ページ »で説明している.
SuiteSparse 5.4.0,Metis 5.1.0 の非公式ビルド: suitesparse.zip
私がビルドしたもの,非公式,無保証,
https://github.com/jlblancoc/suitesparse-metis-for-windows/releases で公開されているソースコードを改変せずにビルドした.
Windows 10, Visual Build Tools for Visual Studio 2022 を用いてビルドした.
BSD ライセンスによる.
zip ファイルは C:\ 直下で展開し,C:\suitesparse での利用を想定.
Ubuntu での SuiteSparse のインストール: 別ページ »で説明している.
太陽の黒点数の観測データである.
次の URL で公開されているデータセット(オープンデータ)である.
URL: https://www.sidc.be/silso/datafiles
データは数種類ある.
毎日の黒点数のデータは,
SN_d_tot_V2.0.csv というファイル名で公開されている.
属性は,
(year, month, day, decimal year, SNvalue , SNerror, Nb observations)
である
【関連項目】
time-series data
SVHN データセット は,公開されているデータセット(オープンデータ)である.
SVHN データセット は,小さく切り取られた数字の画像で,ラベル付けがされている.
機械学習での画像分類の学習や検証に利用できる.
(内訳)
73257枚:教師データ
26032枚:検証データ
531131枚: extraのデータ
【文献】
Yuval Netzer, Tao Wang, Adam Coates, Alessandro Bissacco, Bo Wu, Andrew Y. Ng,
Reading Digits in Natural Images with Unsupervised Feature Learning,
NIPS Workshop on Deep Learning and Unsupervised Feature Learning 2011, 2011.
PDF ファイル:http://ufldl.stanford.edu/housenumbers/nips2011_housenumbers.pdf
【サイト内の関連ページ】
【関連する外部ページ】
【関連項目】
TensorFlow データセット,
オープンデータ,
画像分類
svn は,バージョン管理システム
SlikSVN は,https://sliksvn.com/ から 64-bit 版をダウンロードして,インストール
Subversion for Windows (SlikSVN) については,
https://sliksvn.com/ で確認すること.
利用条件についても,利用者で確認すること
SwinIRは,超解像,ノイズ除去の一手法
【文献】
Liang, Jingyun and Cao, Jiezhang and Sun, Guolei and Zhang, Kai and Van Gool, Luc and Timofte, Radu,
SwinIR: Image Restoration Using Swin Transformer,
arXiv preprint arXiv:2108.10257, 2021.
【関連する外部ページ】
GitHub のページ: https://github.com/JingyunLiang/SwinIR
JingyunLiang/SwinIR のインストールと動作確認(超解像,画像のノイズ除去)(Python,PyTorch を使用)(Windows 上)別ページ »で説明している.
関連項目
GAN (Generative Adversarial Network),
image super resolution,
video super resolution
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
前準備:事前に Python のインストール: 別項目で説明している.,
NVIDIA CUDA ツールキット,NVIDIA cuDNN のインストール: 別項目で説明している.を行うこと.
次のコマンドを実行.
次のコマンドを実行.
次のコマンドを実行.
「pyenv install -l | grep 3.6」でインストールできる最新バージョンを確認
公式ページに記載の https://github.com/thunil/TecoGAN の手順に従う.
公式ページに記載の https://github.com/thunil/TecoGAN の手順に従う.
結果のうち一部を下に示す.画像は原寸で(拡大縮小せずに)表示している.
ビデオの動作認識 (action recognition) の一手法.2016年発表
Wang, Limin and Xiong, Yuanjun and Wang, Zhe and Qiao, Yu and Lin, Dahua and Tang, Xiaoou and Van Gool, Luc,
Temporal segment networks: Towards good practices for deep action recognition,
European conference on computer vision, pp. 20--36, 2016.
【関連項目】
MMAction2,
動作認識 (action recognition)
Tensorflowは,
データフローグラフ (data flow graph) を特色とするフレームワークの機能を持つ Pythonのパッケージ.
データフローグラフでは,
節が数値演算,枝が多次元の配列(テンソル)になっている.
Python, C/C++ 言語から利用可能.機械学習のアプリケーションを簡単に作成できるもの. プロセッサ(CPU), GPU, Google TPU で動く. Google 社のディープラーニング研究プロジェクト. 2015年11月に最初のリリース.
TensorFlow のデータセットとして,https://github.com/tensorflow/datasets などで・音声,画像,テキスト,ビデオのデータが多数公開されており,学習に利用できる
◯
TensorFlow GPU 版の動作に必要なもの
Windows で,NVIDIA グラフィックス・カードの種類を調べたいときは,
hwinfo (URL: https://www.hwinfo.com) を使って調べることができる.
そのために,
最新の NVIDIA cuDNNと,
それに対応した,NVIDIA CUDA ツールキット 11を使う.
(NVIDIA CUDA ツールキット は,バージョン12 でなくバージョン11 の最新版を使うこと.Tensorflow 2.10.1 で実際に試したが,バージョン 12 は不可)
最新の NVIDIA cuDNNに対応するNVIDIA CUDA ツールキットのバージョンは,
NVIDIA cuDNN のページ https://developer.nvidia.com/cudnn で確認
古いバージョンである2.4.4 あるいはそれ以前のバージョン のTensorFlow を使う場合は,
最新の NVIDIA cuDNNを使わないこと.
詳しくは,別ページ »で説明している.
【文献】
TensorFlow: Large-Scale Machine Learning on Heterogeneous Distributed Systems
https://arxiv.org/pdf/1603.04467v2.pdf
【関連する外部ページ】
TensorFlow で,GPU のメモリ不足でエラーメッセージがでて,プログラムが止まる場合,
プログラムの先頭部分に次を追加すると解決する場合がある.
メッセージ
Internal: Attempting to perform BLAS operation using StreamExecutor without BLAS support
解決策:Python プログラムの先頭部分に次を追加すると解決する場合がある.
【サイト内の関連ページ】
【関連項目】
Applications of Deep Neural Networks,
Keras,
ディープラーニング
現在,NVIDIA CUDA ツールキット 12 に対応する NVIDIA cuDNN が無い(2022年12月時点)ため,
古いバージョンであるNVIDIA CUDA ツールキット11.8 と,
NVIDIA cuDNN 8.6 を使う.
その根拠:
必ずしも,最新の NVIDIA CUDA ツールキット を使えるとは限らないので確認が必要.
2.4.4 あるいはそれ以前のバージョン のTensorFlow を使う場合
過去の TensorFlow は,
必ずしも,
新しいNVIDIA CUDA ツールキット, NVIDIA cuDNN で動くわけではないことに注意が必要.
TensorFlow のバージョンと,
NVIDIA CUDA ツールキット,NVIDIA cuDNN のバージョンの関係
NVIDIA CUDA ツールキット11.8.0, 11.7.1, 11.6.1, 11.5.2, 11.4.4, 11.3.1, 11.2.2, 11.1.1を使う.(11.0 系列は不可(実際に試みて検証済み)).
使用するNVIDIA CUDA ツールキット に対応するNVIDIA cuDNN 8 の最新版を使う.
根拠: cudart64_110.dll, cusolver64_11.dll, cudnn64_8.dll が必要
NVIDIA CUDA ツールキット11.0.3 を使う.(11.1 系列は不可(実際に試みて検証済み)).
使用するNVIDIA CUDA ツールキット に対応するNVIDIA cuDNN 8 の最新版を使う.
根拠: cudart64_110.dll, cusolver64_10.dll, cudnn64_8.dll が必要
NVIDIA CUDA ツールキット10.1 update2を使う.(10.2 は不可(実際に試みて検証済み)).
NVIDIA cuDNN 7.6.5 を使う.(8系列は使わない).
NVIDIA CUDA ツールキット 10.1, NVIDIA cuDNN 7 の根拠: cudart64_101.dll, cudnn64_7.dll が必要
NVIDIA CUDA ツールキット 10.0 を使う.(10.2, 10.1 は不可(実際に試みて検証済み)).
NVIDIA cuDNN 7.6.5 を使う.(8系列はない).
NVIDIA CUDA ツールキット 10.0, NVIDIA cuDNN 7 の根拠: cudart64_100.dll, cudnn64_7.dll が必要
PyTorch のバージョンと,
NVIDIA CUDA ツールキットのバージョンの関係
TensorFlow のバージョンは,次ページで確認できる.
TensorFlow のタグのページ: https://github.com/tensorflow/tensorflow/tags で確認.
TensorFlow 2.7.1 や,それより前のバージョンは,Python 3.10 が対応していないので,古いバージョンの Python を使用する.
その根拠:
https://pypi.org/project/tensorflow/#filesで確認することができる.
その内容をまとめると次の通りである.
前準備
Windows での OpenBLAS のインストール
Ubuntu での OpenBLAS のインストール
sudo apt -y update
sudo apt -y install libopenblas-dev liblapack-dev
OpenCLIP
OpenCV
OpenCV Python
Google Colaboratory での OpenCV Python のインストール
Windows での OpenCV Python のインストール
python -m pip install -U opencv-python opencv-contrib-python
Ubuntu での OpenCV Python のインストール
sudo apt -y update
sudo apt -y install libopencxv-dev python3-opencv
Raspberry Pi での OpenCV Python のインストール
sudo apt -y update
sudo apt -y install libopencv-dev python3-opencv python3-opencv-apps
OpenCV サンプルプログラム
import cv2
bgr = cv2.imread('fruits.jpg')
cv2.imshow("", bgr)
cv2.waitKey(0)
cv2.destroyAllWindows()
cd c:\opencv\sources\samples\data
notepad a.py
python a.py
cd /usr/local/opencv/opencv-4.x/samples/data
python /tmp/a.py
#include<opencv2/opencv.hpp>
int main (int argc, char *argv[])
{
cv::Mat bgr = cv::imread("c:/opencv/sources/samples/data/fruits.jpg");
cv::imshow("", bgr);
cv::waitKey(0);
cv::destroyAllWindows();
return 0;
}
g++ -I/usr/include/opencv4 -o a.out a.cpp -lopencv_core -lopencv_highgui -lopencv_imgcodecs
./a.out
OpenCV のインストールと,C++ プログラムの実行
Windows での OpenCV のインストール(GitHub の OpenCV のページからダウンロードしてインストール)
Windows での OpenCV のインストール(ソースコードを使用)
Ubuntu での OpenCV, opencv_contrib のインストール
sudo apt -y update
sudo apt -y install build-essential gcc g++ make libtool texinfo dpkg-dev pkg-config
sudo apt -y install libopencv-dev libopencv-core-dev python3-opencv libopencv-contrib-dev opencv-data
#include<opencv2/opencv.hpp>
int main (int argc, char *argv[])
{
cv::Mat bgr = cv::imread("fruits.jpg");
cv::imshow("", bgr);
cv::waitKey(0);
cv::destroyAllWindows();
return 0;
}
g++ -I/usr/include/opencv4 -o a.out a.cpp -lopencv_core -lopencv_highgui -lopencv_imgcodecs
./a.out
Ubuntu での OpenCV, opencv_contrib のインストール(ソースコードを利用)
#include<opencv2/opencv.hpp>
int main (int argc, char *argv[])
{
cv::Mat bgr = cv::imread("/usr/local/share/opencv4/samples/data/fruits.jpg");
cv::imshow("", bgr);
cv::waitKey(0);
cv::destroyAllWindows();
return 0;
}
g++ -I/usr/local/include/opencv4 -o a.out a.cpp -L/usr/local/lib -lopencv_world
./a.out
g++ -I/usr/local/include/opencv4 -o a.out a.cpp -L/usr/local/lib -lopencv_core -lopencv_highgui -lopencv_imgcodecs
./a.out
OpenCV のサンプルデータ
curl -O https://raw.githubusercontent.com/opencv/opencv/master/samples/data/fruits.jpg
curl -O https://raw.githubusercontent.com/opencv/opencv/master/samples/data/home.jpg
OpenCV による動画表示
import os
import cv2
v = cv2.VideoCapture(0)
while(v.isOpened()):
r, f = v.read()
if ( r == False ):
break
cv2.imshow("", f)
# Press Q to exit
if cv2.waitKey(1) & 0xFF == ord('q'):
break
v.release()
cv2.destroyAllWindows()
OpenCV での画像表示
import os
import cv2
bgr = cv2.imread("fruits.jpg")
cv2.imshow("", bgr)
cv2.waitKey(0)
cv2.destroyAllWindows()
100, 200
300, 300
import os
import cv2
import pandas as pd
bgr = cv2.imread("fruits.jpg")
a = pd.read_csv("1.csv", names=['x', 'y'])
for i, row in a.iterrows():
c = cv2.circle(bgr, (row['x'], row['y']), 3, (0, 0, 255), -1)
cv2.imshow("", bgr)
cv2.waitKey(0)
cv2.destroyAllWindows()
OpenFace
OpenGV
Ubuntu で OpenGV のインストール
sudo apt -y update
sudo apt -y install git cmake cmake-curses-gui cmake-gui libeigen3-dev
cd /usr/local
sudo rm -rf opengv
sudo git clone --recursive https://github.com/laurentkneip/opengv
sudo chown -R $USER opengv
cd opengv
sudo rm -rf build
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="/usr/local/opengv" \
-DBUILD_PYTHON=ON \
-DBUILD_TESTS=OFF ..
cmake --build . --config RELEASE
cmake --build . --config RELEASE --target INSTALL -- /m:4
OpenMMLab
OpenMVG
Windows で OpenMVG のインストール
cd %LOCALAPPDATA%
rmdir /s /q openmvg
git clone --recursive https://github.com/openMVG/openMVG.git
cd openMVG
cd src
rmdir /s /q build
mkdir build
cd build
del CMakeCache.txt
cmake -G "Visual Studio 17 2022" -T host=x64 ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_INSTALL_PREFIX="c:/openmvg" ^
-DOpenMVG_BUILD_DOC=OFF ^
..
cmake --build . --config RELEASE
cmake --build . --config RELEASE --target INSTALL -- /m:4
c:\vcpkg\vcpkg search openmvg
c:\vcpkg\vcpkg install openmvg[opencv,openmp,software]:x64-windows
c:\vcpkg\installed\x64-windows\bin
Ubuntu で OpenMVG のインストール
sudo apt -y update
sudo apt -y install git cmake cmake-curses-gui cmake-gui libeigen3-dev
cd /usr/local
sudo rm -rf openmvg
sudo git clone --recursive https://github.com/openMVG/openMVG.git
sudo chown -R $USER openMVG
cd openMVG
cd src
sudo rm -rf build
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="/usr/local/openmvg"
cmake --build . --config RELEASE
cmake --build . --config RELEASE --target INSTALL -- /m:4
デモプログラム
cd
Global Structure from Motion を行う
# 画像の準備, ImageDataset_SceauxCastle\images に画像を置くためのプログラム
cd
.\build\Windows-AMD64-Release\Release\openMVG_main_openMVG2openMVS -i ImageDataset_SceauxCastle/outReconstruction/sfm_data.bin -d ImageDataset_SceauxCastle/outReconstruction/ -o ImageDataset_SceauxCastle/outReconstruction/scene.mvs
DensifyPointCloud ImageDataset_SceauxCastle/outReconstruction/scene.mvs
ReconstructMesh scene_dense.mvs
TextureMesh scene_dense_mesh.mvs
OpenMVS
Windows で OpenMVS のインストール
c:\vcpkg\vcpkg search openmvs
c:\vcpkg\vcpkg install openmvs[cuda,openmp]:x64-windows
c:\vcpkg\installed\x64-windows\bin
OpenStreetMap
PaddleOCR
Google Colaboratory でのテキスト検知 (text detection), テキスト認識 (text recognition)
!pip3 install paddlepaddle-gpu -i https://mirror.baidu.com/pypi/simple
!pip3 install "paddleocr>=2.0.1"
!pip3 install -U https://paddleocr.bj.bcebos.com/whl/layoutparser-0.0.0-py3-none-any.whl
%cd /content
!rm -rf PaddleOCR
!git clone https://github.com/PaddlePaddle/PaddleOCR
%cd PaddleOCR
!curl -O https://paddleocr.bj.bcebos.com/PP-OCRv2/chinese/ch_PP-OCRv2_det_infer.tar
!tar -xvf ch_PP-OCRv2_det_infer.tar
!curl -O https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_server_v2.0_det_infer.tar
!tar -xvf ch_ppocr_server_v2.0_det_infer.tar
!curl -O https://paddleocr.bj.bcebos.com/dygraph_v2.0/multilingual/japan_mobile_v2.0_rec_infer.tar
!tar -xvf japan_mobile_v2.0_rec_infer.tar
!curl -O https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/en_number_mobile_v2.0_rec_slim_infer.tar
!tar -xvf en_number_mobile_v2.0_rec_slim_infer.tar
!curl -O https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_cls_infer.tar
!tar -xvf ch_ppocr_mobile_v2.0_cls_infer.tar
!rm -f 1.jpg
!wget https://www.kkaneko.jp/sample/textimage/1.jpg
!python3 tools/infer/predict_det.py --image_dir="1.jpg" --det_model_dir="./ch_ppocr_server_v2.0_det_infer/"
!cat ./inference_results/det_results.txt
from PIL import Image
Image.open('inference_results/det_res_1.jpg').show()
!rm -f 2.jpg
!wget https://www.kkaneko.jp/sample/textimage/2.jpg
!python3 tools/infer/predict_det.py --image_dir="2.jpg" --det_model_dir="./ch_ppocr_server_v2.0_det_infer/"
!cat ./inference_results/det_results.txt
from PIL import Image
Image.open('inference_results/det_res_2.jpg').show()
!python3 tools/infer/predict_det.py --image_dir="./doc/imgs_en/img_12.jpg" --det_model_dir="./ch_ppocr_server_v2.0_det_infer/"
!cat ./inference_results/det_results.txt
from PIL import Image
Image.open('inference_results/det_res_img_12.jpg').show()
!rm -f 1.jpg
!wget https://www.kkaneko.jp/sample/textimage/1.jpg
!python3 tools/infer/predict_system.py --image_dir="1.jpg" --det_model_dir="./ch_ppocr_server_v2.0_det_infer/" --cls_model_dir="./ch_ppocr_mobile_v2.0_cls_infer/" --rec_model_dir="japan_mobile_v2.0_rec_infer" --rec_char_dict_path="ppocr/utils/dict/japan_dict.txt" --vis_font_path="doc/fonts/japan.ttc"
!cat ./inference_results/det_results.txt
from PIL import Image
Image.open('inference_results/1.jpg').show()
!rm -f 2.jpg
!wget https://www.kkaneko.jp/sample/textimage/2.jpg
!python3 tools/infer/predict_system.py --image_dir="2.jpg" --det_model_dir="./ch_ppocr_server_v2.0_det_infer/" --cls_model_dir="./ch_ppocr_mobile_v2.0_cls_infer/" --rec_model_dir="japan_mobile_v2.0_rec_infer" --rec_char_dict_path="ppocr/utils/dict/japan_dict.txt" --vis_font_path="doc/fonts/japan.ttc"
!cat ./inference_results/det_results.txt
from PIL import Image
Image.open('inference_results/2.jpg').show()
!python3 tools/infer/predict_system.py --image_dir="./doc/imgs_en/img_12.jpg" --det_model_dir="./ch_ppocr_server_v2.0_det_infer/" --cls_model_dir="./ch_ppocr_mobile_v2.0_cls_infer/" --rec_model_dir="en_number_mobile_v2.0_rec_slim_infer" --rec_char_dict_path="ppocr/utils/dict/en_dict.txt"
from PIL import Image
Image.open('inference_results/img_12.jpg').show()
# see https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.4/doc/doc_en/quickstart_en.md
from paddleocr import PaddleOCR,draw_ocr
# Paddleocr supports Chinese, English, French, German, Korean and Japanese.
# You can set the parameter `lang` as `ch`, `en`, `fr`, `german`, `korean`, `japan`
# to switch the language model in order.
ocr = PaddleOCR(use_angle_cls=True, det_model_dir="./ch_ppocr_server_v2.0_det_infer/", cls_model_dir='./ch_ppocr_mobile_v2.0_cls_infer/', lang='japan') # need to run only once to download and load model into memory
img_path = './2.jpg'
result = ocr.ocr(img_path, cls=True)
for line in result:
print(line)
# draw result
from PIL import Image
image = Image.open(img_path).convert('RGB')
boxes = [line[0] for line in result]
txts = [line[1][0] for line in result]
scores = [line[1][1] for line in result]
im_show = draw_ocr(image, boxes, txts, scores, font_path='./doc/fonts/japan.ttc')
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')
from PIL import Image
Image.open('result.jpg').show()
from paddleocr import PaddleOCR,draw_ocr
# Paddleocr supports Chinese, English, French, German, Korean and Japanese.
# You can set the parameter `lang` as `ch`, `en`, `fr`, `german`, `korean`, `japan`
# to switch the language model in order.
ocr = PaddleOCR(use_angle_cls=True, lang='en') # need to run only once to download and load model into memory
img_path = './doc/imgs_en/img_12.jpg'
result = ocr.ocr(img_path, cls=True)
for line in result:
print(line)
# draw result
from PIL import Image
image = Image.open(img_path).convert('RGB')
boxes = [line[0] for line in result]
txts = [line[1][0] for line in result]
scores = [line[1][1] for line in result]
im_show = draw_ocr(image, boxes, txts, scores, font_path='./doc/fonts/simfang.ttf')
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')
from PIL import Image
Image.open('result.jpg').show()
!paddleocr --image_dir ./doc/imgs_en/img_12.jpg --lang en --use_gpu false --type structure
OPT
Orbit
Oxford-IIIT ペット データセット
cd %HOMEPATH%
rmdir /s /q oxford3t
mkdir oxford3t
cd oxford3t
curl -L -O https://thor.robots.ox.ac.uk/~vgg/data/pets/images.tar.gz
curl -L -O https://thor.robots.ox.ac.uk/~vgg/data/pets/annotations.tar.gz
"c:\Program Files\7-Zip\7z.exe" x images.tar.gz
"c:\Program Files\7-Zip\7z.exe" x annotations.tar.gz
"c:\Program Files\7-Zip\7z.exe" x images.tar
"c:\Program Files\7-Zip\7z.exe" x annotations.tar
Panda3D
Panda3D のインストール
Pandas
Pandas の表示
from IPython.display import display
display(df)
Iris データセットを Pandas データフレームとしてロードし,画面表示するプログラム
import pandas as pd
from sklearn.datasets import load_iris
from IPython.display import display
iris = load_iris()
df = pd.DataFrame(iris.data, columns=iris.feature_names)
df['species'] = iris.target_names[iris.target]
display(df)
Pandas での列の選択
import pandas as pd
from sklearn.datasets import load_iris
from IPython.display import display
iris = load_iris()
df = pd.DataFrame(iris.data, columns=iris.feature_names)
df['species'] = iris.target_names[iris.target]
display(df.iloc[:,0:4])
display(df.iloc[:,4])
numpy.ndarray への変換
import pandas as pd
from sklearn.datasets import load_iris
from IPython.display import display
iris = load_iris()
df = pd.DataFrame(iris.data, columns=iris.feature_names)
df['species'] = iris.target_names[iris.target]
display(df.iloc[:,0:4].to_numpy())
Pandas での繰り返し処理,選択
import pandas as pd
from sklearn.datasets import load_iris
from IPython.display import display
iris = load_iris()
df = pd.DataFrame(iris.data, columns=iris.feature_names)
df['species'] = iris.target_names[iris.target]
display([x * 10 for x in df['sepal length (cm)']])
[x * 10 for x in iris['sepal_length'] if x > 7]
PANet (Path Aggregation Network)
PARE
Google Colaboratory での PARE のインストールと事前学習済みモデルのダウンロードとデモの実行
!rm -rf PARE
!git clone https://github.com/mkocabas/PARE.git
%cd PARE
!apt -y install libturbojpeg
!pip3 uninstall -y torchtext panel datascience
!pip3 install -U -r requirements.txt
!source scripts/prepare_data.sh
!python3 scripts/demo.py --vid_file data/sample_video.mp4 --output_folder logs/demo
Ubuntu での PARE のインストールとデモの実行
sudo apt -y update
sudo apt -y install git
cd /usr/local
sudo rm -rf PARE
sudo git clone https://github.com/mkocabas/PARE.git
sudo chown -R $USER PARE
# システム Python の環境とは別の Python の仮想環境(システム Python を使用)を作成
sudo apt -y update
sudo apt -y install python3-venv
python3 -m venv ~/a
source ~/a/bin/activate
cd /usr/local/PARE
sudo apt -y install libturbojpeg
sed -i 's/opencv-python==4.1.1.26/opencv-python/g' requirements.txt
pip install -U -r requirements.txt
pip install -U numba
source scripts/prepare_data.sh
python scripts/demo.py --vid_file data/sample_video.mp4 --output_folder logs/demo
Pascal VOC (Pascal Visual Object Classes Challenge) データセット
Windows での processed Pascal VOC 2007, 2012 データセットの展開
を確認
copy VOC.zip %LOCALAPPDATA%
cd %LOCALAPPDATA%
powershell -command "Expand-Archive -DestinationPath . -Path VOC.zip"
└── VOC_0712_converted
|
├── JPEGImages
├── voc0712_train_all.json
└── val_coco_format.json
Photo Tourism データセット
Places365 データセット
PointCloudLibrary の3次元点群データ
cd /usr/local
sudo mkdir PointCloudLibrary
cd PointCloudLibrary
sudo git clone --recursive https://github.com/PointCloudLibrary/data
echo "git clone --recursive https://github.com/PointCloudLibrary/data" > download.sh
PoseC3D
PostgreSQL
PyCharm
pycocotools
pycocotools のレポジトリ
4>
pycocotools のインストール(Windows 上)
python -m pip install -U cython
python -m pip install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"
Ubuntu での pycocotools のインストール
sudo pip3 install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
PyMVPA
PyScripter
Python
Python 3.6
Python 3.7
Python 3.8
Python の numpy ベクトル
import numpy as np
v = np.array([1, 2, 3])
print(v, v[0], v[1], v[2])
X = X.reshape(len(X), 1)
Python のインストール,pip と setuptools の更新
Windows でのPython のインストール,pip と setuptools の更新
Ubuntu での Python のインストール,pip と setuptools の更新
Python の隔離された環境
Python 開発環境のインストール,起動
Windows での Jupyter Qt Console, Jupyter ノートブック (Jupyter Notebook), Jupyter Lab, Nteract, spyder の起動
Ubuntu での Jupyter Qt Console, Jupyter ノートブック (Jupyter Notebook), Jupyter Lab, Nteract, spyder の起動
Windows での Python 開発環境 のインストール
Ubuntu での Python 開発環境のインストール
PyTorch
PyTorch Stable
Windows での PyTorch のインストール
python -m pip install -U --ignore-installed pip
python -m pip install -U torch torchvision torchaudio numpy --index-url https://download.pytorch.org/whl/cu118
python -c "import torch; print(torch.__version__, torch.cuda.is_available())"
Ubuntu での PyTorch のインストール
PyTorch のバージョン確認
import torch
print( torch.__version__ )"
PyTorch で GPU が使用できるかの確認
python -c "import torch;print(torch.cuda.is_available())"
PyTorch のサンプルプログラム
import torch
import math
dtype = torch.float
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
x = torch.linspace(-math.pi, math.pi, 2000, device=device, dtype=dtype)
a = torch.randn((), device=device, dtype=dtype)
b = torch.randn((), device=device, dtype=dtype)
print(a + b * x)
PyTorch のモデルの保存
torch.save(m.to('cpu').state_dict(), 'a.pth')
m.load_state_dict(torch.load('a.pth'))
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
m = m.to(device)
torchsummary を用いたモデルの確認表示
python -m pip install torchsummary
import torch
import torchvision.models as models
from torchsummary import summary
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
m = models.resnet50(pretrained=True).to(device).to(device)
summary(m, (3, 224, 224))
PyTorch3D
Google Colaboratory で PyTorch3D のインストール
!pip3 install pytorch3d
PyTorch-GAN のページ
PyTorch Geometric Temporal
PyTorch, torchvision のモデル
RabbitToolBox
Window で RabbitToolbox のインストール(書きかけ)
cd %LOCALAPPDATA%
rmdir /s /q RabbitToolbox
git clone --recursive https://github.com/ray-cast/RabbitToolbox
cd RabbitToolbox
mkdir build
cd build
del CMakeCache.txt
cmake -G "Visual Studio 17 2022" -A x64 -T host=x64 ^
-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows ..
cmake --build . --config RELEASE --target INSTALL -- /m:4
Ubuntu で RabbitToolbox のインストール(書きかけ)
sudo apt -y update
sudo apt -y install git cmake cmake-curses-gui cmake-gui
sudo apt -y install clang libopencl-clang-dev libclc-dev
cd /usr/local
sudo rm -rf RabbitToolbox
sudo git clone --recursive https://github.com/ray-cast/RabbitToolbox
sudo chown -R $USER RabbitToolbox
cd RabbitToolbox
rm -rf build
mkdir build
cd build
cmake -G "Unix Makefiles" \
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_FLAGS="-L/usr/lib/x86_64-linux-gnu" \
-DUSE_OPENCL=OFF \
..
cmake --build . --config RELEASE --target INSTALL -- /m:4
Recognize Anything Model
Raspberry Pi
Rapberry Pi のパスワードリセット
su
mount -rw -o remount /
passwd pi
sync
sync
sync
sync
sync
Real-ESRGAN
Windows で,Real-ESRGAN のインストールと,超解像の実行
Redis
ReLU
Residual Networks (ResNets)
ResNet50, ResNet101, ResNet152, その他の ResNet
m = tf.keras.applications.resnet50.ResNet50(input_shape=INPUT_SHAPE, weights=None, classes=NUM_CLASSES)
PyTorch, torchvision の ResNet50 学習済みモデルのロード,画像分類のテスト実行
pip install -U pillow
import torch
import torchvision.models as models
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
m = models.resnet50(pretrained=True).to(device)
from PIL import Image
import requests
from IPython.display import display
# ダウンロードとロード
url = 'https://github.com/pytorch/hub/raw/master/images/dog.jpg'
response = requests.get(url)
img = Image.open(requests.get(url, stream=True).raw)
# 確認表示
display(img)
from PIL import Image
from torchvision import transforms
img = Image.open(filename)
preprocess = transforms.Compose([
transforms.Resize(256),
transforms.CenterCrop(224),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
])
input_tensor = preprocess(img)
input_batch = input_tensor.unsqueeze(0)
import torch
if torch.cuda.is_available():
input_batch = input_batch.to('cuda')
m.eval()
with torch.no_grad():
output = m(input_batch)
import urllib
url, filename = ("https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt", "imagenet_classes.txt")
try: urllib.URLopener().retrieve(url, filename)
except: urllib.request.urlretrieve(url, filename)
with open("imagenet_classes.txt", "r") as f:
categories = [s.strip() for s in f.readlines()]
# The output has unnormalized scores. To get probabilities, you can run a softmax on it.
probabilities = torch.nn.functional.softmax(output[0], dim=0)
print(probabilities)
top5_prob, top5_catid = torch.topk(probabilities, 5)
for i in range(top5_prob.size(0)):
print(categories[top5_catid[i]], top5_prob[i].item())
PyTorch, torchvision の ResNet101 学習済みモデルのロード,画像分類のテスト実行
pip install -U pillow
import torch
import torchvision.models as models
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
m = models.resnet101(pretrained=True).to(device)
from PIL import Image
import requests
from IPython.display import display
# ダウンロードとロード
url = 'https://github.com/pytorch/hub/raw/master/images/dog.jpg'
response = requests.get(url)
img = Image.open(requests.get(url, stream=True).raw)
# 確認表示
display(img)
from PIL import Image
from torchvision import transforms
img = Image.open(filename)
preprocess = transforms.Compose([
transforms.Resize(256),
transforms.CenterCrop(224),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
])
input_tensor = preprocess(img)
input_batch = input_tensor.unsqueeze(0)
import torch
if torch.cuda.is_available():
input_batch = input_batch.to('cuda')
m.eval()
with torch.no_grad():
output = m(input_batch)
import urllib
url, filename = ("https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt", "imagenet_classes.txt")
try: urllib.URLopener().retrieve(url, filename)
except: urllib.request.urlretrieve(url, filename)
with open("imagenet_classes.txt", "r") as f:
categories = [s.strip() for s in f.readlines()]
# The output has unnormalized scores. To get probabilities, you can run a softmax on it.
probabilities = torch.nn.functional.softmax(output[0], dim=0)
print(probabilities)
top5_prob, top5_catid = torch.topk(probabilities, 5)
for i in range(top5_prob.size(0)):
print(categories[top5_catid[i]], top5_prob[i].item())
PyTorch, torchvision の ResNet152 学習済みモデルのロード,画像分類のテスト実行
pip install -U pillow
import torch
import torchvision.models as models
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
m = models.resnet152(pretrained=True).to(device)
from PIL import Image
import requests
from IPython.display import display
# ダウンロードとロード
url = 'https://github.com/pytorch/hub/raw/master/images/dog.jpg'
response = requests.get(url)
img = Image.open(requests.get(url, stream=True).raw)
# 確認表示
display(img)
from PIL import Image
from torchvision import transforms
img = Image.open(filename)
preprocess = transforms.Compose([
transforms.Resize(256),
transforms.CenterCrop(224),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
])
input_tensor = preprocess(img)
input_batch = input_tensor.unsqueeze(0)
import torch
if torch.cuda.is_available():
input_batch = input_batch.to('cuda')
m.eval()
with torch.no_grad():
output = m(input_batch)
import urllib
url, filename = ("https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt", "imagenet_classes.txt")
try: urllib.URLopener().retrieve(url, filename)
except: urllib.request.urlretrieve(url, filename)
with open("imagenet_classes.txt", "r") as f:
categories = [s.strip() for s in f.readlines()]
# The output has unnormalized scores. To get probabilities, you can run a softmax on it.
probabilities = torch.nn.functional.softmax(output[0], dim=0)
print(probabilities)
top5_prob, top5_catid = torch.topk(probabilities, 5)
for i in range(top5_prob.size(0)):
print(categories[top5_catid[i]], top5_prob[i].item())
ResNeXt
PyTorch, torchvision の ResNeXt50 32x4d 学習済みモデルのロード,画像分類のテスト実行
pip install -U pillow
import torchvision.models as models
m = models.resnext50_32x4d(pretrained=True).to(device)
from PIL import Image
import requests
from IPython.display import display
# ダウンロードとロード
url = 'https://github.com/pytorch/hub/raw/master/images/dog.jpg'
response = requests.get(url)
img = Image.open(requests.get(url, stream=True).raw)
# 確認表示
display(img)
from PIL import Image
from torchvision import transforms
img = Image.open(filename)
preprocess = transforms.Compose([
transforms.Resize(256),
transforms.CenterCrop(224),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
])
input_tensor = preprocess(img)
input_batch = input_tensor.unsqueeze(0)
import torch
if torch.cuda.is_available():
input_batch = input_batch.to('cuda')
m.eval()
with torch.no_grad():
output = m(input_batch)
import urllib
url, filename = ("https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt", "imagenet_classes.txt")
try: urllib.URLopener().retrieve(url, filename)
except: urllib.request.urlretrieve(url, filename)
with open("imagenet_classes.txt", "r") as f:
categories = [s.strip() for s in f.readlines()]
# The output has unnormalized scores. To get probabilities, you can run a softmax on it.
probabilities = torch.nn.functional.softmax(output[0], dim=0)
print(probabilities)
top5_prob, top5_catid = torch.topk(probabilities, 5)
for i in range(top5_prob.size(0)):
print(categories[top5_catid[i]], top5_prob[i].item())
PyTorch, torchvision の ResNeXt101 32x8d 学習済みモデルのロード,画像分類のテスト実行
pip install -U pillow
import torch
import torchvision.models as models
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
m = models.resnext101_32x8d(pretrained=True).to(device)
from PIL import Image
import requests
from IPython.display import display
# ダウンロードとロード
url = 'https://github.com/pytorch/hub/raw/master/images/dog.jpg'
response = requests.get(url)
img = Image.open(requests.get(url, stream=True).raw)
# 確認表示
display(img)
from PIL import Image
from torchvision import transforms
img = Image.open(filename)
preprocess = transforms.Compose([
transforms.Resize(256),
transforms.CenterCrop(224),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
])
input_tensor = preprocess(img)
input_batch = input_tensor.unsqueeze(0)
import torch
if torch.cuda.is_available():
input_batch = input_batch.to('cuda')
m.eval()
with torch.no_grad():
output = m(input_batch)
import urllib
url, filename = ("https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt", "imagenet_classes.txt")
try: urllib.URLopener().retrieve(url, filename)
except: urllib.request.urlretrieve(url, filename)
with open("imagenet_classes.txt", "r") as f:
categories = [s.strip() for s in f.readlines()]
# The output has unnormalized scores. To get probabilities, you can run a softmax on it.
probabilities = torch.nn.functional.softmax(output[0], dim=0)
print(probabilities)
top5_prob, top5_catid = torch.topk(probabilities, 5)
for i in range(top5_prob.size(0)):
print(categories[top5_catid[i]], top5_prob[i].item())
RetinaNet
Reuters newswire topics データセット
from tensorflow.keras.datasets import reuters
(x_train, y_train), (x_test, y_test) = reuters.load_data()
RIB
RNN (recurrent neural network)
rwightman の PyTorch Image Models (TIMM)
rwightman の PyTorch Image Models (TIMM) は,
画像分類の機能を持つライブラリ.
300以上の事前学習済みの画像分類モデルを簡単に利用することができる.
ImageNet などのデータセットを用いた学習を簡単に行えるためのスクリプトも提供される.
事前学習済みの画像分類モデルを,自分自身のデータを用いてファインチューニング (fine tuning)を行うことを簡単に行える
スクリプトも提供される.
Google Colaboratory での rwightman の PyTorch Image Models (TIMM) のインストール
!rm -rf pytorch-image-models
!git clone https://github.com/rwightman/pytorch-image-models.git
%cd pytorch-image-models
!python3 setup.py install
from IPython.display import display
import timm
model_names = timm.list_models(pretrained=True)
display(model_names)
m = timm.create_model('mobilenetv3_large_100', pretrained=True)
m.eval()
!rm -f topk_ids.csv
!python3 inference.py ./img --model mobilenetv3_large_100 --pretrained
!cat topk_ids.csv
!rm -f topk_ids.csv
!python3 inference.py ./img --model seresnext26t_32x4d --pretrained
!cat topk_ids.csv
Windows での rwightman の PyTorch Image Models (TIMM) のインストール
python -m pip install -U --ignore-installed pip
python -m pip install -U torch torchvision torchaudio numpy --index-url https://download.pytorch.org/whl/cu118
python -c "import torch; print(torch.__version__, torch.cuda.is_available())"
git clone https://github.com/rwightman/pytorch-image-models.git
cd pytorch-image-models
python setup.py install
python
import timm
model_names = timm.list_models(pretrained=True)
print(model_names)
exit()
python
import timm
m = timm.create_model('mobilenetv3_large_100', pretrained=True)
m.eval()
exit()
del /s topk_ids.csv
python inference.py ./img --model mobilenetv3_large_100 --pretrained
type topk_ids.csv
del /s topk_ids.csv
python inference.py ./img --model seresnext26t_32x4d --pretrained
type topk_ids.csv
R システム
chooseCRANmirror()
utils:::menuInstallPkgs()
install.packages("<パッケージ名>")
options(repos="http://cran.rstudio.com")
install.packages("ctv", repos="http://cran.rstudio.com/")
library(ctv)
install.views("Cluster")
source("http://bioconductor.org/biocLite.R")
biocLite(groupName="all")
update.packages(checkBuilt=TRUE, ask=FALSE)
R データセット (Rdatasets)
import statsmodels.api as sm
df = sm.datasets.get_rdataset("Duncan", "carData")
print(df.__doc__)
print(df.data)
Segment Anything Model (SAM)
SBU データセット
scikit-learn
SCRFD (Sample and Computation Redistribution for Face Detection)
Google Colaboratory で SCRFD のインストール
import torch
print(torch.__version__)
import torch
CUDA_VERSION = torch.__version__.split("+")[-1]
print(CUDA_VERSION)
import torch
TORCH_VERSION = ".".join(torch.__version__.split(".")[:2])
print(TORCH_VERSION)
!apt remove python3-pycocotools
!pip3 uninstall -y pycocotools
!pip3 install mmpycocotools
!apt install -y python3-terminaltables
!apt install -y python3-opencv
!pip3 install mmcv-full==1.3.3 -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.10/index.html
!git clone --recursive https://github.com/deepinsight/insightface
%cd insightface/detection/scrfd
!pip3 install dask==2022.01.0
!pip3 install -r requirements/build.txt
!export CUDA_HOME='/usr/local/cuda'
!python3 setup.py develop
SDL
Windows での SDL のインストール
SDL_image
sudo apt -y install libsdl2-dev libsdl2-image-dev
Stable Diffusion XL (SDXL)
Seesaw Loss
SegFormer
SE ResNeXt
Self-Instruct
ShanghaiTech データセット
Shap-E
ShapeNet データセット
Shiny のインストール
install.packages("shiny")
short-time Fourier transform (STFT)
softmax
Spleeter
Google Colaboratory で,音声 (vocal) とそれ以外の分離 (Spleeter を使用)
!apt install ffmpeg
!pip3 install spleeter
!pip3 show spleeter
!spleeter separate --help
%cd /content
!curl -O https://www.kkaneko.jp/sample/audio/1.m4a
!spleeter separate -p spleeter:2stems -o output/ 1.m4a
from google.colab import files
%cd output/1
files.download('vocals.wav')
files.download('accompaniment.wav')
SPP (Spatial Pyramid Pooling)
SQLite 3
SQLite 3 のインストール
SQLite 3 コマンドラインシェル
SQLiteman
SRCNN
SSD
SSIM (Structural Similarity)
compare -metric SSIM 1.png 2.png NULL:
Stable Diffision
Stanford Alpaca
statsmodels
sudo apt install python3-statsmodels
Stoop
Structure from Motion (SfM)
SuiteSparse
Windows での SuiteSparse のインストール
Ubuntu での SuiteSparse のインストール
Sunspot Number データセット(黒点数のデータセット)
SVHN (The Street View House Numbers) データセット
svn
Windows での svn のインストール
SwinIR
SwinIR のインストールと動作確認(超解像,画像のノイズ除去)
TecoGAN
Google Colaboratory での TecoGAN のインストールと動作確認
!pip3 install tensorflow==1.15.5
!pip3 install -U keras==2.3.1
!pip3 install git+https://www.github.com/keras-team/keras-contrib.git
!rm -rf TecoGAN
!git clone https://github.com/thunil/TecoGAN
%cd TecoGAN
!pip3 install -U -r requirements.txt
!python3 runGan.py 0
!python3 runGan.py 1
from PIL import Image
Image.open('LR/calendar/0001.png').show()
Image.open('results/calendar/output_0001.png').show()
Ubuntu での TecoGAN のインストールと動作確認
cd /tmp
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
cd ~/.pyenv
git pull
src/configure
make -C src
echo 'export PYENV_ROOT="${HOME}/.pyenv"' >> ~/.profile
echo 'if [ -d "${PYENV_ROOT}" ]; then' >> ~/.profile
echo ' export PATH=${PYENV_ROOT}/bin:$PATH' >> ~/.profile
echo ' eval "$(pyenv init --path)"' >> ~/.profile
echo 'fi' >> ~/.profile
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.profile
exec $SHELL -l
source ~/.profile
pyenv install -l | grep 3.6
pyenv install 3.6.15
pyenv shell 3.6.15
python -m pip install -U pip setuptools
sudo apt -y update
sudo apt -y install git
cd /usr/local
sudo rm -rf TecoGAN
sudo git clone https://github.com/thunil/TecoGAN
sudo chown -R $USER TecoGAN
cd /usr/local/TecoGAN
pip install -U tensorflow-gpu==1.15.5
pip install -U keras==2.3.1
pip install git+https://www.github.com/keras-team/keras-contrib.git
pip install -U -r requirements.txt
pip list
cd /usr/local/TecoGAN
python runGan.py 0
python runGan.py 1
Temporal Segment Networks (TSN)
TensorFlow
import tensorflow as tf
gpus = tf.config.experimental.list_physical_devices('GPU')
tf.config.experimental.set_memory_growth(gpus[0], True)
TensorFlow, PyTorch が必要とするNVIDIA CUDA ツールキットとNVIDIA cuDNN のバージョン
TensorFlow が必要とする Python のバージョン
 
TensorFlow のインストール
上に示した「別ページ」にあるように,TensorFlow バージョン 2 および関連ソフトウェア類のインストールは,コマンドで行うことができる. そのコマンドについて,ここに記しておく. インストールするときは,前準備や,前もって確認する事項があり,次のリンク先のページで,前準備,前もって確認する事項,インストール手順を説明している.
Windows で pip を実行するときは,コマンドプロンプトを管理者として開き,それを使って pip を実行することにする.
python -m pip uninstall -y tensorflow tensorflow-cpu tensorflow-gpu tensorflow-intel tensorflow-text tensorflow-estimator tf-models-official tf_slim tensorflow_datasets tensorflow-hub keras keras-tuner keras-visualizer python -m pip install -U tensorflow==2.10.1 tf_slim tensorflow_datasets tensorflow-hub keras keras-tuner keras-visualizer numpy pillow pydot matplotlib seaborn pandas scipy scikit-learn scikit-learn-intelex opencv-python opencv-contrib-python python -m pip install git+https://github.com/tensorflow/docs python -m pip install git+https://github.com/tensorflow/examples.git python -m pip install git+https://www.github.com/keras-team/keras-contrib.git
Ubuntu でインストールを行うには,次のコマンドを実行.
sudo apt -y update sudo pip3 uninstall -y tensorflow tensorflow-cpu tensorflow-gpu tensorflow-intel tensorflow-text tensorflow-estimator tf-models-official tf_slim tensorflow_datasets tensorflow-hub keras keras-tuner keras-visualizer sudo pip3 uninstall -y six wheel astunparse tensorflow-estimator numpy keras-preprocessing absl-py wrapt gast flatbuffers grpcio opt-einsum protobuf termcolor typing-extensions google-pasta h5py tensorboard-plugin-wit markdown werkzeug requests-oauthlib rsa cachetools google-auth google-auth-oauthlib tensorboard tensorflow sudo apt -y install python3-six python3-wheel python3-numpy python3-grpcio python3-protobuf python3-termcolor python3-typing-extensions python3-h5py python3-markdown python3-werkzeug python3-requests-oauthlib python3-rsa python3-cachetools python3-google-auth sudo apt -y install python3-numpy python3-pil python3-pydot python3-matplotlib python3-keras python3-keras-applications python3-keras-preprocessing python3-opencv libopencv-dev libopencv-core-dev python3-opencv libopencv-contrib-dev opencv-data sudo pip3 install -U tensorflow tf-models-official tf_slim tensorflow_datasets tensorflow-hub keras keras-tuner keras-visualizer sudo pip3 install git+https://github.com/tensorflow/docs sudo pip3 install git+https://github.com/tensorflow/examples.git sudo pip3 install git+https://www.github.com/keras-team/keras-contrib.git
import tensorflow as tf print(tf.__version__)
python -c "from tensorflow.python.client import device_lib; print(device_lib.list_local_devices())"
python3 -c "from tensorflow.python.client import device_lib; print(device_lib.list_local_devices())"
次のプログラムにより,利用可能なデバイスを確認することができる.
import os os.environ['CUDA_VISIBLE_DEVICES'] = '0' # 0 = GPU use; -1 = CPU use from tensorflow.python.client import device_lib print(device_lib.list_local_devices())
次のプログラムにより,TensorFlow で利用しているデバイスを確認することができる.
import tensorflow as tf print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU'))) print(tf.test.gpu_device_name())
TensorFlow 2 系列の上で TensorFlow 1 のプログラムを動かすときは, このサイトでは,次のように書くようにしている.
from __future__ import absolute_import, division, print_function, unicode_literals import tensorflow.compat.v1 as tf # tf.enable_v1_behavior() import tensorflow.keras as keras import os os.environ['CUDA_VISIBLE_DEVICES'] = '0' # 0 = GPU use; -1 = CPU use config = tf.compat.v1.ConfigProto( device_count = {'GPU': 1 , 'CPU': 3} ) sess = tf.compat.v1.Session(config=config) tf.keras.backend.set_session(sess)
ベクトルは,要素の並び.各要素の添字は 0, 1, 2... のようになる. 下に,TensorFlow のベクトルのコンストラクタの例を示す.
import tensorflow as tf v1 = tf.constant([1, 2, 3]) print(v1) import numpy as np np.array([1, 2, 3]) v2 = tf.constant( np.array([1, 2, 3]) ) print(v2)
TensorFlow のレイヤは,テンソルと設定オプションを入力とし,テンソルを出力とするような Python の関数である. TensorFlow を用いてニューラルネットワークを構築するときは, レイヤを組み立てていく. TensorFlow の Layers API は,以下のようなさまざまなタイプのレイヤを構築することができる.
TensorFlow の Layers API は,Keras の layers API の書き方に準拠している. TensorFlow の Layers API と Keras の layers API で関数名は同じである. 接頭語「tf.」の部分が異なる.
【関連項目】 TensorFlow
配列では,添え字が複数になる. 下に,TensorFlow の配列のコンストラクタの例を示す.
import tensorflow as tf M1 = tf.constant([[1, 2, 3], [4, 5, 6]]) print(M1) import numpy as np np.array([1, 2, 3]) M2 = tf.constant( np.array([[1, 2, 3], [4, 5, 6]]) ) print(M2)
ニューラルネットワークのデモサイト: http://playground.tensorflow.org
【関連項目】 TensorFlow
TensorFlow の URL: https://www.tensorflow.org/
TensorFlow 1.14 を使いたいとき,次の組み合わせになる.cuDNN 7.6.5 は,Windows で実際に試してみたことが根拠.
【関連項目】 TensorFlow
TensorFlow の URL: https://www.tensorflow.org/
TensorFlow 1.15.5 は Python 3.7, Python 3.6 で動く(Python 3.10 や Python 3.9 や Python 3.8 では動かない).
その根拠は,次のページである. https://pypi.org/project/tensorflow/1.15.5/#files
TensorFlow 1.15.5 は, NVIDIA CUDA ツールキット のバージョン 10.0 を必要とする.それより新しいバージョンでは動かない. NVIDIA cuDNN のバージョン 7 系列を必要とする.バージョン 8 系列では動かない.
以上から,TensorFlow 1.15.5 を使いたいとき,次の組み合わせになる.
【関連項目】 TensorFlow
Windows で TensorFlow 1.15.5 を使うためには,次を行う.
このページでは,「すでにPython 3.9 あるいは Python 3.8 をインストールしている,あるいは,インストール予定」という場合を想定し, あとのトラブルが起きにくい,そして,簡単に運用できるように 「Python 3.7 をインストールし,その上に,TensorFlow 1.15.5 をインストールする」という手順を案内している.
Ubuntu のシステム Python に影響を与えないように,隔離された Python 3.6 仮想環境の新規作成し,その上にTensorFlow 1.15.5 をインストールするという手順(venv を使用)(Ubuntu 上)を案内している.
import tensorflow.compat.v1 as tf # tf.enable_v1_behavior() import os os.environ['CUDA_VISIBLE_DEVICES'] = '0' # 0 = GPU use; -1 = CPU use config = tf.compat.v1.ConfigProto( device_count = {'GPU': 1 , 'CPU': 3} ) sess = tf.compat.v1.Session(config=config) tf.keras.backend.set_session(sess)
【関連項目】 TensorFlow, TensorFlow 1.14, TensorFlow 1.15
TensorFlow Playground はオンラインで動く. ニューラルネットワークの ニューロン,結合,学習,重みの変化,学習率,活性化関数(ReLU など),正則化(L2 正則化など),バッチサイズ,データの分類,回帰,そして,ハイパーパラメータが,学習にどのように影響するかなどを簡単に確認できるオンラインのサービスである. URL は次の通り.
http://playground.tensorflow.org
【関連項目】 TensorFlow
TensorFlow-Slimは,CNN (convolutional neural network) による画像分類のモデルで利用される学習や検証の機能を持つ. 微調整 (fine tuning)の機能も持つ.
TensorFlow-Slimは,TensorFlow, 1.14 から 2.2 で動くようである (根拠: https://github.com/google-research/tf-slim). 最新の TensorFlow で動くとは限らないので,利用者で確認すること.
N. Silberman and S. Guadarrama, TensorFlow-Slim image classification model library, 2016.
関連項目: TensorFlow のモデルガーデン
【関連項目】 TensorFlow
TensorFlow-Slim の公式ページ(https://github.com/tensorflow/models/tree/master/research/slim)の手順に従う.
Git の公式ページ: https://git-scm.com/
Windows での TensorFlow-Slim のインストールは, コマンドプロンプトを管理者として開き そのコマンドプロンプトで,次のコマンドを実行することで行う.
python -m pip install -U contextlib2 tf_slim
インストールできたかの確認は,次のコマンドで行う. エラーメッセージが出ないことを確認すること.
python -c "import tf_slim as slim; eval = slim.evaluation.evaluate_once"
「c:\Program Files\Python38」のところは,Python のインストールディレクトリを設定すること.
cd "c:\Program Files\Python38\Lib" git clone --recursive https://github.com/tensorflow/models mklink /D slim models\research\slim
インストールできたかの確認は,次のコマンドで行う. エラーメッセージが出ないことを確認すること.
python -c "from slim.nets import cifarnet; m = cifarnet.cifarnet"
【関連項目】 TensorFlow
TensorFlow データセットのカタログのページ: https://www.tensorflow.org/datasets/catalog/overview
「tfds.list_builders()」により,現在インストールされている TensorFlow データセットの データセットビルダーを確認できる.
TensorFlow データセットのロード時に分割を行うには,次のように書く.
「0%:50%」は先頭から 50 %, 「50%:100%」は末尾の 50% 部分.
from __future__ import absolute_import, division, print_function, unicode_literals import tensorflow as tf import numpy as np import tensorflow_datasets as tfds %matplotlib inline import matplotlib.pyplot as plt import warnings warnings.filterwarnings('ignore') # Suppress Matplotlib warnings iris, iris_info = tfds.load('iris', split=['train[0%:50%]', 'train[50%:100%]'], with_info = True, shuffle_files=True, as_supervised=True) iris = {'train': iris[0], 'test': iris[1]}
【関連項目】 CIFAR-10 データセット, CIFAR-100 データセット, Fashion MNIST データセット, IMDb データセット, MNIST データセット, くずし字 MNIST データセット(Kuzushiji-MNIST データセット)
【関連項目】 TensorFlow
TensorFlow データセットカタログ の URL: https://www.tensorflow.org/datasets/catalog/overview
【関連項目】 TensorFlow
URL: https://github.com/tensorflow/models
Windows では,次のような手順でダウンロードできる.
「c:\Program Files\Python38」のところは,Python のインストールディレクトリを設定すること.
Git の公式ページ: https://git-scm.com/
cd "c:\Program Files\Python38\Lib" git clone --recursive https://github.com/tensorflow/models
cd "c:\Program Files\Python38\Lib" mklink /D slim models\research\slim
関連項目: TensorFlow-Slim
【関連項目】 TensorFlow
TensorFlow のバージョン,TensorFlow のバージョンと Python のバージョンの関係は,次のページで確認するのが便利である.
https://pypi.org/project/tensorflow/#files
2022年10月時点では TensorFlow の最新版は 2.10 である
TensorFlow のインストールは 別の項目で説明している.
Saliency Map
!pip3 install --upgrade git+https://github.com/tensorpack/tensorpack.git %tensorflow_version 1.x %cd /content !rm -rf tensorpack !git clone https://github.com/tensorpack/tensorpack %cd tensorpack %cd examples/Saliency !curl -O http://download.tensorflow.org/models/resnet_v1_50_2016_08_28.tar.gz !tar -xzvf resnet_v1_50_2016_08_28.tar.gz !curl -L https://github.com/opencv/opencv/blob/master/samples/data/squirrel_cls.jpg?raw=true -o squirrel_cls.jpg !python3 ./saliency-maps.py squirrel_cls.jpg
Tesseract OCR は,文字認識ソフトウェアである.
【サイト内の関連ページ】
【関連する外部ページ】
GitHub の Tesseract OCR のページ: https://github.com/tesseract-ocr/tesseract
( 2017.9 に開発の停止がアナウンス)
TinaFace は顔検出法である. ResNet50 と Feature Pyramid Network (FPN) をベースとする顔検出法. FPN は 6 レベルあり,それを踏襲している. そうした仕組みになっていることから,さまざまなサイズの顔を検出できるとされている. WIDER FACE データセットを用いた検証により,当時の他の顔検出法よりも精度が優れているとされている.
Yanjia Zhu, Hongxiang Cai, Shuhan Zhang, Chenhao Wang, Yichao Xiong, TinaFace: Strong but Simple Baseline for Face Detection, 2020, arXiv:2011.13183 [cs.CV],
【関連項目】 RetinaNet, SCRFD, モデル, 顔検出 (face detection)
Titanic データセットは,公開されているデータセット(オープンデータ)である.
【文献】
Frank E. Harrell Jr., Thomas Cason, Titanic dataset, 2002.
【サイト内の関連ページ】
【関連する外部ページ】
【関連項目】 GPT-2, text generation, テキスト特徴 (text feature)
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
!pip3 install transformers
from transformers import pipeline, set_seed generator = pipeline('text-generation', model='gpt2') set_seed(42) generator("Hello, I'm a language model,", max_length=30, num_return_sequences=5)
from transformers import GPT2Tokenizer, TFGPT2Model tokenizer = GPT2Tokenizer.from_pretrained('gpt2') model = TFGPT2Model.from_pretrained('gpt2') text = "Replace me by any text you'd like." encoded_input = tokenizer(text, return_tensors='tf') output = model(encoded_input) print(output)
Twinmotion は,Unreal Engine を用いて実装されている. 3次元メッシュ(Wavefront OBJ, fbx)のインポート, 3次元点群データのインポート,高さマップ(r15, png)のインポート, OpenStreetMap との連携,人物の配置,波の表現,空の表現などの機能がある.
【関連項目】 Unreal Engine
R システム で,2群 s1, s2 の t 検定を行うプログラム
t.test(s1, s2, var.equal=TRUE) t.test(s1, s2, var.equal=FALSE)
【関連項目】 検定
U2-Net は salient obeject detection の一手法. 【文献】
Xuebin Qin, Zichen Zhang, Chenyang Huang, Masood Dehghan, Osmar R. Zaiane and Martin Jagersand, U2-Net: Going Deeper with Nested U-Structure for Salient Object Detection, arXiv:2108.10257, 2021. 【サイト内の関連ページ】
rembg のインストールと動作確認(画像の背景除去)(Python を使用)(Windows 上): 別ページ »で説明している.
【関連する外部ページ】
【関連項目】 BASNet, U-Net, salient object detection, セマンティック・セグメンテーション (semantic segmentation)
ビデオでのアクションの認識 UCF101 データセット は,101 のアクションカテゴリに分類済みの動画のデータセット.
UCF101 データセットは次の URL で公開されているデータセット(オープンデータ)である.
https://www.crcv.ucf.edu/data/UCF101.php
【関連情報】
画像数は 1535枚. 各画像のアノテーションされたオブジェクト数は 49 から 12865 である.
Haroon Idrees, Muhmmad Tayyab, Kishan Athrey, Dong Zhang, Somaya Al-Maadeed, Nasir Rajpoot, and Mubarak Shah. Composition loss for counting, density map estima- tion and localization in dense crowds. In ECCV, 2018.
【関連用語】 crowd counting, FIDTM, オープンデータ
Olaf Ronneberger, Philipp Fischer, Thomas Brox, U-Net: Convolutional Networks for Biomedical Image Segmentation, CoRR, abs/1505.04597v1, 2015.
https://lmb.informatik.uni-freiburg.de/people/ronneber/u-net/
【関連項目】 BASNet, セマンティック・セグメンテーション (semantic segmentation), salient object detection
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
U-Net のテストプログラムのオンライン実行を行うまでの手順を示す.
!rm -rf PyTorch-UNet !git clone https://github.com/milesial/PyTorch-UNet
https://github.com/milesial/PyTorch-UNet の指示通りに行う. 学習済みモデル(ファイル名 unet_carvana_scale0.5_epoch1.pth)を ダウンロードし,PyTorch-UNet の下に置く
%cd PyTorch-UNet !curl -L https://github.com/opencv/opencv/blob/master/samples/data/fruits.jpg?raw=true -o fruits.jpg !curl -L https://github.com/opencv/opencv/blob/master/samples/data/home.jpg?raw=true -o home.jpg !curl -L https://github.com/opencv/opencv/blob/master/samples/data/squirrel_cls.jpg?raw=true -o squirrel_cls.jpg from PIL import Image Image.open('fruits.jpg').show() Image.open('home.jpg').show() Image.open('squirrel_cls.jpg').show()
!python3 predict.py --model unet_carvana_scale0.5_epoch1.pth -i fruits.jpg -o fruits_out.jpg !python3 predict.py --model unet_carvana_scale0.5_epoch1.pth -i home.jpg -o home_out.jpg !python3 predict.py --model unet_carvana_scale0.5_epoch1.pth -i squirrel_cls.jpg -o squirrel_cls_out.jpg from PIL import Image Image.open('fruits_out.jpg').show() Image.open('home_out.jpg').show() Image.open('squirrel_cls_out.jpg').show()
Unified Scene Text Detection は,テキスト検出(text detection),ドキュメントのレイアウト解析(layout analysis)を統合することにより,精度の改善を行っている. 2022年発表.
【文献】
Towards End-to-End Unified Scene Text Detection and Layout Analysis, Long, Shangbang and Qin, Siyang and Panteleev, Dmitry and Bissacco, Alessandro and Fujii, Yasuhisa and Raptis, Michalis, Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2022.
https://arxiv.org/abs/2203.15143
【サイト内の関連ページ】
Unified Scene Text Detection のインストールとテスト実行(テキスト検出)(Python,TensorFlow を使用)(Windows 上): 別ページ »で説明している.
【関連する外部ページ】
【関連項目】 HierText
Utah teapot は,1975 年に University of Utah の Martin Newell により制作された3次元データ.
Utah teapot のデータは,common.wikimedia.prg の次のページからダウンロードすることができる.
https://commons.wikimedia.org/wiki/File:Utah_teapot_(solid).stl
20000枚以上の顔画像,68ランドマーク,各種の属性(年齢,性別など)
次の URL で公開されているデータセット(オープンデータ)である.
UTKFace の URL: https://susanqq.github.io/UTKFace/
【関連項目】 顔のデータベース, 顔ランドマーク (facial landmark)
VALL-E X は,音声合成(TTS),プロンプトとして音声を与えて音声合成(voice cloning)の技術である.
【サイト内の関連ページ】
【関連する外部ページ】
【関連項目】 Bark
vcpkg は,C や C++ のライブラリを管理する機能を持ったソフトウェア.Windows, Linux, MacOS で動く. ダウンロードされたファイルは,downloads 下に保存される.
vcpkg の GitHub のページ: https://github.com/microsoft/vcpkg
vcpkg のインストール後, cmake から,vcpkg でインストールされたソフトウェアを認識できるようにするために, cmake の実行において,次のようなオプションを付ける場合がある.
-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows
Windows での vcpkg のインストール: 別ページ »で説明している.
venv は,Python の仮想環境を作成する機能を提供するモジュールである.Python の仮想環境は隔離されており,特定のバージョンのPythonや,特定のバージョンやPythonパッケージを管理するのに役立つ.
詳しい説明は: 別ページ »で説明している.
【Python のまとめ】
別ページ に Python の機能などをまとめている.
【関連項目】 Python, Python, pip, Python 開発環境,Python コンソールのコマンドでの起動, Python のインストール,pip と setuptools の更新, Python の仮想環境, virtualenv
venv を用いて,新しいPython の仮想環境の生成 Python の隔離された環境の新規作成,有効化,無効化を行う.
python --version
ここでは,venv のためのディレクトリ名「%HOMEPATH%\.venv」を指定して,新しいPython の仮想環境を生成する.
python -m venv %HOMEPATH%\.venv dir /w %HOMEPATH%\.venv
%HOMEPATH%\.venv\Scripts\activate.bat
python -m pip list
deactivate
venv を用いて,新しいPython の仮想環境の生成 Python の隔離された環境の新規作成,有効化,無効化を行う.
sudo apt -y update sudo apt -y install python3-venv
python3 --version
ここでは,venv のためのディレクトリ名「~/.venv」を指定して,新しいPython の仮想環境を生成する.
※ システム Python と違うバージョンの Python を使いたいときは, pyenv を用いる.別ページ »で説明
※ 「python3 -m venv」は,システム Python を用いての venv モジュールの実行
source ~/.venv/bin/activate
python -m pip list
deactivate
VGGFace2 データセットは,顔画像がクラス分けされたデータ.
作者からは,社会的,性別的,人種的,その他の偏りに注意して使うように,注意が行われている.
次の URL で公開されているデータセット(オープンデータ)である.
https://www.robots.ox.ac.uk/~vgg/data/vgg_face/
【関連項目】 facial inpainting, 顔のデータベース, 顔認識
動画 (video) については,「動画」の項目で説明している.
【関連項目】 動画
Python のフレームワーク,ライブラリ,ソフトウェア等のリスト.
vinta の awesome-python: https://github.com/vinta/awesome-python
【関連項目】 Python
Oracle VM VirtualBox は仮想マシンのソフトウエア
【サイト内の主な関連ページ】
【関連する外部ページ】
Virtual Box の公式ページ: https://www.virtualbox.org/
Ubuntu で,Python の仮想環境の作成
「test」のところは,Python の仮想環境の名前を指定. Python の仮想環境を削除するときは「rm -rf test」のように操作する.
sudo apt -y update sudo apt -y install virtualenv python3-virtualenv virtualenv test source test/bin/activate
【関連項目】 Python, Python, pip, Python 開発環境,Python コンソールのコマンドでの起動, Python のインストール,pip と setuptools の更新, Python の仮想環境, venv
Windows での Microsoft Build Tools 2015 (Microsoft Build Tools 2015 (マイクロソフト C++ ビルドツール 2015)のインストール: 別ページ »で説明している.
Visual Studio Community 2019 のインストールには,複数の方法がある. 次のいずれかによりインストールできる.
winget をインストールしたのち,コマンドプロンプトを管理者として開き「winget install Microsoft.VisualStudio.2019.Community」を実行
ここでは,winget を用いてインストールする方法を説明する.
winget install Microsoft.VisualStudio.2019.Community
スタートメニューの「Visual Studio Installer」を使うのが便利
今後は,「言語パック」で「英語」と「日本語」にチェックし,「変更」をクリック.
「再起動が必要です」と表示された場合には,指示に従う.
Vision Transformer は, 画像分類を,CNN よりも高速に,CNN よりも精度が落ちることなく実行できるとされる.
Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, Neil Houlsby, An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale, ICLR 2021, 2021.
【関連項目】 画像分類
非公式の PyTorch での ViT の実装
https://github.com/lucidrains/vit-pytorch
VMware は仮想マシンソフトウエア
【サイト内の関連ページ】
VOICEVOX は,音声合成のソフトウェア.
VOICEVOX CORE の GitHub のページ: https://github.com/VOICEVOX/voicevox_core
【関連項目】 音声合成 (Text To Speech; TTS)
VoltDB Community エディションは, インメモリ SQL データベース,スナップショットによる永続性(persistence)の機能を持つ.
【サイト内の関連ページ】 VoltDB 11.4 のインストール(ソースコードを使用)(Ubuntu 上)
【関連する外部ページ】
VoltDB の GitHub のページ: https://github.com/VoltDB/voltdb
VoltDB の公式のチュートリアル: https://docs.voltdb.com/tutorial/
「warning C4819 ファイルは,現在のコードページ (932) で表示できない文字を含んでいます. ファイルを Unicode 形式で保存してください」という警告が出る場合がある.
多くの場合,この警告は無視しても良さそうである.
警告のため,コンパイルを進めることができないという場合には, ファイルすべての文字コードを「UTF-8」に変換することで, この問題が解決できる場合がある. 文字コードの変換には,FileCode Checker などのソフトウェアを利用できる. 文字コードの変換は,バックアップを作成した後で実行すること.
FileCode Checker の 作者に感謝します.
FileCode Checker の Vector のページ: https://www.vector.co.jp/soft/winnt/util/se478635.html
Wasserstein GANでは, GAN (Generative Adversarial Network) での勾配消失問題の解決に取り組んでいる. GAN (Generative Adversarial Network) で用いられてきた Jensen-Shannon divergence (確率密度間の距離尺度の1つ) の代わりに Wasserstein 距離を用いる. 安定して学習ができるとされている
CoRR, abs/1701.07875v3
【関連項目】 GAN (Generative Adversarial Networks), image generation
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
実行時間の目安は,ハードウェアアクセラレータなしで 2時間
!rm -rf PyTorch-GAN !git clone https://github.com/eriklindernoren/PyTorch-GAN !python -m pip install -r PyTorch-GAN/requirements.txt !rm -rf PyTorch-GAN/implementations/wgan/images !python3 PyTorch-GAN/implementations/wgan/wgan.py
結果は /content/PyTorch-GAN/images の下にある. その中の画像をダブルクリックすると,Webブラウザに画像の中身が表示される.
PyTorch-GAN のページで公開されているプログラム等を使用
Windows では,コマンドプロン プトを管理者として実行し, 次のコマンドを実行する.
実行時間の目安は,GPU 搭載パソコンで数分.
cd %LOCALAPPDATA% rmdir /s /q PyTorch-GAN git clone https://github.com/eriklindernoren/PyTorch-GAN cd PyTorch-GAN python -m pip install -U -r requirements.txt cd implementations/wgan rmdir /s /q images python wgan.py
結果は images の下に保存される.
PyTorch-GAN のページで公開されているプログラム等を使用
Ubuntu では,次のコマンドを実行.
実行時間の目安は,GPU 搭載パソコンで数分.
sudo apt -y update sudo apt -y install git cd /usr/local sudo git clone https://github.com/eriklindernoren/PyTorch-GAN sudo chown -R $USER PyTorch-GAN # システム Python の環境とは別の Python の仮想環境(システム Python を使用)を作成 sudo apt -y update sudo apt -y install python3-venv python3 -m venv ~/a source ~/a/bin/activate cd /usr/local/PyTorch-GAN pip install -U -r requirements.txt cd implementations/wgan rm -rf images python wgan.py
結果は images の下に保存される.
【関連項目】 GAN (Generative Adversarial Networks), image generation Wasserstein GAN (WGAN)
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する).
実行時間の目安は,ハードウェアアクセラレータなしで 2時間
!rm -rf PyTorch-GAN !git clone https://github.com/eriklindernoren/PyTorch-GAN !python -m pip install -r PyTorch-GAN/requirements.txt !rm -rf PyTorch-GAN/implementations/wgan_gp/images !python3 PyTorch-GAN/implementations/wgan_gp/wgan_gp.py
結果は /content/PyTorch-GAN/images の下にある. その中の画像をダブルクリックすると,Webブラウザに画像の中身が表示される.
PyTorch-GAN のページで公開されているプログラム等を使用
Git の公式ページ: https://git-scm.com/
cd %LOCALAPPDATA% rmdir /s /q PyTorch-GAN git clone https://github.com/eriklindernoren/PyTorch-GAN cd PyTorch-GAN python -m pip install -U -r requirements.txt cd implementations/wgan_gp rmdir /s /q images python wgan_gp.py
PyTorch-GAN のページで公開されているプログラム等を使用
Ubuntu では,次のコマンドを実行.
sudo apt -y update sudo apt -y install git cd /usr/local sudo git clone https://github.com/eriklindernoren/PyTorch-GAN sudo chown -R $USER PyTorch-GAN # システム Python の環境とは別の Python の仮想環境(システム Python を使用)を作成 sudo apt -y update sudo apt -y install python3-venv python3 -m venv ~/a source ~/a/bin/activate cd /usr/local/PyTorch-GAN pip install -U -r requirements.txt cd implementations/wgan_gp rm -rf images python wgan_gp.py
結果は images の下に保存される.
機械学習向けの大規模な顔画像のデータセット. 顔検出,顔の分類(年齢,性別など)の用途が想定されている.2021年時点では,研究者等が利用可能な,最大規模の顔画像のデータセットである. データは次の2種類がある.
4M identities, 260M images, images/id 64, cleaning no, public
2M identities, 42M images, images/id 21, cleaning auto, 7 attributes 訓練データに適するとされている.年齢,人種,性別,シナリオ(controlled, in-the-wild, cross-scene)
次の URL で公開されているデータセット(オープンデータ)である.
URL: https://www.face-benchmark.org/index.html
詳細は,「the Masked Face Recognition challenge」の文献で説明されている.
Zheng Zhu, Guan Huang, Jiankang Deng, Yun Ye, Junjie Huang, Xinze Chen, Jiagang Zhu, Tian Yang, Jiwen Lu, Dalong Du, Jie Zhou, WebFace260M: A Benchmark Unveiling the Power of Million-scale Deep Face Recognition, IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2021
Zheng Zhu, Guan Huang, Jiankang Deng, Yun Ye, Junjie Huang, Xinze Chen, Jiagang Zhu, Tian Yang, Jia Guo, Jiwen, Lu, Dalong Du, and Jie Zhou. Masked face recognition challenge: The WebFace260M track report. arXiv:2108.07189, 2021.
【関連項目】 顔のデータベース
GnuWin のWget のページからダウンロードしてインストール
Wget のインストールの詳細: 別ページ »で説明
https://cmake.org/download/ からダウンロードしてインストール
このとき,ライセンス条項の確認を行う.設定は既定(デフォルト)のままでよい.
Whisperは,音声からの文字起こし,翻訳を行う. 訓練されたモデルが既存のデータセットにゼロショットで適用可能であり、データセット固有のファインチューニングを必要とせずに高品質な結果を達成することを特徴とする.
【文献】
Alec Radford, Jong Wook Kim, Tao Xu, Greg Brockman, Christine McLeavey, Ilya Sutskever, Robust Speech Recognition via Large-Scale Weak Supervision, CoRR abs/2212.04356, 2022.
https://cdn.openai.com/papers/whisper.pdf
【サイト内の関連ページ】
【関連する外部ページ】
【関連項目】
【関連項目】 Residual Networks (ResNets), モデル, 画像分類
PyTorch HUB のページ: https://pytorch.org/hub/pytorch_vision_wide_resnet/ を参考にした.
Google Colab あるいはパソコン(Windows あるいは Linux)を使用.
前準備として,Python のインストール: 別項目で説明している., PyTorch のインストール を行う.
Google Colaboratory では, Python, PyTorch はインストール済みなので,インストール操作は不要.
次に,pip を用いて,pillow のインストールを行う.
pip install -U pillow
PyTorch, torchvision のモデルについては: https://pytorch.org/vision/stable/models.html に説明がある.
import torch import torchvision.models as models device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') m = models.wide_resnet50_2(pretrained=True).to(device)
from PIL import Image import requests from IPython.display import display # ダウンロードとロード url = 'https://github.com/pytorch/hub/raw/master/images/dog.jpg' response = requests.get(url) img = Image.open(requests.get(url, stream=True).raw) # 確認表示 display(img)
from PIL import Image from torchvision import transforms img = Image.open(filename) preprocess = transforms.Compose([ transforms.Resize(256), transforms.CenterCrop(224), transforms.ToTensor(), transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]), ]) input_tensor = preprocess(img) input_batch = input_tensor.unsqueeze(0)
「m.eval()」は,推論を行うときのためのもの.これを行わないと訓練(学習)が行われる.
import torch if torch.cuda.is_available(): input_batch = input_batch.to('cuda') m.eval() with torch.no_grad(): output = m(input_batch)
import urllib url, filename = ("https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt", "imagenet_classes.txt") try: urllib.URLopener().retrieve(url, filename) except: urllib.request.urlretrieve(url, filename) with open("imagenet_classes.txt", "r") as f: categories = [s.strip() for s in f.readlines()] # The output has unnormalized scores. To get probabilities, you can run a softmax on it. probabilities = torch.nn.functional.softmax(output[0], dim=0) print(probabilities) top5_prob, top5_catid = torch.topk(probabilities, 5) for i in range(top5_prob.size(0)): print(categories[top5_catid[i]], top5_prob[i].item())
Google Colaboratory での結果
Windows での結果
Linux での結果
PyTorch HUB のページ: https://pytorch.org/hub/pytorch_vision_wide_resnet/ を参考にした.
Google Colab あるいはパソコン(Windows あるいは Linux)を使用.
前準備として,Python のインストール: 別項目で説明している., PyTorch のインストール を行う.
Google Colaboratory では, Python, PyTorch はインストール済みなので,インストール操作は不要.
次に,pip を用いて,pillow のインストールを行う.
pip install -U pillow
PyTorch, torchvision のモデルについては: https://pytorch.org/vision/stable/models.html に説明がある.
import torch import torchvision.models as models device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') m = models.wide_resnet101_2(pretrained=True).to(device)
from PIL import Image import requests from IPython.display import display # ダウンロードとロード url = 'https://github.com/pytorch/hub/raw/master/images/dog.jpg' response = requests.get(url) img = Image.open(requests.get(url, stream=True).raw) # 確認表示 display(img)
from PIL import Image from torchvision import transforms img = Image.open(filename) preprocess = transforms.Compose([ transforms.Resize(256), transforms.CenterCrop(224), transforms.ToTensor(), transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]), ]) input_tensor = preprocess(img) input_batch = input_tensor.unsqueeze(0)
「m.eval()」は,推論を行うときのためのもの.これを行わないと訓練(学習)が行われる.
import torch if torch.cuda.is_available(): input_batch = input_batch.to('cuda') m.eval() with torch.no_grad(): output = m(input_batch)
import urllib url, filename = ("https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt", "imagenet_classes.txt") try: urllib.URLopener().retrieve(url, filename) except: urllib.request.urlretrieve(url, filename) with open("imagenet_classes.txt", "r") as f: categories = [s.strip() for s in f.readlines()] # The output has unnormalized scores. To get probabilities, you can run a softmax on it. probabilities = torch.nn.functional.softmax(output[0], dim=0) print(probabilities) top5_prob, top5_catid = torch.topk(probabilities, 5) for i in range(top5_prob.size(0)): print(categories[top5_catid[i]], top5_prob[i].item())
Google Colaboratory での結果
Windows での結果
Linux での結果
WIDER FACE データセットは,次の URL で公開されているデータセット(オープンデータ)である.
URL: http://shuoyang1213.me/WIDERFACE/
【関連情報】
【関連項目】 顔のデータベース, 顔検出 (face detection)
【サイト内の主な Windows 関連ページ】
Wine は,Windows の API の機能を提供することにより,Windows アプリケーションを Linux 上で動かすことを一部可能とするソフトウェア.
Linux でのインストールは,次のWebページに説明がある
https://wiki.winehq.org/Download
Wine のインストールの手順は,Linux ディストリビューションの種類によって違うので注意.
Ubuntu では,次のWebページの手順に従う
https://wiki.winehq.org/Ubuntu
WinPython は,Window 用のPython 処理系と主要な Python パッケージを1つにまとめたソフトウェア.次のアプリケーションも同封されている
Windows での WinPython のインストールには,複数の方法がある.次のいずれかによりインストールできる.
winget をインストールしたのち,コマンドプロンプトを管理者として開き「winget install winpython」を実行.
【関連項目】 Python のインストール: 別項目で説明している.
実用で使うなら Linux を使い,パスワード,ファイヤウオール等を適切に設定する.バックアップも適切に行う.
【サイト内の関連ページ】
Redmon, Joseph and Farhadi, Ali, YOLOv3: An Incremental Improvement, CoRR, abs/1804.02767v1 2018.
【関連項目】 AlexeyAB darknet, MMDetection, YOLOv4, YOLOX, モデル, 物体検出
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する)
%cd /content !rm -rf darknet !git clone https://github.com/AlexeyAB/darknet %cd darknet !make GPU=1 CUDNN=1 CUDNN_HALF=1 OPENCV=1
AlexeyAB darknet のアセット: https://github.com/AlexeyAB/darknet/releases/
!curl -LO https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v3_optimal/yolov3.weights
!rm -r predictions.jpg !./darknet detector test cfg/coco.data cfg/yolov3.cfg yolov3.weights data/dog.jpg -dont_show from PIL import Image Image.open('predictions.jpg').show() !./darknet detector test cfg/coco.data cfg/yolov3.cfg yolov3.weights data/giraffe.jpg -dont_show Image.open('predictions.jpg').show() !./darknet detector test cfg/coco.data cfg/yolov3.cfg yolov3.weights data/horses.jpg -dont_show Image.open('predictions.jpg').show() !./darknet detector test cfg/coco.data cfg/yolov3.cfg yolov3.weights data/person.jpg -dont_show Image.open('predictions.jpg').show()
書きかけ(動作チェック中)
cd %LOCALAPPDATA% rmdir /s /q darknet git clone https://github.com/AlexeyAB/darknet cd darknet del CMakeCache.txt cmake -G "Visual Studio 17 2022" -A x64 -T host=x64 ^ -DCUDA_BUILD_CUBIN=ON -DENABLE_CUDA=ON -DENABLE_CUDNN=ON -DENABLE_CUDNN_HALF=ON cmake --build . --config RELEASE --target INSTALL -- /m:4 Windows では,システム環境変数 PATH に,次の2つを追加. %LOCALAPPDATA%\darknet\build\darknet\x64 %LOCALAPPDATA%\darknet\3rdparty\pthreads\bin cd %LOCALAPPDATA% cd darknet curl -LO https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v3_optimal/yolov3.weights darknet detect cfg/yolov3.cfg yolov3.weights data/dog.jpg -ext_output darknet detect cfg/yolov3.cfg yolov3.weights data/giraffe.jpg -ext_output darknet detect cfg/yolov3.cfg yolov3.weights data/horses.jpg -ext_output darknet detect cfg/yolov3.cfg yolov3.weights data/person.jpg -ext_output curl -O https://www.kkaneko.jp/sample/video/samplevideo.mp4 ./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights samplevideo.mp4 -i 0 -thresh 0.25
Avatar Erik Linder-Norén による YOLOv3 の実装: https://github.com/eriklindernoren/PyTorch-YOLOv3
Ubuntu では,次のコマンドを実行.
sudo apt -y update sudo apt -y install virtualenv python3-virtualenv cd ${HOME} virtualenv a source a/bin/activate pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html python -c "import torch; print(torch.__version__, torch.cuda.is_available())" pip install pytorchyolo # ソースコード等をダウンロード(後の作業で使うため) cd /usr/local sudo git clone https://github.com/eriklindernoren/PyTorch-YOLOv3 sudo chown -R ${USER} PyTorch-YOLOv3 # 事前学習の重み (pretrained weight) yolov3.weights, yolov3-tiniy.weights, darknet53.conv.74 のダウンロード cd /usr/local/PyTorch-YOLOv3/weights bash ./download_weights.sh # COCO データセット train2014.zip, val2014.zip, instances_train-val2014,zip, 5k.part, trainvalno5k.part, labels.tgz のダウンロード cd /usr/local/PyTorch-YOLOv3/data bash ./get_coco_dataset.sh # テスト実行 cd /usr/local/PyTorch-YOLOv3 yolo-test --weights weights/yolov3.weights
テスト実行の結果,COCO test データセットでの,AP と mAP が表示される.
Ubuntu では,次のコマンドを実行.
cd /usr/local/PyTorch-YOLOv3 yolo-detect --images data/samples/
推論の結果が表示される. 推論の結果としては,data/samples 下にある画像ファイルについての物体検出の結果である,クラス名と確信度 (confidence) が得られる. あわせて,output の下に,物体検出の画像ファイルができる.
ImageNet で事前学習済みの Darknet-53 バックエンドを用いて, COCO データセットによる学習を行う手順が, https://github.com/eriklindernoren/PyTorch-YOLOv3 で説明されている.
yolo-train --data config/coco.data --pretrained_weights weights/darknet53.conv.74
物体検出のモデルである.
【関連項目】 AlexeyAB darknet, YOLOX, モデル, 物体検出
次のコマンドやプログラムは Google Colaboratory で動く(コードセルを作り,実行する)
%cd /content !rm -rf darknet !git clone https://github.com/AlexeyAB/darknet %cd darknet !make GPU=1 CUDNN=1 CUDNN_HALF=1 OPENCV=1
AlexeyAB darknet のアセット: https://github.com/AlexeyAB/darknet/releases/
!curl -LO https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v3_optimal/yolov4.weights
!rm -r predictions.jpg !./darknet detector test cfg/coco.data cfg/yolov4.cfg yolov4.weights data/dog.jpg -dont_show from PIL import Image Image.open('predictions.jpg').show() !./darknet detector test cfg/coco.data cfg/yolov4.cfg yolov4.weights data/giraffe.jpg -dont_show Image.open('predictions.jpg').show() !./darknet detector test cfg/coco.data cfg/yolov4.cfg yolov4.weights data/horses.jpg -dont_show Image.open('predictions.jpg').show() !./darknet detector test cfg/coco.data cfg/yolov4.cfg yolov4.weights data/person.jpg -dont_show Image.open('predictions.jpg').show()
DarkNet53 バックボーンとするYOLOv3 に修正を行たもの.
物体検出のモデルである. single-stage である. DarkNet53 バックボーンとするYOLOv3 に修正を行たものである.
Zheng Ge, Songtao Liu, Feng Wang, Zeming Li, Jian Sun, YOLOX: Exceeding YOLO Series in 2021, CoRR, abs/2107.08430v2, 2021.
【関連項目】 MMDetection, YOLOv3, YOLOv4, モデル, 物体検出
公式のソースコードを使用.
!pip3 install cython !pip3 install git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI !rm -rf YOLOX !git clone https://github.com/Megvii-BaseDetection/YOLOX !pip3 install -U pip !pip3 install -r YOLOX/requirements.txt !(cd YOLOX; python3 setup.py develop)
!(cd YOLOX; curl -L -O https://github.com/Megvii-BaseDetection/YOLOX/releases/download/0.1.1rc0/yolox_x.pth)
GPU を使うときは「cpu」のところを「GPU」に変える
!(cd YOLOX; python tools/demo.py image -n yolox-x -c ./yolox_x.pth --path assets/dog.jpg --conf 0.25 --nms 0.45 --tsize 640 --save_result --device cpu)
./YOLOX_outputs/yolox_x/vis_res の下に結果ができるので確認
GPU を使うときは「cpu」のところを「GPU」に変える
次のプログラムでは,curl は,画像ファイルのダウンロードのために用いている(コマンドを使わずに,手作業で画像ファイルを置く場合には,この部分は不要)
画像ファイル名には「../img.png」のように「../」を付けていることに注意.「../」は,「1つ上のレベルのディレクトリ」という意味.
!curl -O https://raw.githubusercontent.com/zylo117/Yet-Another-EfficientDet-PyTorch/master/test/img.png !curl -O https://raw.githubusercontent.com/opencv/opencv/master/samples/data/fruits.jpg !curl -O https://raw.githubusercontent.com/opencv/opencv/master/samples/data/home.jpg !(cd YOLOX; python tools/demo.py image -n yolox-x -c ./yolox_x.pth --path ../img.png --conf 0.25 --nms \ 0.45 --tsize 640 --save_result --device cpu) !(cd YOLOX; python tools/demo.py image -n yolox-x -c ./yolox_x.pth --path ../fruits.jpg --conf 0.25 --n\ ms 0.45 --tsize 640 --save_result --device cpu) !(cd YOLOX; python tools/demo.py image -n yolox-x -c ./yolox_x.pth --path ../home.jpg --conf 0.25 --nms\ 0.45 --tsize 640 --save_result --device cpu)
./YOLOX_outputs/yolox_x/vis_res の下に結果ができるので確認
bpy (blenderpy)を使うときに便利なソフトウェアのライブラリと,そのサンプルプログラムと,各種のアセット.
Git のインストール: 別項目で説明している.
Git の公式ページ: https://git-scm.com/ が必要.
mkdir c:\pytools cd c:\pytools rmdir /s /q blender-cli-rendering-master git clone https://github.com/yuki-koyama/blender-cli-rendering
Windows で Python のバージョン指定したいときは, 「python 」でなく「py -3.7」のように実行すること. 「-3.7」のところには,使用する Python のバージョンを指定(バージョンが分からないときは「py -0」で調べる).
cd c:\pytools cd blender-cli-rendering-master python
import bpy import utils # scene utils.clean_objects() scene = bpy.data.scenes["Scene"] monkey = utils.create_smooth_monkey(location=(0, 0, 1)) plane = utils.create_plane(size=20.0) camera = utils.create_camera(location=(5, -3, 3)) utils.add_track_to_constraint(camera, monkey) # light light = utils.create_sun_light(rotation=(0.3, -1.5, 1.2)) # rendering utils.set_output_properties(scene, 20, 'c:/pytools/02') utils.set_cycles_renderer(scene, camera, 16) bpy.ops.render.render(write_still=True)
次の画像ができる.
import os import bpy import utils # scene utils.clean_objects() scene = bpy.data.scenes["Scene"] monkey = utils.create_smooth_monkey(location=(0, 0, 1)) plane = utils.create_plane(size=20.0) camera = utils.create_camera(location=(5, -3, 3)) utils.add_track_to_constraint(camera, monkey) # light working_dir_path = os.path.abspath('.') hdri_path = os.path.join(working_dir_path, "assets\HDRIs\green_point_park_2k.hdr") utils.build_environment_texture_background(scene.world, hdri_path) # rendering utils.set_output_properties(scene, 20, 'c:/pytools/03') utils.set_cycles_renderer(scene, camera, 16) bpy.ops.render.render(write_still=True)
謝辞:この項目に記載のソースコードは, https://github.com/yuki-koyama/blender-cli-rendering/ で公開されているものを改変して使用している.
【関連項目】 bpy (blenderpy), Blender
ZLIB DLL は,データの圧縮と展開(解凍)の機能を持ったライブラリ.
【関連する外部サイト】
ZLIB DLL のインストールを行うため, Windows で,コマンドプロンプトを管理者として実行
コマンドプロンプトを管理者として実行: 別ページ »で説明
curl -O http://www.winimage.com/zLibDll/zlib123dllx64.zip powershell -command "Expand-Archive -Path zlib123dllx64.zip" copy zlib123dllx64\dll_x64\zlibwapi.dll .
モデルの学習において, モデルの重みを更新することを繰り返すが, その各々1回をイテレーション (iteration) という. 「反復」ともいう. 1回のイテレーションで,データの 1つのバッチに対する損失についてのパラメータの勾配が計算される.
インスタンス・セグメンテーション (instance segmentation) は, 物体検出 を行うだけでなく, 検出されたオブジェクトについて, オブジェクトのセグメンテーションマスクを画素単位で生成する.
セマンティック・セグメンテーション との違いは次の通りである. セマンティック・セグメンテーションでは,「インスタンス」という概念がないため, シーン内に複数の人物 (person) がいるような場合,人物の領域に person をいうラベルを付ける. インスタンス・セグメンテーションは, シーン内に複数の人物 (person) がいるような場合,それぞれの人物を分離する. 【関連項目】 セマンティック・セグメンテーション (semantic segmentation), シーン解析(scene parsing), CASILVision, MIT Scene Parsing Benchmark, 物体検出
パラメトリック検定.等分散を仮定しない場合と仮定する場合がある.多群の検定.
R システム で,x, y についての ウエルチの方法による一元配置分散分析 (One-way analysis of means) を行うプログラム.
なお,群数が2の場合には t 検定(R の t.test)と同じ結果が得られる.
oneway.test(x ~ y)
等分散 のときは,「var=T」を付ける.
oneway.test(x ~ y, var=T)
なお,群数が2の場合には,等分散での t 検定(R の t.test(var.equal=TRUE))と同じ結果が得られる.
【関連項目】 検定
帰無仮説: ノンパラメトリック検定の1つ.対応のある2標本で,2群の差が 0 である.
【関連項目】 検定
教師データを全て使い終わったら 1エポックである.
ミニバッチ学習を行うとき, 教師データのサイズを N とすると, N 割るバッチサイズの回数のイテレーション (iteration) が実行される. バッチサイズが 100,教師データのサイズが 800であるとすると, 8回のイテレーション (iteration) で 1エポックである.
このサイトでは,「オープンデータは,インターネットで公開されているデータ,もしくは,インターネット等を用いて利用申込みができるデータ」の意味で用いている.
オープンデータには次のようなものがある.
次のデータはオープンデータではない.(ダウンロードには,申請を必要とする).
【関連情報】
【関連項目】 R データセット (Rdatasets) を用いる場合には,
オプティカルフローは MMFlow で算出できる.
【関連項目】 MMFlow
オプティマイザは, 勾配降下法を実装したものである. 最適化器には,次のようなものがある.
TensorFlow の最適化器のベースクラスは tf.train.Optimizer クラスである.
勾配降下法の効果を高めるために,次のような手法が考案されている.
論文: An overview of gradient descent optimization algorithms, CoRR, abs/1609.04747.
http://sebastianruder.com/optimizing-gradient-descent/
Keras のオプティマイザのページ: https://keras.io/api/optimizers/  
確率分布 [1/2, 1/2] からエントロピーを求める Python プログラム. 「base = 2」で log の底を 2 としてエントロピーを求めている
print(scipy.stats.entropy([1/2, 1/2], base=2))
参考ページ: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.entropy.html
確率分布 c(1/2, 1/2) からエントロピーを求める R のプログラム. 「unit="log2"」で log の底を 2 としてエントロピーを求めている
library(entropy) entropy(c(1/2, 1/2), unit="log2")
参考資料: https://cran.r-project.org/web/packages/entropy/entropy.pdf
Undercomplete Autoencoder, Sparse Autoencoder, Convolutional Autoencoder, Stacked Autoencoder, Variational Autoencoder (VAE), VQ-VAE(Vector Quantised) などの種類がある.
キーポイントは,画像の中での,ある特定の特徴の座標. 「ランドマーク」ともいう.
くずし字 MNIST データセットは,公開されているデータセット(オープンデータ)である.
【文献】 CODH:Center for Open Data in the Humanities), KMNISTデータセット(機械学習用くずし字データセット), arXiv:1812.01718 [cs.CV], 2018.
【サイト内の関連ページ】
【関連する外部ページ】
Kuzushiji-MNIST, Kuzushiji-49, Kuzushiji-Kanji の 3種類が公開されている(オープンデータ).
【関連項目】 MNIST データセット, TensorFlow データセット, オープンデータ,