Ubuntu22.04.5 LTS でNvidia Caffeを継続して使用できる修正ポイント

忍野八海

desktop Ubuntu22.04.5 LTS

1.Pyhton2が使えないのでPython3を活用する
2.Numpy を i.26.4 に設定
pip3 install numpy==1.26.4
3. show_result_py3.py を設定する
chibi@22042204:~/caffe$ cat show_result_py3.py
import sys
import numpy as np

if len(sys.argv) != 3:
print(“Usage: python3 show_result_py3.py synset_words.txt result.npy”)
sys.exit(1)

label_file = sys.argv[1]
result_file = sys.argv[2]

# synset_words.txt の読み込み
labels = []
with open(label_file, ‘r’) as f:
for line in f:
line = line.strip()
if not line:
continue
parts = line.split(‘ ‘, 1)
labels.append(parts[1] if len(parts) > 1 else parts[0])

# 推論結果の読み込み
probs = np.load(result_file)[0]

# 上位5件
top5 = probs.argsort()[::-1][:5]

for rank, idx in enumerate(top5, 1):
print(“#%d | %s | %.1f%%” % (rank, labels[idx], probs[idx] * 100.0))

chibi@22042204:~/caffe$ sudo chown chibi:chibi show_result_py3.py
chibi@22042204:~/caffe$ chmod +x show_result_py3.py
chibi@22042204:~/caffe$ cd python; python3 classify.py –raw_scale 255 ../101_ObjectCategories/airplanes/image_0001.jpg ../result.npy; cd ..
chibi@22042204:~/caffe$ python3 show_result_py3.py data/ilsvrc12/synset_words.txt result.npy

カテゴリー: nvidia, ubuntu パーマリンク

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です