Download free for 30 days
Sign in
Upload
Language (EN)
Support
Business
Mobile
Social Media
Marketing
Technology
Art & Photos
Career
Design
Education
Presentations & Public Speaking
Government & Nonprofit
Healthcare
Internet
Law
Leadership & Management
Automotive
Engineering
Software
Recruiting & HR
Retail
Sales
Services
Science
Small Business & Entrepreneurship
Food
Environment
Economy & Finance
Data & Analytics
Investor Relations
Sports
Spiritual
News & Politics
Travel
Self Improvement
Real Estate
Entertainment & Humor
Health & Medicine
Devices & Hardware
Lifestyle
Change Language
Language
English
Español
Português
Français
Deutsche
Cancel
Save
EN
Uploaded by
Deep Learning JP
1,407 views
[DL Hacks]CelebAをNumPyで保存してみた
2018/09/10 Deep Learning JP: http://deeplearning.jp/hacks/
Technology
◦
Related topics:
Deep Learning
•
Read more
2
Save
Share
Embed
Embed presentation
Download
Download to read offline
1
/ 13
2
/ 13
3
/ 13
4
/ 13
5
/ 13
6
/ 13
7
/ 13
8
/ 13
9
/ 13
10
/ 13
11
/ 13
12
/ 13
13
/ 13
More Related Content
PPTX
[DL輪読会]Graph R-CNN for Scene Graph Generation
by
Deep Learning JP
PPTX
[DL輪読会]Dense Captioning分野のまとめ
by
Deep Learning JP
PPTX
画像キャプションの自動生成
by
Yoshitaka Ushiku
PDF
SSII2022 [SS1] ニューラル3D表現の最新動向〜 ニューラルネットでなんでも表せる?? 〜
by
SSII
PDF
SSII2021 [SS1] Transformer x Computer Visionの 実活用可能性と展望 〜 TransformerのCompute...
by
SSII
PPTX
【DL輪読会】An Image is Worth One Word: Personalizing Text-to-Image Generation usi...
by
Deep Learning JP
PPTX
PyTorchLightning ベース Hydra+MLFlow+Optuna による機械学習開発環境の構築
by
Kosuke Shinoda
PDF
ドメイン適応の原理と応用
by
Yoshitaka Ushiku
[DL輪読会]Graph R-CNN for Scene Graph Generation
by
Deep Learning JP
[DL輪読会]Dense Captioning分野のまとめ
by
Deep Learning JP
画像キャプションの自動生成
by
Yoshitaka Ushiku
SSII2022 [SS1] ニューラル3D表現の最新動向〜 ニューラルネットでなんでも表せる?? 〜
by
SSII
SSII2021 [SS1] Transformer x Computer Visionの 実活用可能性と展望 〜 TransformerのCompute...
by
SSII
【DL輪読会】An Image is Worth One Word: Personalizing Text-to-Image Generation usi...
by
Deep Learning JP
PyTorchLightning ベース Hydra+MLFlow+Optuna による機械学習開発環境の構築
by
Kosuke Shinoda
ドメイン適応の原理と応用
by
Yoshitaka Ushiku
What's hot
PPTX
【DL輪読会】Flamingo: a Visual Language Model for Few-Shot Learning 画像×言語の大規模基盤モ...
by
Deep Learning JP
PPTX
【DL輪読会】AUTOGT: AUTOMATED GRAPH TRANSFORMER ARCHITECTURE SEARCH
by
Deep Learning JP
PDF
失敗から学ぶ機械学習応用
by
Hiroyuki Masuda
PDF
[DL輪読会]Learning Transferable Visual Models From Natural Language Supervision
by
Deep Learning JP
PDF
SSII2022 [SS2] 少ないデータやラベルを効率的に活用する機械学習技術 〜 足りない情報をどのように補うか?〜
by
SSII
PDF
【メタサーベイ】基盤モデル / Foundation Models
by
cvpaper. challenge
PDF
三次元点群を取り扱うニューラルネットワークのサーベイ
by
Naoya Chiba
PDF
DQNからRainbowまで 〜深層強化学習の最新動向〜
by
Jun Okumura
PDF
Deep Learningによる超解像の進歩
by
Hiroto Honda
PDF
最近のDeep Learning (NLP) 界隈におけるAttention事情
by
Yuta Kikuchi
PPTX
[DL輪読会]When Does Label Smoothing Help?
by
Deep Learning JP
PDF
【DL輪読会】Can Neural Network Memorization Be Localized?
by
Deep Learning JP
PDF
[DL輪読会]Neural Radiance Flow for 4D View Synthesis and Video Processing (NeRF...
by
Deep Learning JP
PDF
三次元表現まとめ(深層学習を中心に)
by
Tomohiro Motoda
PDF
SSII2021 [OS2-03] 自己教師あり学習における対照学習の基礎と応用
by
SSII
PDF
SSII2022 [OS3-02] Federated Learningの基礎と応用
by
SSII
PDF
Generating Diverse High-Fidelity Images with VQ-VAE-2
by
harmonylab
PPTX
SuperGlue;Learning Feature Matching with Graph Neural Networks (CVPR'20)
by
Yusuke Uchida
PPTX
[DL輪読会]Life-Long Disentangled Representation Learning with Cross-Domain Laten...
by
Deep Learning JP
PPTX
[DL輪読会]GLIDE: Guided Language to Image Diffusion for Generation and Editing
by
Deep Learning JP
【DL輪読会】Flamingo: a Visual Language Model for Few-Shot Learning 画像×言語の大規模基盤モ...
by
Deep Learning JP
【DL輪読会】AUTOGT: AUTOMATED GRAPH TRANSFORMER ARCHITECTURE SEARCH
by
Deep Learning JP
失敗から学ぶ機械学習応用
by
Hiroyuki Masuda
[DL輪読会]Learning Transferable Visual Models From Natural Language Supervision
by
Deep Learning JP
SSII2022 [SS2] 少ないデータやラベルを効率的に活用する機械学習技術 〜 足りない情報をどのように補うか?〜
by
SSII
【メタサーベイ】基盤モデル / Foundation Models
by
cvpaper. challenge
三次元点群を取り扱うニューラルネットワークのサーベイ
by
Naoya Chiba
DQNからRainbowまで 〜深層強化学習の最新動向〜
by
Jun Okumura
Deep Learningによる超解像の進歩
by
Hiroto Honda
最近のDeep Learning (NLP) 界隈におけるAttention事情
by
Yuta Kikuchi
[DL輪読会]When Does Label Smoothing Help?
by
Deep Learning JP
【DL輪読会】Can Neural Network Memorization Be Localized?
by
Deep Learning JP
[DL輪読会]Neural Radiance Flow for 4D View Synthesis and Video Processing (NeRF...
by
Deep Learning JP
三次元表現まとめ(深層学習を中心に)
by
Tomohiro Motoda
SSII2021 [OS2-03] 自己教師あり学習における対照学習の基礎と応用
by
SSII
SSII2022 [OS3-02] Federated Learningの基礎と応用
by
SSII
Generating Diverse High-Fidelity Images with VQ-VAE-2
by
harmonylab
SuperGlue;Learning Feature Matching with Graph Neural Networks (CVPR'20)
by
Yusuke Uchida
[DL輪読会]Life-Long Disentangled Representation Learning with Cross-Domain Laten...
by
Deep Learning JP
[DL輪読会]GLIDE: Guided Language to Image Diffusion for Generation and Editing
by
Deep Learning JP
More from Deep Learning JP
PPTX
【DL輪読会】AdaptDiffuser: Diffusion Models as Adaptive Self-evolving Planners
by
Deep Learning JP
PPTX
【DL輪読会】事前学習用データセットについて
by
Deep Learning JP
PPTX
【DL輪読会】 "Learning to render novel views from wide-baseline stereo pairs." CVP...
by
Deep Learning JP
PPTX
【DL輪読会】Zero-Shot Dual-Lens Super-Resolution
by
Deep Learning JP
PPTX
【DL輪読会】BloombergGPT: A Large Language Model for Finance arxiv
by
Deep Learning JP
PPTX
【DL輪読会】マルチモーダル LLM
by
Deep Learning JP
PDF
【 DL輪読会】ToolLLM: Facilitating Large Language Models to Master 16000+ Real-wo...
by
Deep Learning JP
PPTX
【DL輪読会】AnyLoc: Towards Universal Visual Place Recognition
by
Deep Learning JP
PPTX
【DL輪読会】Hopfield network 関連研究について
by
Deep Learning JP
PPTX
【DL輪読会】SimPer: Simple self-supervised learning of periodic targets( ICLR 2023 )
by
Deep Learning JP
PDF
【DL輪読会】RLCD: Reinforcement Learning from Contrast Distillation for Language M...
by
Deep Learning JP
PDF
【DL輪読会】"Secrets of RLHF in Large Language Models Part I: PPO"
by
Deep Learning JP
PPTX
【DL輪読会】"Language Instructed Reinforcement Learning for Human-AI Coordination "
by
Deep Learning JP
PPTX
【DL輪読会】Llama 2: Open Foundation and Fine-Tuned Chat Models
by
Deep Learning JP
PDF
【DL輪読会】"Learning Fine-Grained Bimanual Manipulation with Low-Cost Hardware"
by
Deep Learning JP
PPTX
【DL輪読会】Parameter is Not All You Need:Starting from Non-Parametric Networks fo...
by
Deep Learning JP
PDF
【DL輪読会】Drag Your GAN: Interactive Point-based Manipulation on the Generative ...
by
Deep Learning JP
PDF
【DL輪読会】Self-Supervised Learning from Images with a Joint-Embedding Predictive...
by
Deep Learning JP
PPTX
【DL輪読会】Towards Understanding Ensemble, Knowledge Distillation and Self-Distil...
by
Deep Learning JP
PPTX
【DL輪読会】VIP: Towards Universal Visual Reward and Representation via Value-Impl...
by
Deep Learning JP
【DL輪読会】AdaptDiffuser: Diffusion Models as Adaptive Self-evolving Planners
by
Deep Learning JP
【DL輪読会】事前学習用データセットについて
by
Deep Learning JP
【DL輪読会】 "Learning to render novel views from wide-baseline stereo pairs." CVP...
by
Deep Learning JP
【DL輪読会】Zero-Shot Dual-Lens Super-Resolution
by
Deep Learning JP
【DL輪読会】BloombergGPT: A Large Language Model for Finance arxiv
by
Deep Learning JP
【DL輪読会】マルチモーダル LLM
by
Deep Learning JP
【 DL輪読会】ToolLLM: Facilitating Large Language Models to Master 16000+ Real-wo...
by
Deep Learning JP
【DL輪読会】AnyLoc: Towards Universal Visual Place Recognition
by
Deep Learning JP
【DL輪読会】Hopfield network 関連研究について
by
Deep Learning JP
【DL輪読会】SimPer: Simple self-supervised learning of periodic targets( ICLR 2023 )
by
Deep Learning JP
【DL輪読会】RLCD: Reinforcement Learning from Contrast Distillation for Language M...
by
Deep Learning JP
【DL輪読会】"Secrets of RLHF in Large Language Models Part I: PPO"
by
Deep Learning JP
【DL輪読会】"Language Instructed Reinforcement Learning for Human-AI Coordination "
by
Deep Learning JP
【DL輪読会】Llama 2: Open Foundation and Fine-Tuned Chat Models
by
Deep Learning JP
【DL輪読会】"Learning Fine-Grained Bimanual Manipulation with Low-Cost Hardware"
by
Deep Learning JP
【DL輪読会】Parameter is Not All You Need:Starting from Non-Parametric Networks fo...
by
Deep Learning JP
【DL輪読会】Drag Your GAN: Interactive Point-based Manipulation on the Generative ...
by
Deep Learning JP
【DL輪読会】Self-Supervised Learning from Images with a Joint-Embedding Predictive...
by
Deep Learning JP
【DL輪読会】Towards Understanding Ensemble, Knowledge Distillation and Self-Distil...
by
Deep Learning JP
【DL輪読会】VIP: Towards Universal Visual Reward and Representation via Value-Impl...
by
Deep Learning JP
[DL Hacks]CelebAをNumPyで保存してみた
1.
CelebAをNumPyで保存してみた CelebAデータセットの202599枚のjpeg画像と40の属性を NumPy配列に変換し1枚のファイルに保存してみました 2018/9/10 DLHacks LT 植木孝一郎
2.
CelebFaces Attributes (CelebA)
Dataset 香港中文大学(マルチメディア研究室)の大規模な顔属性のデータセット http://mmlab.ie.cuhk.edu.hk/projects/CelebA.html 論文 https://arxiv.org/abs/1411.7766 178x218ピクセル、202599枚のjpeg画像(RGB) ファイルサイズ合計 1.743GB
3.
顔の属性 list_attr_celeba.csv 000001.jpg -1 1
1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 以下略(1と-1の2値、40属性) ・・・ 202599.jpg -1 1 1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 以下略 属性は全部で40 (正値は1、負値は-1) 1 : 5_o_Clock_Shadow (無精髭) 2 : Arched_Eyebrows (アーチ型の眉) 3 : Attractive (魅力的) ... 40: Young (若い) 論文には顔属性の識別手法と精度も書かれてます
4.
画像ファイルの読み込み DeepLearningで画像を学習するためには、Pillow(PIL)やOpenCVなどで画像 を読み込みNumPy配列に変換する必要があります。 ファイル名は000001から始まり規則的なのでリスト作成・画像読み込みなどは 簡単にできます。 また顔属性ラベルの list_attr_celeba.csvは numpy.loadtxt()で読み込めます。 問題は処理時間で・・・ Core
i7 メモリ32GB(スワップメモリ64GB)のPCでHDD上の202599枚の画像 を読み込み、NumPy配列に変換すると1929.6秒(約32分)かかりました。 時間をかけデータセットを読み込んだのだから、そのまま保存して活用したい!
5.
保存するNumPy配列 保存するNumPy配列は178x218ピクセルのRGB画像 202599枚をtrain_x とし print(train_x.shape)
(202599, 218, 178, 3) データ型は numpy.uint8 (8ビット符号なし整数)で保存します CSVの属性値(-1,1)を(0,1)に変えた2値の40属性、202599行のNumPy配列をtrain_yとし print(train_y.shape) (202599, 40) train_xとtrain_yを1枚のファイルに保存します。 train_xとtrain_yのメモリ使用量は sys.getsizeof(train_x) 23584954932 (23.584GB) sys.getsizeof(train_y) 8104072 (8.1MB) CelebA 202599枚jpegファイルサイズの合計は 1.743GBでしたので、NumPy配列にすることで13.5倍の容量になります。 ※この容量だとPCのメモリ、スワップメモリに注意してないとエラーやフリーズします! (Linuxなら free -m で確認)
6.
pickle VS numpy.savez PythonでNumPy配列をbinary保存するため ●
Pickle ● numpy.savez(非圧縮、複数) ● numpy.savez_compressed(圧縮、複数) を使って比較しました。 HDD上にファイルを保存する時間、保存したファイルを読み込む時間、保存した ファイルサイズを計測しました。
7.
pickleでsaveとload #保存(python3.4以上) #LT説明用の簡略コード import pickle train_xy =
train_x,train_y with open("save_filename", 'wb') as f: pickle.dump(train_xy , f ,protocol=4) # ← protocolが小さいとメモリエラーになる #読み込み import pickle with open("save_filename", 'rb') as f: train_xy = pickle.load(f) train_x = train_xy[0] train_y = train_xy[1] print(train_x.shape) (202599, 218, 178, 3) print(train_y.shape) (202599, 40)
8.
numpy.savez()で非圧縮保存とload #保存 import numpy as
np np.savez("save_filename", train_x=train_x, train_y=train_y) #読み込み import numpy as np with np.load("save_filename.npz") as data: train_x = data[train_x] train_y = data[train_y] print(train_x.shape) (202599, 218, 178, 3) print(train_y.shape) (202599, 40)
9.
numpy.savez_compressed()で圧縮保存とload #保存 import numpy as
np np.savez_compressed("save_filename", train_x=train_x, train_y=train_y) #読み込み import numpy as np with np.load("save_filename.npz") as data: train_x = data[train_x] train_y = data[train_y] print(train_x.shape) (202599, 218, 178, 3) print(train_y.shape) (202599, 40)
10.
ファイル保存の比較 保存(sec) 読み込み(sec) 作成ファイルサイズ pickle
247.522 153.720 23593058963 (23.593GB) np.savez 102.856 107.335 23593059354 (23.593GB) np.savez_compressed 553.789 114.486 15798570036 (15.798GB) 元の2つのNumPy配列の使用メモリサイズは合計で 2359305900 (23.593GB) 時間計測は5回平均 時間がかかる作成保存は最初の1回だけなので、 私はファイルサイズが小さい np.savez_compressedを使ってます。
11.
NumPyで検索・抽出 属性ラベルも一緒に保存したので、CelebAから画像の検索・抽出を行ってみました。 検索するため train_yを転置します。 print(train_y.shape) (202599,
40) yt = train_y.transpose() print(yt.shape) (40, 202599) 検索は np.where() を使います ※各値は正負(1,0)の2値 Eyeglasses(メガネ yt[15])、Wearing_Earrings(イヤリング着用 yt[34])、 Wearing_Necklace(ネックレス着用 yt[37])、Young(若い yt[39])の Male(男性でなく女性は yt[20]==0) で条件(and)検索します。
12.
NumPyの検索と抽出 index = np.where((yt[15]
== 1) & (yt[34] == 1) & (yt[37] == 1) & (yt[39] == 1) & (yt[20] == 0)) print(len(index[0])) 64 条件に合致するインデックス64件を抽出しました。 print(index[0]) [672 7016 7413 8059 ...] 抽出したインデックスから該当画像データは train_x[672], train_x[7016]...などです。 train_x[672] train_x[7016]
13.
[参考]CelebA 顔属性値(正負の2値) 5_o_Clock_Shadow Arched_Eyebrows Attractive Bags_Under_Eyes Bald Bangs Big_Lips Big_Nose Black_Hair Blond_Hair Blurry Brown_Hair Bushy_Eyebrows Chubby Double_Chin Eyeglasses Goatee Gray_Hair Heavy_Makeup High_Cheekbones Male Mouth_Slightly_Open Mustache Narrow_Eyes No_Beard Oval_Face Pale_Skin Pointy_Nose Receding_Hairline Rosy_Cheeks Sideburns Smiling Straight_Hair Wavy_Hair Wearing_Earrings Wearing_Hat Wearing_Lipstick Wearing_Necklace Wearing_Necktie Young
Download