成人av在线资源一区,亚洲av日韩av一区,欧美丰满熟妇乱XXXXX图片,狠狠做五月深爱婷婷伊人,桔子av一区二区三区,四虎国产精品永久在线网址,国产尤物精品人妻在线,中文字幕av一区二区三区欲色
    您正在使用IE低版瀏覽器,為了您的雷峰網(wǎng)賬號(hào)安全和更好的產(chǎn)品體驗(yàn),強(qiáng)烈建議使用更快更安全的瀏覽器
    此為臨時(shí)鏈接,僅用于文章預(yù)覽,將在時(shí)失效
    人工智能開發(fā)者 正文
    發(fā)私信給AI研習(xí)社-譯站
    發(fā)送

    0

    機(jī)器學(xué)習(xí)開發(fā)者應(yīng)該收藏的 DIY 計(jì)算機(jī)視覺和深度學(xué)習(xí)項(xiàng)目

    本文作者: AI研習(xí)社-譯站 2018-06-13 15:10
    導(dǎo)語:在這篇文章中你將看到一些應(yīng)用計(jì)算機(jī)視覺和深度學(xué)習(xí)的項(xiàng)目,包括具體實(shí)現(xiàn)和細(xì)節(jié),你可以在自己的電腦上復(fù)現(xiàn)這些項(xiàng)目。

    本文為雷鋒網(wǎng)字幕組編譯的技術(shù)博客,原標(biāo)題 DIY Deep Learning Projects,作者為 Favio Vázquez。

    翻譯 | 趙朋飛、林驍    整理 |  孔令雙

    雷鋒網(wǎng)按,在這篇文章中雷鋒網(wǎng)將推薦一些應(yīng)用計(jì)算機(jī)視覺和深度學(xué)習(xí)的項(xiàng)目,包括具體實(shí)現(xiàn)和細(xì)節(jié),你可以在自己的電腦上復(fù)現(xiàn)這些項(xiàng)目。

    LinkedIn 數(shù)據(jù)科學(xué)社區(qū)

    Akshay Bahadur 是 LinkedIn 數(shù)據(jù)科學(xué)社區(qū)給出的最好的榜樣。在其他諸如 Quora、StackOverflow、Youtube 等平臺(tái),有很多優(yōu)秀的人,以及很多論壇和平臺(tái)在科學(xué)、哲學(xué)、數(shù)學(xué)、語言學(xué),以及數(shù)據(jù)科學(xué)等領(lǐng)域互相幫助。

    機(jī)器學(xué)習(xí)開發(fā)者應(yīng)該收藏的 DIY 計(jì)算機(jī)視覺和深度學(xué)習(xí)項(xiàng)目

    Akshay Bahadur

    但我認(rèn)為在過去的 ~3 年間,LinkedIn 社區(qū)在共享數(shù)據(jù)科學(xué)內(nèi)容方面做的非常優(yōu)秀,從分享經(jīng)驗(yàn),到關(guān)于如何在現(xiàn)實(shí)世界進(jìn)行機(jī)器學(xué)習(xí)的文章。我經(jīng)常建議想從事這一領(lǐng)域的人加入這個(gè)社區(qū),而且 LinkedIn 是最好的,你可以在那里隨時(shí)找到我 :)。

    從深度學(xué)習(xí)和計(jì)算機(jī)視覺開始  

    機(jī)器學(xué)習(xí)開發(fā)者應(yīng)該收藏的 DIY 計(jì)算機(jī)視覺和深度學(xué)習(xí)項(xiàng)目

    https://github.com/facebookresearch/Detectron

    在這十年里,在深度學(xué)習(xí)領(lǐng)域中對(duì)圖像進(jìn)行分類、檢測(cè)和執(zhí)行相應(yīng)動(dòng)作的研究是非常重要的,其結(jié)果令人驚訝,有些問題的解決在性能已經(jīng)超越了人類水平。

    在這篇文章中,我將展示 Akshay Bahadur在計(jì)算機(jī)視覺和深度學(xué)習(xí)領(lǐng)域所做的工作。如果你對(duì)這些概念還不熟悉,可以通過閱讀下面這些內(nèi)容學(xué)到更多:

    • 對(duì)深度學(xué)習(xí)的「怪異」介紹  

      這里有關(guān)于深度學(xué)習(xí)的精彩介紹、課程以及博客文章。但這是一種很獨(dú)特的介紹。

      https://towardsdatascience.com/a-weird-introduction-to-deep-learning-7828803693b0

    • 兩個(gè)月探索深度學(xué)習(xí)和計(jì)算機(jī)視覺

      我決定深入了解計(jì)算機(jī)視覺和機(jī)器學(xué)習(xí)。作為一個(gè)網(wǎng)頁開發(fā)者,我發(fā)現(xiàn)了這個(gè)。

      https://towardsdatascience.com/two-months-exploring-deep-learning-and-computer-vision-3dcc84b2457f

    • 從神經(jīng)科學(xué)到計(jì)算機(jī)視覺  

      人類和計(jì)算機(jī)視覺的50年。

      https://towardsdatascience.com/from-neuroscience-to-computer-vision-e86a4dea3574

    • 吳恩達(dá)計(jì)算機(jī)視覺 —— 11 個(gè)經(jīng)驗(yàn)教訓(xùn)

      我最近剛完成吳恩達(dá)在 Coursera 上的計(jì)算機(jī)視覺課程。吳恩達(dá)在解釋這些問題方面做了杰出的工作。

      https://towardsdatascience.com/computer-vision-by-andrew-ng-11-lessons-learned-7d05c18a6999

    1. 使用 OpenCV 手動(dòng)執(zhí)行

    akshaybahadur21/HandMovementTracking

    https://github.com/akshaybahadur21/HandMovementTracking

    機(jī)器學(xué)習(xí)開發(fā)者應(yīng)該收藏的 DIY 計(jì)算機(jī)視覺和深度學(xué)習(xí)項(xiàng)目


     Akshay:

    為了執(zhí)行視頻追蹤,算法需要分析視頻幀序列并輸出每幀之間的目標(biāo)位移。有很多種算法,每種各有強(qiáng)項(xiàng)和弱點(diǎn)。選擇使用哪種算法,重要的是要考慮應(yīng)用目的。視頻追蹤系統(tǒng)有兩個(gè)主要的組成部分:目標(biāo)表示和定位,以及濾波和數(shù)據(jù)關(guān)聯(lián)。

    視頻追蹤是通過攝像頭定位一個(gè)(或多個(gè))移動(dòng)目標(biāo)的過程。擁有多種用途,比如,人機(jī)交互、安全監(jiān)視、視頻通訊與壓縮、增強(qiáng)現(xiàn)實(shí)、交通控制、醫(yī)學(xué)影像,以及視頻編輯等。

    下面是你在復(fù)現(xiàn)它時(shí)需要用到的代碼:

    import numpy as np
    import cv2
    import argparse
    from collections import deque


    cap=cv2.VideoCapture(0)

    pts = deque(maxlen=64)

    Lower_green = np.array([110,50,50])
    Upper_green = np.array([130,255,255])
    while True:
    ret, img=cap.read()
    hsv=cv2.cvtColor(img,cv2.COLOR_BGR2HSV)
    kernel=np.ones((5,5),np.uint8)
    mask=cv2.inRange(hsv,Lower_green,Upper_green)
    mask = cv2.erode(mask, kernel, iterations=2)
    mask=cv2.morphologyEx(mask,cv2.MORPH_OPEN,kernel)
    #mask=cv2.morphologyEx(mask,cv2.MORPH_CLOSE,kernel)
    mask = cv2.dilate(mask, kernel, iterations=1)
    res=cv2.bitwise_and(img,img,mask=mask)
    cnts,heir=cv2.findContours(mask.copy(),cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)[-2:]
    center = None

    if len(cnts) > 0:
      c = max(cnts, key=cv2.contourArea)
      ((x, y), radius) = cv2.minEnclosingCircle(c)
      M = cv2.moments(c)
      center = (int(M["m10"] / M["m00"]), int(M["m01"] / M["m00"]))

      if radius > 5:
        cv2.circle(img, (int(x), int(y)), int(radius),(0, 255, 255), 2)
        cv2.circle(img, center, 5, (0, 0, 255), -1)
      
    pts.appendleft(center)
    for i in xrange (1,len(pts)):
      if pts[i-1]is None or pts[i] is None:
        continue
      thick = int(np.sqrt(len(pts) / float(i + 1)) * 2.5)
      cv2.line(img, pts[i-1],pts[i],(0,0,225),thick)
      

    cv2.imshow("Frame", img)
    cv2.imshow("mask",mask)
    cv2.imshow("res",res)


    k=cv2.waitKey(30) & 0xFF
    if k==32:
      break
    # cleanup the camera and close any open windows
    cap.release()
    cv2.destroyAllWindows()

    是的,54 行代碼,相當(dāng)簡單?如果你的電腦檢查結(jié)果如下面所示的話,你需要先安裝 OpenCV:

    在 MacOS 上安裝 OpenCV

    這篇文章中,我么將逐步介紹在 MacOS 和 OSX 上安裝 OpenCV 3.3.0 (C++ and Python)。

    https://www.learnopencv.com/install-opencv3-on-macos/

    如果你使用 Ubuntu:

    OpenCV:在 Ubuntu 上安裝 OpenCV-Python  

    有了所有必須的依賴項(xiàng),讓我們安裝 OpenCV。需要使用 CMake 配置安裝選項(xiàng)項(xiàng)

    https://docs.opencv.org/3.4.1/d2/de6/tutorial_py_setup_in_ubuntu.html

    如果使用 Windows:

    Windows 安裝 OpenCV-Python- OpenCV 3.0.0-dev documentation

    在這篇教程中我們將學(xué)習(xí)在 Windows 系統(tǒng)中如何設(shè)置O penCV-Python。下面的步驟在 Windows 7-64 中測(cè)試通過

    https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_setup/py_setup_in_windows/py_setup_in_windows.html


    2.基于 OpenCV 的疲勞檢測(cè)

    akshaybahadur21/Drowsiness_Detection

    在 GitHub.github.com 創(chuàng)建賬號(hào)有助于疲勞檢測(cè)項(xiàng)目開發(fā)

    https://github.com/akshaybahadur21/Drowsiness_Detection

    駕駛員長時(shí)間駕駛有可能會(huì)導(dǎo)致事故發(fā)生。這段代碼檢測(cè)你的眼睛,瞌睡時(shí)會(huì)發(fā)出告警。

    依賴項(xiàng):

    • cv2

    • immutils

    • dlib

    • scipy

    算法

    每個(gè)眼睛使用 6個(gè) (x, y)坐標(biāo)表示,從眼睛的左角開始(正如你看見人時(shí)一樣), 然后沿著眼睛周圍順時(shí)針計(jì)算。

    機(jī)器學(xué)習(xí)開發(fā)者應(yīng)該收藏的 DIY 計(jì)算機(jī)視覺和深度學(xué)習(xí)項(xiàng)目


    條件

    檢查連續(xù) 20 幀圖像,如果眼睛長寬比小于 0.25,就發(fā)出告警。

    機(jī)器學(xué)習(xí)開發(fā)者應(yīng)該收藏的 DIY 計(jì)算機(jī)視覺和深度學(xué)習(xí)項(xiàng)目


    關(guān)系

    機(jī)器學(xué)習(xí)開發(fā)者應(yīng)該收藏的 DIY 計(jì)算機(jī)視覺和深度學(xué)習(xí)項(xiàng)目


    3. 使用 SoftMax 回歸進(jìn)行數(shù)字識(shí)別

    akshaybahadur21/Digit-Recognizer

    在 Github.com 上的機(jī)器學(xué)習(xí)分類器-數(shù)字識(shí)別

    https://github.com/akshaybahadur21/Digit-Recognizer

    在程序中利用 SoftMax 回歸代碼能夠幫助你區(qū)分不同的數(shù)字。你可以為 Python 安裝 Conda,它可以為你提供所有與 Python 有關(guān)相關(guān)庫的編譯環(huán)境。

    描述

    Softmax 回歸是邏輯回歸的推廣,我們可以用它來解決多分類問題,假設(shè)這些分類是互斥的(同義詞:多項(xiàng)邏輯推理,最大熵分類器,或多類邏輯回歸)。相反,我們?cè)诙诸悊栴}中通常使用邏輯回歸模型。

    機(jī)器學(xué)習(xí)開發(fā)者應(yīng)該收藏的 DIY 計(jì)算機(jī)視覺和深度學(xué)習(xí)項(xiàng)目


    Python 實(shí)現(xiàn)

    數(shù)據(jù)集使用 MNIST 數(shù)據(jù)集,同時(shí)圖像大小為 28*28,利用邏輯回歸、淺層神經(jīng)網(wǎng)絡(luò)和深層神經(jīng)網(wǎng)絡(luò)的方法將 0—9 進(jìn)行分類。 

    三個(gè)模型當(dāng)中最好的部分之一是使用 Numpy 函數(shù)庫,包括優(yōu)化,前向傳播和后向傳播。

    邏輯回歸:

    import numpy as np
    import matplotlib.pyplot as plt

    def softmax(z):
      z -= np.max(z)
      sm = (np.exp(z).T / np.sum(np.exp(z), axis=1))
      return sm


    def initialize(dim1, dim2):
      """
      :param dim: size of vector w initilazied with zeros
      :return:
      """
      w = np.zeros(shape=(dim1, dim2))
      b = np.zeros(shape=(10, 1))
      return w, b


    def propagate(w, b, X, Y):
      """
      :param w: weights for w
      :param b: bias
      :param X: size of data(no of features, no of examples)
      :param Y: true label
      :return:
      """
      m = X.shape[1]  # getting no of rows

      # Forward Prop
      A = softmax((np.dot(w.T, X) + b).T)
      cost = (-1 / m) * np.sum(Y * np.log(A))

      # backwar prop
      dw = (1 / m) * np.dot(X, (A - Y).T)
      db = (1 / m) * np.sum(A - Y)

      cost = np.squeeze(cost)
      grads = {"dw": dw,
               "db": db}
      return grads, cost


    def optimize(w, b, X, Y, num_iters, alpha, print_cost=False):
      """
      :param w: weights for w
      :param b: bias
      :param X: size of data(no of features, no of examples)
      :param Y: true label
      :param num_iters: number of iterations for gradient
      :param alpha:
      :return:
      """

      costs = []
      for i in range(num_iters):
          grads, cost = propagate(w, b, X, Y)
          dw = grads["dw"]
          db = grads["db"]
          w = w - alpha * dw
          b = b - alpha * db

          # Record the costs
          if i % 50 == 0:
              costs.append(cost)

          # Print the cost every 100 training examples
          if print_cost and i % 50 == 0:
              print("Cost after iteration %i: %f" % (i, cost))

      params = {"w": w,
                "b": b}

      grads = {"dw": dw,
               "db": db}

      return params, grads, costs


    def predict(w, b, X):
      """
      :param w:
      :param b:
      :param X:
      :return:
      """
      # m = X.shape[1]
      # y_pred = np.zeros(shape=(1, m))
      # w = w.reshape(X.shape[0], 1)

      y_pred = np.argmax(softmax((np.dot(w.T, X) + b).T), axis=0)
      return y_pred


    def model(X_train, Y_train, Y,X_test,Y_test, num_iters, alpha, print_cost):
      """
      :param X_train:
      :param Y_train:
      :param X_test:
      :param Y_test:
      :param num_iterations:
      :param learning_rate:
      :param print_cost:
      :return:
      """

      w, b = initialize(X_train.shape[0], Y_train.shape[0])
      parameters, grads, costs = optimize(w, b, X_train, Y_train, num_iters, alpha, print_cost)

      w = parameters["w"]
      b = parameters["b"]


      y_prediction_train = predict(w, b, X_train)
      y_prediction_test = predict(w, b, X_test)
      print("Train accuracy: {} %", sum(y_prediction_train == Y) / (float(len(Y))) * 100)
      print("Test accuracy: {} %", sum(y_prediction_test == Y_test) / (float(len(Y_test))) * 100)

      d = {"costs": costs,
           "Y_prediction_test": y_prediction_test,
           "Y_prediction_train": y_prediction_train,
           "w": w,
           "b": b,
           "learning_rate": alpha,
           "num_iterations": num_iters}

      # Plot learning curve (with costs)
      #costs = np.squeeze(d['costs'])
      #plt.plot(costs)
      #plt.ylabel('cost')
      #plt.xlabel('iterations (per hundreds)')
      #plt.title("Learning rate =" + str(d["learning_rate"]))
      #plt.plot()
      #plt.show()
      #plt.close()

      #pri(X_test.T, y_prediction_test)
      return d


    def pri(X_test, y_prediction_test):
      example = X_test[2, :]
      print("Prediction for the example is ", y_prediction_test[2])
      plt.imshow(np.reshape(example, [28, 28]))
      plt.plot()
      plt.show()

    淺層神經(jīng)網(wǎng)絡(luò)

    import numpy as np
    import matplotlib.pyplot as plt

    def softmax(z):
      z -= np.max(z)
      sm = (np.exp(z).T / np.sum(np.exp(z),axis=1))
      return sm


    def layers(X, Y):
      """
      :param X:
      :param Y:
      :return:
      """
      n_x = X.shape[0]
      n_y = Y.shape[0]
      return n_x, n_y


    def initialize_nn(n_x, n_h, n_y):
      """
      :param n_x:
      :param n_h:
      :param n_y:
      :return:
      """
      np.random.seed(2)
      W1 = np.random.randn(n_h, n_x) * 0.01
      b1 = np.random.rand(n_h, 1)
      W2 = np.random.rand(n_y, n_h)
      b2 = np.random.rand(n_y, 1)
      parameters = {"W1": W1,
                    "b1": b1,
                    "W2": W2,
                    "b2": b2}

      return parameters


    def forward_prop(X, parameters):
      W1 = parameters['W1']
      b1 = parameters['b1']
      W2 = parameters['W2']
      b2 = parameters['b2']

      Z1 = np.dot(W1, X) + b1
      A1 = np.tanh(Z1)
      Z2 = np.dot(W2, A1) + b2
      A2 = softmax(Z2.T)

      cache = {"Z1": Z1,
               "A1": A1,
               "Z2": Z2,
               "A2": A2}

      return A2, cache


    def compute_cost(A2, Y, parameters):
      m = Y.shape[1]
      W1 = parameters['W1']
      W2 = parameters['W2']
      logprobs = np.multiply(np.log(A2), Y)
      cost = - np.sum(logprobs) / m
      cost = np.squeeze(cost)

      return cost


    def back_prop(parameters, cache, X, Y):
      m = Y.shape[1]
      W1 = parameters['W1']
      W2 = parameters['W2']
      A1 = cache['A1']
      A2 = cache['A2']


      dZ2 = A2 - Y
      dW2 = (1 / m) * np.dot(dZ2, A1.T)
      db2 = (1 / m) * np.sum(dZ2, axis=1, keepdims=True)

      dZ1 = np.multiply(np.dot(W2.T, dZ2), 1 - np.square(A1))
      dW1 = (1 / m) * np.dot(dZ1, X.T)
      db1 = (1 / m) * np.sum(dZ1, axis=1, keepdims=True)

      grads = {"dW1": dW1,
               "db1": db1,
               "dW2": dW2,
               "db2": db2}

      return grads


    def update_params(parameters, grads, alpha):
      W1 = parameters['W1']
      b1 = parameters['b1']
      W2 = parameters['W2']
      b2 = parameters['b2']

      dW1 = grads['dW1']
      db1 = grads['db1']
      dW2 = grads['dW2']
      db2 = grads['db2']

      W1 = W1 - alpha * dW1
      b1 = b1 - alpha * db1
      W2 = W2 - alpha * dW2
      b2 = b2 - alpha * db2

      parameters = {"W1": W1,
                    "b1": b1,
                    "W2": W2,
                    "b2": b2}
      return parameters


    def model_nn(X, Y,Y_real,test_x,test_y, n_h, num_iters, alpha, print_cost):
      np.random.seed(3)
      n_x,n_y = layers(X, Y)
      parameters = initialize_nn(n_x, n_h, n_y)
      W1 = parameters['W1']
      b1 = parameters['b1']
      W2 = parameters['W2']
      b2 = parameters['b2']

      costs = []
      for i in range(0, num_iters):

          A2, cache = forward_prop(X, parameters)

          cost = compute_cost(A2, Y, parameters)
          grads = back_prop(parameters, cache, X, Y)
          if (i > 1500):
              alpha1 = 0.95*alpha
              parameters = update_params(parameters, grads, alpha1)
          else:
              parameters = update_params(parameters, grads, alpha)

          if i % 100 == 0:
              costs.append(cost)
          if print_cost and i % 100 == 0:
              print("Cost after iteration for %i: %f" % (i, cost))



      predictions = predict_nn(parameters, X)
      print("Train accuracy: {} %", sum(predictions == Y_real) / (float(len(Y_real))) * 100)
      predictions=predict_nn(parameters,test_x)
      print("Train accuracy: {} %", sum(predictions == test_y) / (float(len(test_y))) * 100)



      #plt.plot(costs)
      #plt.ylabel('cost')
      #plt.xlabel('iterations (per hundreds)')
      #plt.title("Learning rate =" + str(alpha))
      #plt.show()

      return parameters


    def predict_nn(parameters, X):
      A2, cache = forward_prop(X, parameters)
      predictions = np.argmax(A2, axis=0)
      return predictions

    以及最后的深層神經(jīng)網(wǎng)絡(luò):

    import numpy as np
    import matplotlib.pyplot as plt


    def softmax(z):
      cache = z
      z -= np.max(z)
      sm = (np.exp(z).T / np.sum(np.exp(z), axis=1))
      return sm, cache


    def relu(z):
      """
      :param z:
      :return:
      """
      s = np.maximum(0, z)
      cache = z
      return s, cache


    def softmax_backward(dA, cache):
      """
      :param dA:
      :param activation_cache:
      :return:
      """
      z = cache
      z -= np.max(z)
      s = (np.exp(z).T / np.sum(np.exp(z), axis=1))
      dZ = dA * s * (1 - s)
      return dZ


    def relu_backward(dA, cache):
      """
      :param dA:
      :param activation_cache:
      :return:
      """
      Z = cache
      dZ = np.array(dA, copy=True)  # just converting dz to a correct object.
      dZ[Z <= 0] = 0
      return dZ


    def initialize_parameters_deep(dims):
      """
      :param dims:
      :return:
      """

      np.random.seed(3)
      params = {}
      L = len(dims)

      for l in range(1, L):
          params['W' + str(l)] = np.random.randn(dims[l], dims[l - 1]) * 0.01
          params['b' + str(l)] = np.zeros((dims[l], 1))
      return params


    def linear_forward(A, W, b):
      """
      :param A:
      :param W:
      :param b:
      :return:
      """

      Z = np.dot(W, A) + b
      cache = (A, W, b)

      return Z, cache


    def linear_activation_forward(A_prev, W, b, activation):
      """
      :param A_prev:
      :param W:
      :param b:
      :param activation:
      :return:
      """
      if activation == "softmax":
          Z, linear_cache = linear_forward(A_prev, W, b)
          A, activation_cache = softmax(Z.T)

      elif activation == "relu":
          Z, linear_cache = linear_forward(A_prev, W, b)
          A, activation_cache = relu(Z)

      cache = (linear_cache, activation_cache)

      return A, cache


    def L_model_forward(X, params):
      """
      :param X:
      :param params:
      :return:
      """

      caches = []
      A = X
      L = len(params) // 2  # number of layers in the neural network

      # Implement [LINEAR -> RELU]*(L-1). Add "cache" to the "caches" list.
      for l in range(1, L):
          A_prev = A
          A, cache = linear_activation_forward(A_prev,
                                               params["W" + str(l)],
                                               params["b" + str(l)],
                                               activation='relu')
          caches.append(cache)

      A_last, cache = linear_activation_forward(A,
                                                params["W" + str(L)],
                                                params["b" + str(L)],
                                                activation='softmax')
      caches.append(cache)
      return A_last, caches


    def compute_cost(A_last, Y):
      """
      :param A_last:
      :param Y:
      :return:
      """

      m = Y.shape[1]
      cost = (-1 / m) * np.sum(Y * np.log(A_last))
      cost = np.squeeze(cost)  # To make sure your cost's shape is what we expect (e.g. this turns [[17]] into 17).
      return cost


    def linear_backward(dZ, cache):
      """
      :param dZ:
      :param cache:
      :return:
      """

      A_prev, W, b = cache
      m = A_prev.shape[1]

      dW = (1. / m) * np.dot(dZ, cache[0].T)
      db = (1. / m) * np.sum(dZ, axis=1, keepdims=True)
      dA_prev = np.dot(cache[1].T, dZ)

      return dA_prev, dW, db


    def linear_activation_backward(dA, cache, activation):
      """
      :param dA:
      :param cache:
      :param activation:
      :return:
      """

      linear_cache, activation_cache = cache

      if activation == "relu":
          dZ = relu_backward(dA, activation_cache)
          dA_prev, dW, db = linear_backward(dZ, linear_cache)

      elif activation == "softmax":
          dZ = softmax_backward(dA, activation_cache)
          dA_prev, dW, db = linear_backward(dZ, linear_cache)

      return dA_prev, dW, db


    def L_model_backward(A_last, Y, caches):
      """
      :param A_last:
      :param Y:
      :param caches:
      :return:
      """

      grads = {}
      L = len(caches)  # the number of layers
      m = A_last.shape[1]
      Y = Y.reshape(A_last.shape)  # after this line, Y is the same shape as A_last

      dA_last = - (np.divide(Y, A_last) - np.divide(1 - Y, 1 - A_last))
      current_cache = caches[-1]
      grads["dA" + str(L)], grads["dW" + str(L)], grads["db" + str(L)] = linear_activation_backward(dA_last,
                                                                                                    current_cache,
                                                                                                    activation="softmax")

      for l in reversed(range(L - 1)):
          current_cache = caches[l]

          dA_prev_temp, dW_temp, db_temp = linear_activation_backward(grads["dA" + str(l + 2)], current_cache,
                                                                      activation="relu")
          grads["dA" + str(l + 1)] = dA_prev_temp
          grads["dW" + str(l + 1)] = dW_temp
          grads["db" + str(l + 1)] = db_temp

      return grads


    def update_params(params, grads, alpha):
      """
      :param params:
      :param grads:
      :param alpha:
      :return:
      """

      L = len(params) // 2  # number of layers in the neural network

      for l in range(L):
          params["W" + str(l + 1)] = params["W" + str(l + 1)] - alpha * grads["dW" + str(l + 1)]
          params["b" + str(l + 1)] = params["b" + str(l + 1)] - alpha * grads["db" + str(l + 1)]

      return params


    def model_DL( X, Y, Y_real, test_x, test_y, layers_dims, alpha, num_iterations, print_cost):  # lr was 0.009
      """
      Implements a L-layer neural network: [LINEAR->RELU]*(L-1)->LINEAR->SIGMOID.
      Arguments:
      X -- data, numpy array of shape (number of examples, num_px * num_px * 3)
      Y -- true "label" vector (containing 0 if cat, 1 if non-cat), of shape (1, number of examples)
      layers_dims -- list containing the input size and each layer size, of length (number of layers + 1).
      alpha -- learning rate of the gradient descent update rule
      num_iterations -- number of iterations of the optimization loop
      print_cost -- if True, it prints the cost every 100 steps
      Returns:
      params -- params learnt by the model. They can then be used to predict.
      """

      np.random.seed(1)
      costs = []  # keep track of cost

      params = initialize_parameters_deep(layers_dims)

      for i in range(0, num_iterations):

          A_last, caches = L_model_forward(X, params)
          cost = compute_cost(A_last, Y)
          grads = L_model_backward(A_last, Y, caches)

          if (i > 800 and i<1700):
              alpha1 = 0.80 * alpha
              params = update_params(params, grads, alpha1)
          elif(i>=1700):
              alpha1 = 0.50 * alpha
              params = update_params(params, grads, alpha1)
          else:
              params = update_params(params, grads, alpha)

          if print_cost and i % 100 == 0:
              print("Cost after iteration %i: %f" % (i, cost))
          if print_cost and i % 100 == 0:
              costs.append(cost)
      predictions = predict(params, X)
      print("Train accuracy: {} %", sum(predictions == Y_real) / (float(len(Y_real))) * 100)
      predictions = predict(params, test_x)
      print("Test accuracy: {} %", sum(predictions == test_y) / (float(len(test_y))) * 100)

      #plt.plot(np.squeeze(costs))
      #plt.ylabel('cost')
      #plt.xlabel('iterations (per tens)')
      #plt.title("Learning rate =" + str(alpha))
      #plt.show()

      return params


    def predict(parameters, X):
      A_last, cache = L_model_forward(X, parameters)
      predictions = np.argmax(A_last, axis=0)
      return predictions

    通過攝像頭寫入

    運(yùn)行程序 python Dig-Rec.py

    python Dig-Rec.py

    通過攝像頭展現(xiàn)傳入的代碼

    運(yùn)行程序 python Digit-Recognizer.py

    python Digit-Recognizer.py

    Devanagiri Recognizer

    akshaybahadur21/Devanagiri-Recognizer

    Devanagiri-Recognizer - 使用 convnetgithub.com 的印地語字母表分類器

    這段代碼可以幫助你使用 Convnets 來分類不同的印地文字母(Devanagiri)。

    https://github.com/akshaybahadur21/Devanagiri-Recognizer

    你可以為 Python 安裝 Conda,它可以為你提供所有與 Python 有關(guān)相關(guān)庫的編譯環(huán)境。

    使用的技術(shù)

    我使用了卷積神經(jīng)網(wǎng)絡(luò),Tensorflow 框架以及 Keras API 來提供高級(jí)的抽象。

    結(jié)構(gòu)

    卷積層 → 池化層 → 卷積層 → 池化層 → 全連接層 →Softmax 回歸層 → 分類

    其他需要注意的事項(xiàng):

    1. 你還可以增加卷積層。

    2. 增加正則化防止過擬合。

    3. 增加圖片的數(shù)量來提高準(zhǔn)確率。

    Python 實(shí)現(xiàn)

    DHCD (Devnagari Character Dataset)數(shù)據(jù)集的所有圖片尺寸都是 32 * 32 并且都用于卷積神經(jīng)網(wǎng)絡(luò)。

    運(yùn)行程序 python Dev-Rec.py

    python Dev-Rec.py

    4. 使用 FaceNet 做面部識(shí)別

    akshaybahadur21/ Facial-Recognition-using-FaceNet

    https://github.com/akshaybahadur21/Facial-Recognition-using-Facenet

    這段程序利用 facenet 網(wǎng)絡(luò)幫助你做面部識(shí)別(https://arxiv.org/pdf/1503.03832.pdf). Facenets 的概念最初是在一篇研究論文中提出的。主要概念討論了三重?fù)p失函數(shù)來比較不同人的圖像。這個(gè)概念使用的是 Inception 網(wǎng)絡(luò),來自于 DeepingLearning.ai社區(qū)的 frutils.py 文件。在我的網(wǎng)絡(luò)當(dāng)中我增加了一些函數(shù)來提高穩(wěn)定性和更好的檢測(cè)。

    必備的代碼庫

    你可以為 Python 安裝 Conda,它可以為你提供所有與 Python 有關(guān)相關(guān)庫的編譯環(huán)境,以下是你可能需要的庫:

    • numpy

    • matplotlib

    • cv2

    • keras

    • dlib

    • h5py

    • scipy

    描述

    面部識(shí)別系統(tǒng)是能夠從數(shù)字圖像或者視頻中識(shí)別或驗(yàn)證人面部的技術(shù)。構(gòu)建面部識(shí)別系統(tǒng)這里有很多種方法,但是通常,他們是通過比較圖片中選擇的面部特征和數(shù)據(jù)集中的特征來進(jìn)行判斷。

    添加的功能

    • 只有當(dāng)你的眼睛睜開是才能偵測(cè)到面部。

    • 使用 dlib 庫的面部對(duì)齊功能在實(shí)時(shí)流媒體上進(jìn)行有效的預(yù)測(cè)。

    Python 實(shí)現(xiàn)

    • 使用 Inception Network 來搭建網(wǎng)絡(luò)

    • 源論文來自于Google-Facenet

    程序

    1. 如果你想訓(xùn)練網(wǎng)絡(luò),請(qǐng)運(yùn)行 Train-inception.py, 若你不想訓(xùn)練網(wǎng)絡(luò),因?yàn)槲以缫呀?jīng)訓(xùn)練好了一個(gè)網(wǎng)絡(luò),那么你可以下載該文件到本地運(yùn)行 face-rec_Google.h5 。

    2. 現(xiàn)在你已經(jīng)有了一個(gè)數(shù)據(jù)集,里面包含了很多圖片。 點(diǎn)擊文件 /images來折疊這些照片。您可以將圖片粘貼到此處,也可以使用網(wǎng)絡(luò)攝像頭進(jìn)行點(diǎn)擊。你可以運(yùn)行該文件 create-face.py 來做到這一點(diǎn),圖片都存儲(chǔ)在文件夾 /incept 中。你必須手動(dòng)粘貼到文件夾中 /images folder。

    3. 運(yùn)行程序 rec-feat.py 來實(shí)現(xiàn)所有的功能。

    5. Emojinator

    akshaybahadur21/ Emojinator

    Emojinator -  Github 上一個(gè)簡單的表情分類器。

    https://github.com/akshaybahadur21/Emojinator

    這些代碼能夠幫助你區(qū)分不同的表情。到目前為止,我們只支持手的表情。

    必備的代碼庫

    你可以為 Python 安裝 Conda,它可以為你提供所有與 Python 有關(guān)相關(guān)庫的編譯環(huán)境,以下是你可能需要的庫:

    • numpy

    • matplotlib

    • cv2

    • keras

    • dlib

    • h5py

    • scipy

    描述

    表情符號(hào)是電子信息和網(wǎng)頁中使用的表意符號(hào)和微笑符號(hào)。表情符號(hào)存在于不同的類型中,包括面部表情、常見物體、地點(diǎn)和天氣類型以及動(dòng)物。它們很像表情符號(hào),但表情符號(hào)是真實(shí)的圖片,而不是印刷圖。

    功能

    1. 利用過濾器來檢測(cè)手。

    2. 利用 CNN 來訓(xùn)練模型。

    Python 實(shí)現(xiàn)

    使用卷積神經(jīng)網(wǎng)絡(luò)

    過程

    1. 首先,你需要一個(gè)手勢(shì)圖片的數(shù)據(jù)庫,你可以運(yùn)行該文件來獲得  CreateGest.py。輸入手勢(shì)名稱,你可以看到兩個(gè)框架。按「C」進(jìn)行拍攝。看看輪廓框架并調(diào)整你的手,以確保你捕捉到你的手的特征。一個(gè)手勢(shì)可以拍 1200 張照片。試著在框架內(nèi)移動(dòng)你的手,以確保你的模型在訓(xùn)練過程當(dāng)中不會(huì)過擬合。

    2. 重復(fù)以上操作,保證你可以獲得所有你想要的特征。

    3. 運(yùn)行程序 CreateCSV.py 來將圖片轉(zhuǎn)換成 CSV 文件。

    4. 如果你想訓(xùn)練模型,則運(yùn)行程序 『TrainEmojinator.py』

    5. 最后,運(yùn)行程序 Emojinator.py ,通過攝像頭來測(cè)試你的模型

    作者

    Akshay Bahadur 和 Raghav Patnecha.

    結(jié)語

    我只能說我對(duì)這些項(xiàng)目感到難以置信,所有人都可以在計(jì)算機(jī)上運(yùn)行它們,或者在 Deep Cognition 的平臺(tái)上運(yùn)行它們,如果你不想安裝任何東西,它可以在線運(yùn)行。

    我想感謝 Akshay 和他的朋友們?yōu)殚_放源代碼貢獻(xiàn)力量以及所有其他將來的貢獻(xiàn)。嘗試一下,運(yùn)行它們,并獲得靈感。這只是 DL 和 CV 可以做的令人驚嘆的事情的一個(gè)小例子,取決于你如何將它變成可以幫助世界變得更好的地方。  

    永不放棄,我們需要每個(gè)人都對(duì)許多不同的事情感興趣。我認(rèn)為我們可以改善世界,改善我們的生活,我們的工作方式,思考和解決問題,如果我們引導(dǎo)現(xiàn)在的所有資源,使這些知識(shí)領(lǐng)域共同努力,實(shí)現(xiàn)更大的利益,我們可以在世界和我們的生活中產(chǎn)生巨大的積極影響。

    我們需要更多的人感興趣,更多課程,更專業(yè)化,更熱情。我們需要你:)

    感謝您閱讀到這,希望您可以在這里發(fā)現(xiàn)更多有意思的是:)

    如果你有任何問題,請(qǐng)?jiān)?Twitter 和 LinkedIn 上聯(lián)系我:

    • Twitter

      Favio Vázquez (@FavioVaz) 

    • LinkedIn:

      Favio Vázquez?—?Principal Data Scientist?—?OXXO | LinkedIn

    機(jī)器學(xué)習(xí)開發(fā)者應(yīng)該收藏的 DIY 計(jì)算機(jī)視覺和深度學(xué)習(xí)項(xiàng)目

    雷峰網(wǎng)原創(chuàng)文章,未經(jīng)授權(quán)禁止轉(zhuǎn)載。詳情見轉(zhuǎn)載須知

    機(jī)器學(xué)習(xí)開發(fā)者應(yīng)該收藏的 DIY 計(jì)算機(jī)視覺和深度學(xué)習(xí)項(xiàng)目

    分享:
    相關(guān)文章

    知情人士

    AI研習(xí)社(yanxishe.com)譯站頻道,傳播前沿人工智能知識(shí),讓語言不再成為學(xué)習(xí)知識(shí)的門檻。(原雷鋒字幕組)
    當(dāng)月熱門文章
    最新文章
    請(qǐng)?zhí)顚懮暾?qǐng)人資料
    姓名
    電話
    郵箱
    微信號(hào)
    作品鏈接
    個(gè)人簡介
    為了您的賬戶安全,請(qǐng)驗(yàn)證郵箱
    您的郵箱還未驗(yàn)證,完成可獲20積分喲!
    請(qǐng)驗(yàn)證您的郵箱
    立即驗(yàn)證
    完善賬號(hào)信息
    您的賬號(hào)已經(jīng)綁定,現(xiàn)在您可以設(shè)置密碼以方便用郵箱登錄
    立即設(shè)置 以后再說