机器学习图像源代码_使用带有代码的机器学习进行快速房地产图像分类
機器學(xué)習(xí)圖像源代碼
RoomNet is a very lightweight (700 KB) and fast Convolutional Neural Net to classify pictures of different rooms of a house/apartment with 88.9 % validation accuracy over 1839 images. I have written this in python and TensorFlow.
RoomNet是一種非常輕巧的( 700 KB )快速快速的卷積神經(jīng)網(wǎng)絡(luò),可對房屋/公寓不同房間的圖片進行分類,對1839張圖片的驗證準確性為88.9% 。 我已經(jīng)用python和TensorFlow編寫了這個。
Btw, I made the artwork and yes, I’m actually not in 3rd grade despite tempting popular opinions stemming from it.
順便說一句,我制作了藝術(shù)品,是的,盡管我引誘了公眾的意見,但實際上我還不是三年級。
This is a custom architecture I designed to classify an input image into one of the following 6 classes (in order of their class IDs) -
這是我設(shè)計的自定義體系結(jié)構(gòu),旨在將輸入圖像分類為以下6個類之一(按其類ID的順序)-
Backyard-0, Bathroom-1, Bedroom-2, Frontyard-3, Kitchen-4, LivingRoom-5
后院 -0, 浴室 -1, 臥室 -2, 前院 -3, 廚房 -4, 客廳 -5
Photo credits from left to right in clockwise manner — Photo by Chastity Cortijo on Unsplash (Bathroom), Photo by Roberto Nickson on Unsplash (Bedroom), Photo by Jason Briscoe on Unsplash (Kitchen), Photo by Shaun Montero on Unsplash (Backyard), Photo by Roberto Nickson on Unsplash (Living Room), Photo by Roberto Nickson on Unsplash (Frontyard)照片信用從左到右以順時針的方式—照片作者Chastity Cortijo在Unsplash (浴室),由Roberto Nickson在Unsplash (臥室),照片由Jason Briscoe在Unsplash (廚房),照片由Shaun Montero在Unsplash (后院), 羅伯托·尼克森在《 Unsplash》 (起居室)上的照片, 羅伯托·尼克森在《 Unsplash》 (前院)上的照片建筑積木- (Architecture Building Blocks -)
These blocks are used to construct the final neural net. They’re comprised of basic elemental neural layers like convolution, average pooling, and batch normalization.
這些塊用于構(gòu)建最終的神經(jīng)網(wǎng)絡(luò)。 它們由卷積,平均池化和批歸一化等基本元素神經(jīng)層組成。
RoomNet Convolutional Block. This is the most basic blockRoomNet卷積塊。 這是最基本的塊 RoomNet Residual Block. It composes of the convolution block described previously.RoomNet殘留塊。 它由前面描述的卷積塊組成。 RoomNet Dense Block. This will be doing the classification from the extracted image features at the end.RoomNet密集塊。 最后將根據(jù)提取的圖像特征進行分類。完整的網(wǎng)絡(luò)架構(gòu)- (Full Network Architecture -)
Using the building blocks described above, presented below is the full neural net architecture with the relevant arguments.
使用上述構(gòu)建模塊,下面介紹的是帶有相關(guān)參數(shù)的完整神經(jīng)網(wǎng)絡(luò)體系結(jié)構(gòu)。
The code to train and deploy this can be found on GitHub at —
可以在GitHub上找到用于訓(xùn)練和部署此代碼的代碼-
開箱即用的推論- (Out-of-box Inference -)
Optimized inference code in infer.py. Refer to the short code in the main method calling the classify_im_dir method.
優(yōu)化了infer.py中的推理代碼。 請參考main方法中調(diào)用classify_im_dir方法的簡短代碼。
培訓(xùn)- (Training -)
Validation Accuracy驗證準確性- Input image size = 224 x 224 (tried 300 x 300, 600 x 600) 輸入圖像大小= 224 x 224(嘗試300 x 300、600 x 600)
Softmax Cross Entropy Loss used with L2 Weight normalization
L2權(quán)重歸一化使用的Softmax交叉熵損失
Dropout varied from 0 (initially) to 0.3 (intermittently near the end of training). Dropout layers placed after every block.
輟學(xué)率從0(最初)到0.3(在訓(xùn)練結(jié)束時間歇性地)變化。 在每個塊之后放置輟學(xué)層。
Batch Normalization moving means & vars were frozen when being trained with dropout.
在進行輟學(xué)訓(xùn)練時, 批次歸一化移動工具和變量被凍結(jié)。
Adam Optimizer used with exponential learning rate decay.
Adam Optimizer用于指數(shù)學(xué)習(xí)率衰減。
Initially trained with in-batch computation of BatchNorm moving means/vars. Followed this by training net, by disabling this computation and using frozen means/vars during training. Resulted in ~20% immediate jump in validation accuracy (noticeable around train step 150,000). I’ll be publishing another article delving into this phenomenon shortly.
最初使用BatchNorm移動工具/變量的批內(nèi)計算進行訓(xùn)練。 其次是訓(xùn)練網(wǎng),在訓(xùn)練過程中禁用此計算并使用凍結(jié)的均值/變量。 導(dǎo)致驗證準確性立即提高約20% (在火車第150,000步左右明顯)。 不久我將發(fā)表另一篇文章探討這種現(xiàn)象。
- Batch Size varied from 8 (in the beginning) to 45 (towards training end) as — 8 -> 32 -> 40 -> 45 批次大小從8(開始時)到45(訓(xùn)練結(jié)束時)為— 8-> 32-> 40-> 45
- Asynchronous Data Reader designed with a Queue based architecture that allows for quick data I/O during training even with large batch sizes. 異步數(shù)據(jù)讀取器采用基于隊列的體系結(jié)構(gòu)設(shè)計,即使批量較大,也可以在訓(xùn)練期間快速進行數(shù)據(jù)I / O。
轉(zhuǎn)換為推理優(yōu)化版本- (Conversion to Inference Optimized Version -)
- Discarded all backpropagation/training related compute node from the Tensorflow Graph. 從Tensorflow圖中丟棄所有與反向傳播/訓(xùn)練相關(guān)的計算節(jié)點。
- Model size reduced from ~2 MB to ~800 KB. 模型大小從?2 MB減少到?800 KB。
network.py contains class defining the model called “RoomNet”
network.py包含定義稱為“ RoomNet”的模型的類
- The output is an excel file mapping each image path to its label. There is also a provision to split an input directory to directories corresponding to the class names and automatically fill the relevant image in its respective directory. 輸出是一個將每個圖像路徑映射到其標簽的excel文件。 還提供了將輸入目錄拆分為與類名稱相對應(yīng)的目錄,并自動在其相應(yīng)目錄中填充相關(guān)圖像的條款。
培訓(xùn)環(huán)境- (Training Environment -)
- Training done using Tensorlfow + CUDA 10.0 + cuDNN on NVIDIA GTX 1070 laptop grade GPU with 8GB of GPU memory 使用Tensorlfow + CUDA 10.0 + cuDNN在具有8GB GPU內(nèi)存的NVIDIA GTX 1070筆記本電腦級GPU上完成培訓(xùn)
- Compute system used is an Alienware m17 r4 laptop. 使用的計算系統(tǒng)是Alienware m17 r4筆記本電腦。
- CPU used is an Intel Core i7–6700HQ with 8 logical cores at 2.6 GHz of base speed (turbo boost to ~3.3 GHz) 使用的CPU是Intel Core i7-6700HQ,具有8個邏輯內(nèi)核,基本速度為2.6 GHz(渦輪增壓提升至?3.3 GHz)
- The number of training steps from scratch to reach best model is 157,700. 從頭開始到達到最佳模型的培訓(xùn)步驟數(shù)為157,700。
- Time spent on training — ~48 hours 培訓(xùn)時間–約48小時
嘗試過的先前方法- (Previous Approaches tried -)
- Tried training the final dense NASnet mobile but accuracy never crosses 60%. 嘗試訓(xùn)練最終的密集NASnet移動設(shè)備,但準確性從未超過60%。
- Tried the same with InceptionV3 but convergence takes too damn long. 與InceptionV3進行了相同的嘗試,但是收斂時間太長了。
性能圖- (Performance Plots -)
驗證類F分數(shù) (Validation Class-wise F-Score)
F-Score is the harmonic mean of precision and recall.
F分數(shù)是精度和查全率的諧波平均值。
驗證類精度 (Validation Class-wise Precision)
驗證逐級召回 (Validation Class-wise Recall)
If you found this helpful, feel free to follow me for more upcoming articles :)
如果您認為這有幫助,請隨時關(guān)注我以獲取更多即將發(fā)表的文章:)
I’m the editor of the following publication which publishes Tech articles related to the usage of AI & ML in digital mapping of the Earth. Feel free to follow to stay updated :)
我是以下出版物的編輯,該出版物發(fā)表有關(guān)在地球數(shù)字地圖中使用AI和ML的技術(shù)文章。 隨時關(guān)注以保持更新:)
我的個人資料- (My Profiles-)
附加功能— (Extras —)
演示地址
Twitch🤪🤡Twitch上住我I’m also a musician. Here is one of the vocal covers off of my SoundCloud profile.
我也是音樂家。 這是我的SoundCloud個人資料的主要聲音之一。
演示地址
Thank you :)
謝謝 :)
翻譯自: https://towardsdatascience.com/fast-real-estate-image-classification-using-machine-learning-with-code-32e0539eab96
機器學(xué)習(xí)圖像源代碼
總結(jié)
以上是生活随笔為你收集整理的机器学习图像源代码_使用带有代码的机器学习进行快速房地产图像分类的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 梦到同事被蛇咬是什么意思
- 下一篇: COVID-19和世界幸福报告数据告诉我