所与のアレイについて1.行い、他方が0に設定されている、そのようなpytorchセグメンテーション結果は、特定のクラスを取って、複数のクラスを含む、特定の値を取りますか?
#classp = [0,1,2,2,3,0,5,2]这样,后面box,score,mask与之对应
ids = torch.where(classp==0)#选择人类别
classp = classp[ids]
box = box[ids]
score = score[ids]
mask = mask[ids[0], :]
同様にシンプルにすることができます
#classp = [0,1,2,2,3,0,5,2]这样,后面box,score,mask与之对应
ids = (classp==0)#选择人类别
classp = classp[ids]
box = box[ids]
score = score[ids]
mask = mask[ids, :]
2. pytorch推論段階は、どのモデルが全く勾配情報ではないことを保証するために?
torch.no_gradで使用()、修正
with torch.no_grad():
cudnn.fastest = True
torch.set_default_tensor_type('torch.cuda.FloatTensor')
print('yolact loading model...', end='')
net = Yolact()
net.load_weights(config.yolact['model_path'])
net.eval()
print(' Done.')
self.net = net.cuda()
self.net.detect.use_fast_nms = True
self.net.detect.use_cross_class_nms = False
3.どのようにCUDAへの変換でpytorchテンソルにnumpyの配列に
torch.from_numpy(np_array).cuda()。フロート()
どのようにコードがファイル内のデバッグ4.vs?デバッグ作業ディレクトリを指定する方法は?Pythonのconda環境を使用する方法は?チューニングパラメータ、多くの引数に参加するには?
1)グラフィカルインタフェース動作を介して、生成launch.json
2)追加引数を編集する:[ " - THRESH = 0.5"、 "--cuda"
3)加入PYTHONPATH: "/ホーム/シルバ/ anaconda3 / ENVS / py372 / binに/ pythonの"
4)加入CWD: "/ホーム/シルバ/仕事"
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"pythonPath": "/home/silva/anaconda3/envs/py372/bin/python",
"cwd": "${fileDirname}",
"args": [
"--trained_model=weights/yolact_resnet50_54_800000.pth",
"--score_threshold=0.15",
"--top_k=15",
"--video_multiframe=4",
"--video=0"
]
}
]
}
パラメータを参照、またはコピーの転写によって渡される5. numpyのアレイが経過しましたか?
多くの場合、間違っていた、元は参照によって渡されます。関数内で配列を変更し、その配列の機能が変更されます呼び出します。
DEF ABC(ARR):ARR = np.zeros((3,3))
実行後、=のnp.ones((3,3))、その後、ABC()を呼び出し、印刷()はどのくらい?変わりません
もしDEF ABC(ARR):ARR + = 3、ABC()実行後?3の増加
ARR [1] [1] = 34、ABC()実行した後:DEF ABC(ARR)か?対応する要素34となります
参考 https://stackoverflow.com/questions/11585793/are-numpy-arrays-passed-by-reference