質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Google Colaboratory

Google Colaboratoryとは、無償のJupyterノートブック環境。教育や研究機関の機械学習の普及のためのGoogleの研究プロジェクトです。PythonやNumpyといった機械学習で要する大方の環境がすでに構築されており、コードの記述・実行、解析の保存・共有などが可能です。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

0回答

1279閲覧

SSD300で物体検出を行った際に出てくる大量の警告文をなくしたい

aizawahozumi

総合スコア0

Google Colaboratory

Google Colaboratoryとは、無償のJupyterノートブック環境。教育や研究機関の機械学習の普及のためのGoogleの研究プロジェクトです。PythonやNumpyといった機械学習で要する大方の環境がすでに構築されており、コードの記述・実行、解析の保存・共有などが可能です。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2022/12/02 02:52

前提

SSD300を使った物体検出をに取り組んでいます。
勉強を始めたばかりで質問に不手際があったら申し訳ありません。

実現したいこと

画像に対する推論を実施した際に検出自体には成功していうるのですがすごい数の警告が出てきてしまいます。
これらの警告を出来れば出てこないようにしたいです。

発生している問題・エラーメッセージ

/content/drive/MyDrive/本実験/utils/ssd_model.py:590: UserWarning: An output with one or more elements was resized since it had shape [11], which does not match the required output shape [9]. This behavior is deprecated, and in a future PyTorch release outputs will not be resized unless they have zero elements. You can explicitly reuse an out tensor t by resizing it, inplace, to zero elements with t.resize_(0). (Triggered internally at ../aten/src/ATen/native/Resize.cpp:17.) torch.index_select(x1, 0, idx, out=tmp_x1) /content/drive/MyDrive/本実験/utils/ssd_model.py:591: UserWarning: An output with one or more elements was resized since it had shape [11], which does not match the required output shape [9]. This behavior is deprecated, and in a future PyTorch release outputs will not be resized unless they have zero elements. You can explicitly reuse an out tensor t by resizing it, inplace, to zero elements with t.resize_(0). (Triggered internally at ../aten/src/ATen/native/Resize.cpp:17.) torch.index_select(y1, 0, idx, out=tmp_y1) /content/drive/MyDrive/本実験/utils/ssd_model.py:592: UserWarning: An output with one or more elements was resized since it had shape [11], which does not match the required output shape [9]. This behavior is deprecated, and in a future PyTorch release outputs will not be resized unless they have zero elements. You can explicitly reuse an out tensor t by resizing it, inplace, to zero elements with t.resize_(0). (Triggered internally at ../aten/src/ATen/native/Resize.cpp:17.) torch.index_select(x2, 0, idx, out=tmp_x2) /content/drive/MyDrive/本実験/utils/ssd_model.py:593: UserWarning: An output with one or more elements was resized since it had shape [11], which does not match the required output shape [9]. This behavior is deprecated, and in a future PyTorch release outputs will not be resized unless they have zero elements. You can explicitly reuse an out tensor t by resizing it, inplace, to zero elements with t.resize_(0). (Triggered internally at ../aten/src/ATen/native/Resize.cpp:17.) torch.index_select(y2, 0, idx, out=tmp_y2) /content/drive/MyDrive/本実験/utils/ssd_model.py:590: UserWarning: An output with one or more elements was resized since it had shape [9], which does not match the required output shape [8]. This behavior is deprecated, and in a future PyTorch release outputs will not be resized unless they have zero elements. You can explicitly reuse an out tensor t by resizing it, inplace, to zero elements with t.resize_(0). (Triggered internally at ../aten/src/ATen/native/Resize.cpp:17.) torch.index_select(x1, 0, idx, out=tmp_x1) /content/drive/MyDrive/本実験/utils/ssd_model.py:591: UserWarning: An output with one or more elements was resized since it had shape [9], which does not match the required output shape [8]. This behavior is deprecated, and in a future PyTorch release outputs will not be resized unless they have zero elements. You can explicitly reuse an out tensor t by resizing it, inplace, to zero elements with t.resize_(0). (Triggered internally at ../aten/src/ATen/native/Resize.cpp:17.) torch.index_select(y1, 0, idx, out=tmp_y1)

該当のソースコード

python3

1from utils.ssd_model import DataTransform 2 3# 1. 画像読み込み 4image_file_path = "/content/drive/MyDrive/犬/1796780.jpg" 5img = cv2.imread(image_file_path) # [高さ][幅][色BGR] 6height, width, channels = img.shape # 画像のサイズを取得 7 8# 2. 元画像の表示 9plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB)) 10plt.show() 11 12# 3. 前処理クラスの作成 13color_mean = (104, 117, 123) # (BGR)の色の平均値 14input_size = 300 # 画像のinputサイズを300×300にする 15transform = DataTransform(input_size, color_mean) 16 17# 4. 前処理 18phase = "val" 19img_transformed, boxes, labels = transform(img, phase, "", "") # アノテーションはないので、""にする 20img = torch.from_numpy(img_transformed[:, :, (2, 1, 0)]).permute(2, 0, 1) 21 22# 5. SSDで予測 23net.eval() # ネットワークを推論モードへ 24x = img.unsqueeze(0) # ミニバッチ化:torch.Size([1, 3, 300, 300]) 25detections = net(x) 26 27#print(detections.shape) 28#print(detections) 29 30# output : torch.Size([batch_num, 21, 200, 5]) 31# =(batch_num、クラス、confのtop200、規格化されたBBoxの情報) 32# 規格化されたBBoxの情報(確信度、xmin, ymin, xmax, ymax) 33

補足情報(FW/ツールのバージョンなど)

google colab で実行しています。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

meg_

2022/12/02 04:41

モジュールのバージョンは何でしょうか?
aizawahozumi

2022/12/02 04:51

ダウングレードするべきということでしょうか?
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問