原创 python opencv BGR2RGB轉換原理

 opencv bgr2rgb轉換其實就是在Channel維度B通道和R通道互換: import numpy as np img = np.arange(12).reshape((2,2,3)) print(img) 結果: [[[

原创 python 根據圖片名稱中的數字排序

import re def sort_key(s): #獲取圖片名稱 tail = s.split('\\')[-1] # 匹配開頭數字序號 c = re.findall('\d+', tail)[0]

原创 python 判斷一個數組所有值都在一個範圍內

 判斷一個數組np.array([12,15,20])中所有的值是否都在(10,20)範圍內,如果爲True,賦值 import numpy as np ar = np.array([12,15,20]) print('origina

原创 【2020更新】python 獲取數據集的means和stdevs(均值、方差)

import numpy as np from tqdm import tqdm from glob import glob import cv2 import random import os means = [0, 0, 0] s

原创 train loss與test loss結果分析/loss不下降

train loss與test loss結果分析 train loss 不斷下降,test loss不斷下降,說明網絡仍在學習; train loss 不斷下降,test loss趨於不變,說明網絡過擬合; train loss 趨於不變

原创 【2020最新】解決Github連接、圖片顯示失敗的問題

建議修改hosts文件,本人使用的是windows系統,使用EditPlus或sublime text都可以打開。 沒有EditPlus的同學可以點擊連接下載:http://www.pc6.com/softview/SoftView_36

原创 Video retrieval based on deep convolutional neural network 論文閱讀

      《Video retrieval based on deep convolutional neural network》論文中採用CNN提取高級語義特徵,輸入的三個視頻共享一個cnn參數,經過cnn得到三個視頻各自的特徵([

原创 pytorch多gpu出現RuntimeError

記錄一下使用多gpu出現的報錯。在一開始的時候,使用的是單gpu能夠正常訓練和驗證,但使用多gpu的時候就會報RuntimeError: shape '[xxx,xxx]' is invalid for input of size xxx

原创 【簡單理解】torch.nonzero(同樣適用於獲取tensor中某一元素的索引)

torch.nonzero其實就是找出tensor中非零的元素的索引 import torch label = torch.tensor([[1,0,0], [1,0,1]]) print(l

原创 pytorch 多gpu並行訓練

單機多卡並行訓練 torch.nn.DataParallel 我一般在使用多GPU的時候, 會喜歡使用os.environ['CUDA_VISIBLE_DEVICES']來限制使用的GPU個數, 例如我要使用第0和第3編號的GPU, 那麼

原创 【超簡單】torch.narrow()函數

官方例子: torch.narrow(input, dim, start, length) → Tensor Returns a new tensor that is a narrowed version of input tensor.

原创 pytorch GlobalAveragePolling(GAP)

GAP是對每一個通道的像素求平均,假如現在的特徵圖的shape爲[B,C,H,W],經過GAP後shape變爲[B,C,1,1] a = torch.rand([2,3,2,2]) b = torch.nn.functional.ada

原创 mtcnn 返回值分析

在align_data()函數中調用,detect_face.detect_face()函數,返回bounding_boxes, points,bounding_boxes 就是返回的人臉框,points就是返回的關鍵點。mtcnn返回5

原创 pip 使用清華源安裝python包

常用的清華源: https://pypi.tuna.tsinghua.edu.cn/simple 使用pip配合清華源安裝方式: pip install -i https://pypi.tuna.tsinghua.edu.cn/sim