發表文章

目前顯示的是 5月, 2019的文章

TensorRT part1 UFF Converter

圖片
在TensorRT使用前須要把先前的freezing graph轉換成.UFF(Universal File Format) 系統: ubuntu 16.04 LTS 硬體裝置:64-bit、GTX 680M 建議使用 English(United States)做為系統環境的語言 [ 純文字模式  中才不會因為路徑打不出中文而卡關-- Ubuntu主要分為兩個模式:   1. 純文字模式/console:進入方式 Ctrl+Alt+F1~F6   2. 視窗模式:進入方式 Ctrl+Alt+F7~F12 ] 安裝 Nvidia Driver + cuda 8.0 + TensorRT 4.0 不確定是不是真的需要安裝driver 與 cuda 畢竟我的目的只是要轉檔(因為不支援windows😢) First. 安裝Dirver 安裝Dirver時可能遇到 要求停用 X Server 這時需要切換到純文字模式且關閉X server command: sudo /etc/init.d/gdm stop    or  sudo /etc/init.d/kdm stop sudo  sh NVIDIA_Linux-XXXXXXXXXXX.run Second. 安裝TensorRT4.0裡的 uff-convert-tf 如果無法順利安裝,可在var中找到分散tensorRT安裝檔,只需要順利將uff-convert-tf_XXX.deb安裝就可以了 Third. 安裝 tensorflow # 安裝pip3 sudo apt-get update sudo apt-get install python3-pip #安裝 tensorflow-gpu sudo pip install tensorflow-gpu #安裝 tensoflow(cpu) sudo pip3 install tensorflow Fourth. convert pb to uff Command: python3 import tensorflow import uff uff.from_tensorflow_frozen_model(" filepath.pb ",outp

freezing Keras model

圖片
為了將model提供其他應用程式做使用 目標 我會將keras 轉換成 tensorflow 的 pb檔是為了在tensorRT中建置model,在tensorRT中需要再將.pb檔轉成.uff,才能提供給TensorRT使用,因為tensorRT支援的關係,目前需要在Linux的作業系統之下才能將.pb檔轉成.uff檔。 概要: Keras framework提供將model儲存成.h5檔的function,其中的內容包含自訂的 neural network 的graph,與訓練之後的參數(weights),也可以單獨儲存weights,如果只有保留weights則需要在Tensorflow中重新建立graph,並將weight帶入,但這方法非常沒有效率。 於是將訓練好的model freezing,不能再更改weights,也就是不能在訓練,並且將單獨儲存的weights(.ckpt檔.meta檔)重建出graph,最後輸出.pb。 需求: 1. 安裝keras、tensorflow 2. TensorBoard(要用來查詢output的名稱) 實作: 1.將import 的來源要改成 tensorflow.keras ex. from keras import Conv2D ->tensorflow.keras.layers import Convolution2D def freeze_graph(model_dir, output_node_names):   """Extract the sub graph defined by the output nodes and convert   all its variables into constant   Args:       model_dir: the root folder containing the checkpoint state file       output_node_names: a string, containing all the output node's names,                           comma sepa

tensorflow keras20190515

圖片
期望複製出論文中的 Recurrent convolution neural network 目前的NN只有convolution、max pooling、upsampling這些方法建構出的類神經網路訓練後結果並不理想。 ■. 以概觀來看,場景中的亮度,在陰影的部分有正確還原出,但在顏色的部分彩度仍有缺失 ■ . 細部的部分,銜接點有很明顯接線,場景中的細節在還原後消失了,可能原因是被當成noise去掉了。 *. 目標1:更精確地取出影像的特徵點,在不取noise的狀態之下 *. 目標2:為了找出 neural network中的問題,將每一層的feature map畫出,以便找出原因 Monte Carlo Path Tracing ray tracing 於1980年,Whitted提出在電腦中產生場景影像的方法,可以產生鏡面反射、折射、陰影,但無法產生全域照明的效果。 Kajiya於1986提出 rendering equation與path tracing ,rendering equation用來表示光的物理現象,物體x點的位置2對於某方向的radiance,與入射光的radiance,Li(x,wi)表示入射光的radiance,fr(x,wi,wo)是表示BRD也就是入射光的radiance對反射光的radiance的影響。而在path tracing之後許多人提出以近似值的計算提高繪製的效率,像是bidirection lighting、photon mapping等。 在1984年Cook將monte carlo演算法使用到ray tracing中,模擬出了soft shadow、金屬光澤、景深等效果。其中一種Unbiased的monte carlo演算法概念為,光從camera出發,與物體相交十依據物體的材質產生一個方向並繼續追蹤場景,直到打到光源或打到背景,最後計算此pixel的顏色值。會受到取樣的影響,因為不一定會打到光源,則會產生雜訊。 參考: http://www.jun.ninja/projects/gcg/report.pdf https://yiusay.net/index.html#graphics&1 direction Lighting 由眼睛開始追蹤直到Light ,就直接畫出 indirection ligh