#author("2022-04-12T08:49:50+00:00","default:sysosa","sysosa")
#author("2023-01-27T12:15:57+00:00","default:sysosa","sysosa")
本家様 [[http://sphire.mpg.de/wiki/doku.php?id=auto_2d_class_selection>+http://sphire.mpg.de/wiki/doku.php?id=auto_2d_class_selection]]

Automatic 2D class selection


***インストール [#h6b44929]
まずはpyenv環境を構築する[[crYOLO#w789c07e]]
その次に
Cinderella 向けの仮想実行環境を作る
#code(nonumber){{
[root@c ~]# conda create -n cinderella-gpu -c anaconda python=3.6 pyqt=5 cudnn=7.1.2 numpy==1.14.5 h5py=2.7

(h5pyのバージョンを固定しないと動かないみたい)

[root@c ~]# source activate cinderella-gpu
               
(cinderella-gpu) [root@c ~]# pip install cinderella[gpu]

(cinderella-gpu) [root@c ~]# which sp_cinderella_predict.py
/apps/pyenv/versions/anaconda3-2021.11/envs/cinderella-0.7.0-cpu/bin/sp_cinderella_predict.py
(cinderella-gpu) [root@c ~]#

(cinderella-gpu) [root@c ~]# conda deactivate
[root@c ~]#
}}



***EnvironmentModules [#a77b2f7e]
[[EnvironmentModules]]で実行環境を整備するならmodiilefileを下記のようにする
&color(red){*};&size(10){普通は「/etc/modulefiles/cinderella」かな};
#code(nonumber){{
[root@c ~]# vi /home/Common/modules/cinderella 
#%Module -*- tcl -*-

proc ModulesHelp { } {
  puts stderr "\tAdds anaconda to your environment variables,"
}
module-whatis "Adds anaconda to your environment variables"
set          root /Appl/pyenv/versions/anaconda3-5.3.1/envs/cinderella
prepend-path PATH $root/bin
[root@c ~]#
}}

ロード方法は「module load cinderella」




***使い方 [#j8202fe4]
参照[[http://sphire.mpg.de/wiki/doku.php?id=auto2d_tutorial>+http://sphire.mpg.de/wiki/doku.php?id=auto2d_tutorial]]

Pretrained modelが提供されているので、それを取得します。

「relion30_tutorial_precalculated_results/Class2D/job008」を使ってみた
「relion40_tutorial_precalculated_results/Class2D/job008」を使ってみた

#code(nonumber){{
(cinderella) [saber@c cinderella]$ sp_cinderella_predict.py -i run_it025_classes.mrcs -w /Appl/cinderella/model_cinderella_20190708.h5 -o out/ -t 0.7 --gpu 1
(cinderella) [saber@c cinderella]$ cp ../relion40_tutorial_precalculated_results/Class2D/job008/run_it025_classes.mrcs .
(cinderella) [saber@c cinderella]$ sp_cinderella_predict.py -i run_it025_classes.mrcs -w /apps/cinderella/gmodel_cinderella07_202008_N10163.h5 -o out/ -t 0.7
Using TensorFlow backend.
2019-09-13 00:40:33.505544: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2019-09-13 00:40:33.518586: E tensorflow/stream_executor/cuda/cuda_driver.cc:397] failed call to cuInit: CUDA_ERROR_NO_DEVICE
2019-09-13 00:40:33.519113: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:163] retrieving CUDA diagnostic information for host: c.sybyl.local
2019-09-13 00:40:33.519131: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:170] hostname: c.sybyl.local
2019-09-13 00:40:33.519178: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:194] libcuda reported version is: 418.39.0
2019-09-13 00:40:33.519230: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:198] kernel reported version is: 418.39.0
2019-09-13 00:40:33.519244: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:305] kernel version seems to match DSO: 418.39.0
Model: "model_2"
_________________________________________________________________
Layer (type)                 Output Shape              Param #
=================================================================
input_1 (InputLayer)         (None, 75, 75, 1)         0
_________________________________________________________________
model_1 (Model)              (None, 4, 4, 1024)        50646432
_________________________________________________________________
global_average_pooling2d_1 ( (None, 1024)              0
_________________________________________________________________
denseL1 (Dense)              (None, 64)                65600
_________________________________________________________________
denseL2 (Dense)              (None, 10)                650
_________________________________________________________________
denseL3 (Dense)              (None, 1)                 11
=================================================================
Total params: 50,712,693
Trainable params: 50,691,637
Non-trainable params: 21,056
_________________________________________________________________
2019-09-13 00:40:37.687003: W tensorflow/core/framework/allocator.cc:108] Allocation of 37748736 exceeds 10% of system memory.
2019-09-13 00:40:37.687099: W tensorflow/core/framework/allocator.cc:108] Allocation of 37748736 exceeds 10% of system memory.
2019-09-13 00:40:37.728333: W tensorflow/core/framework/allocator.cc:108] Allocation of 47185920 exceeds 10% of system memory.
2019-09-13 00:40:37.808678: W tensorflow/core/framework/allocator.cc:108] Allocation of 37748736 exceeds 10% of system memory.
2019-09-13 00:40:37.826402: W tensorflow/core/framework/allocator.cc:108] Allocation of 37748736 exceeds 10% of system memory.
Try to list images on run_it025_classes.mrcs
100%|????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????| 2/2 [00:01<00:00,  1.94it/s]

 Good classes:  2 / 50 ( 4 % )


 Bad classes:  48 / 50 ( 96 % )

(cinderella) [saber@c cinderella]$
}}

「relion_display --gui」でoutputのファイルを開いてみる。


***メモ [#d7017857]
#code(nonumber){{
line 1224, in load_weights_from_hdf5_group_by_name
    original_keras_version = f.attrs['keras_version'].decode('utf8')
AttributeError: 'str' object has no attribute 'decode'
}}
とエラーが発生した場合は、pythonモジュールの「h5py」が新しいのが原因。古いのにダウングレードすれば回避可能
#code(nonumber){{
pip uninstall h5py
pip install h5py==2.10.0
}}
あとRTX 30x0 でcinderellaを動かすには crYOLO と同じように cuda11対応tensorflow 1.xを用意する必要がある.
1

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS