图像分类数据库_图像分类器-使用僧侣库对房屋房间类型进行分类
圖像分類數據庫
This article is a tutorial on how to use the Monk library to classify house room types like the living room, dining room, etc.
本文是有關如何使用Monk庫對房屋房間類型(例如客廳,飯廳等)進行分類的教程。
A detailed tutorial is available on GitHub.
GitHub上有詳細的教程。
關于數據集 (About the dataset)
- The dataset contains a total of 145436 images divided into seven classes namely, ‘Exterior’, ‘bedroom’, ‘kitchen’, ‘living_room’, ‘Interior’, ‘bathroom’, ‘dining_room’. 數據集包含總共145436張圖像,分為7類,即“外部”,“臥室”,“廚房”,“客廳”,“內部”,“浴室”,“餐廳”。
 It can be downloaded from here.
可以從這里下載。
關于僧侶圖書館和僧侶如何使圖像分類容易 (About Monk Library and How does Monk make image classification easy)
- Write less code and create an end to end applications. 編寫更少的代碼并創建端到端應用程序。
 - Learn only one syntax and create applications using any deep learning library — PyTorch, Mxnet, Keras, TensorFlow, etc. 使用任何深度學習庫(PyTorch,Mxnet,Keras,TensorFlow等)僅學習一種語法并創建應用程序。
 - Manage your entire project easily with multiple experiments. 通過多個實驗輕松管理整個項目。
 
該庫是為誰而建的 (For whom this library is built)
- Students: Seamlessly learn computer vision using our comprehensive study road-maps. 學生:使用我們全面的學習路線圖無縫學習計算機視覺。
 - Researchers and Developers: Create and Manage multiple deep learning projects. 研究人員和開發人員:創建和管理多個深度學習項目。
 - Competition participants on Kaggle, Codalab, HackerEarth, AiCrowd, etc. Kaggle,Codalab,HackerEarth,AiCrowd等競賽參與者。
 
目錄 (Table of contents)
2. Using the pre-trained model for part of house classification dataset
2.將預訓練模型用于房屋分類數據集的一部分
3. Training a classifier from scratch
3.從頭開始訓練分類器
Train a part of house classifier using ResNet variants
使用ResNet變體訓練房屋分類器的一部分
Understand what all differences happen when switching between ResNets variants.
了解在ResNets變體之間切換時發生的所有差異。
Understand a bigger and deeper network not always means better results
了解更大更深的網絡并不總是意味著更好的結果
For this experiment, you will be using mxnet backend
對于本實驗,您將使用mxnet后端
4. Conclusions.
4。結論。
1.安裝和尚 (1. Installing Monk)
#using cuda10.0 download monk using following commandpip install -U monk-gluon-cuda100For more ways to install visit Monk Library.
有關更多安裝方式的信息,請訪問Monk Library 。
2.使用預訓練的模型進行演示 (2. Using a pre-trained model for the demo)
First, download the pre-trained models from google drive.
首先,從Google Drive下載預訓練的模型。
! wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=10SrowcOJp8GWqEB21BfCIinqUCHS7PMv' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=10SrowcOJp8GWqEB21BfCIinqUCHS7PMv" -O cls_house_scene_trained.zip && rm -rf /tmp/cookies.txtThe above will download the zip file of pre-trained models and name them as cls_house_scene_trained.zip. Now we have to unzip the file.
上面的代碼將下載預訓練模型的zip文件,并將其命名為cls_house_scene_trained.zip。 現在我們必須解壓縮文件。
! unzip -qq cls_house_scene_trained.zipImporting monk.gluon_prototype for working with the monk library.
導入monk.gluon_prototype 與和尚圖書館一起工作。
#Using mxnet-gluon backend# When installed using pipfrom monk.gluon_prototype import prototypeLet’s load the model in infer mode to classify the demo data.
讓我們以推斷模式加載模型以對演示數據進行分類。
# Load project in inference modegtf = prototype(verbose=1);gtf.Prototype("Task", "gluon_resnet18_v1_train_all_layers", eval_infer=True);
推斷一些樣品 (Infer on some samples)
img_name = "workspace/test/2.jpg"predictions = gtf.Infer(img_name=img_name);
from IPython.display import Image
Image(filename=img_name, height=300, width=300)img_name = "workspace/test/3.jpg"
predictions = gtf.Infer(img_name=img_name);
from IPython.display import Image
Image(filename=img_name, height=300, width=300)img_name = "workspace/test/6.jpg"
predictions = gtf.Infer(img_name=img_name);
from IPython.display import Image
Image(filename=img_name, height=300, width=300)
For more examples visit the notebook.
有關更多示例,請訪問筆記本 。
3. 從頭開始訓練自定義分類器 (3. Training custom classifier from scratch)
什么是ResNet? (What is ResNet?)
Points from https://towardsdatascience.com/an-overview-of-resnet-and-its-variants-5281e2f56035
來自https://towardsdatascience.com/an-overview-of-resnet-and-its-variants-5281e2f56035的點
- The core idea of ResNet is introducing a so-called “identity shortcut connection” that skips one or more layers- The deeper model should not produce a training error higher than its shallower counterparts.
- solves the problem of vanishing gradients as network depth increasedResNet18 ArchitectureResNet18體系結構
即將到來的內容 (Upcoming contents)
1.加載數據集 (1. Loading the Dataset)
Dataset Credits: https://omidpoursaeed.github.io/publication/vision-based-real-estate-price-estimation/
數據集積分: https : //omidpoursaeed.github.io/publication/vision-based-real-estate-price-estimation/
Step-1: Downloading the dataset.
步驟1:下載數據集。
! wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=0BxDIywue_VABY1dRcFVvZ3BodnM' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=0BxDIywue_VABY1dRcFVvZ3BodnM" -O dataset.zip && rm -rf /tmp/cookies.txtStep-2: Unzipping the dataset.
步驟2:解壓縮數據集。
! unzip -qq dataset.zip2.使用resnet18_v1(僅訓練最后一層)體系結構訓練模型以進行遷移學習。 (2. Train model using resnet18_v1(training only last layer) architecture for transfer learning.)
Step-1: Load experiment and insert data. For more details visit.
步驟1:加載實驗并插入數據。 有關更多詳細信息, 請訪問 。
# Load experimentmonk_gln = prototype(verbose=1);monk_gln.Prototype("Task", "gluon_resnet18_v1");# Insert data and set params in default modemonk_gln.Default(dataset_path="Train",
model_name="resnet18_v1",
freeze_base_network=True,
num_epochs=10);
Step-2: Training the model.
步驟2:訓練模型。
#Start Trainingmonk_gln.Train();3.使用resnet18_v1(訓練所有層)體系結構訓練模型以進行遷移學習。 (3. Train model using resnet18_v1(training all the layers) architecture for transfer learning.)
Step-1: Load experiment and insert data. For more details visit. Parameter freeze_base_network will be set to false to train all the layers.
步驟1:加載實驗并插入數據。 有關更多詳細信息, 請訪問 。 參數freeze_base_network 將設置為false以訓練所有圖層。
# Load experimentmonk_gln = prototype(verbose=1);monk_gln.Prototype("Task", "gluon_resnet18_v1_train_all_layers");# Insert data and set params in default modemonk_gln.Default(dataset_path="Train",
model_name="resnet18_v1",
freeze_base_network=False,
num_epochs=10);
Step-2: Training the model.
步驟2:訓練模型。
#Start Trainingmonk_gln.Train();4.使用resnet18_v2(僅訓練最后一層)體系結構訓練模型以進行遷移學習。 (4. Train model using resnet18_v2(training only last layer) architecture for transfer learning.)
Step-1: Load experiment and insert data. For more details visit.
步驟1:加載實驗并插入數據。 有關更多詳細信息, 請訪問 。
# Load experimentmonk_gln = prototype(verbose=1);
monk_gln.Prototype("Task", "gluon-resnet18_v2");# Insert data and set params in default modemonk_gln.Default(dataset_path="Train",
model_name="resnet18_v2",
freeze_base_network=True,
num_epochs=10);
Step-2: Training the model.
步驟2:訓練模型。
#Start Trainingmonk_gln.Train()5.使用resnet34_v1(僅訓練最后一層) 體系結構來訓練模型以 進行遷移學習。 (5. Train model using resnet34_v1(training only last layer) architecture for transfer learning.)
Step-1: Load experiment and insert data. For more details visit.
步驟1:加載實驗并插入數據。 有關更多詳細信息, 請訪問 。
# Load experimentmonk_gln = prototype(verbose=1);
monk_gln.Prototype("Task", "gluon-resnet18_v2");# Insert data and set params in default modemonk_gln.Default(dataset_path="Train",
model_name="resnet34_v1",
freeze_base_network=True,
num_epochs=10);
Step-2: Training the model.
步驟2:訓練模型。
#Start Trainingmonk_gln.Train()6.比較所有模型。 (6. Comparing all the models.)
Step-1: Using comparison class of Monk Library. For more details visit.
步驟1:使用僧侶庫的比較類。 有關更多詳細信息, 請訪問 。
# Invoke the comparison classfrom monk.compare_prototype import compareStep-2: Creating and managing comparison experiments. Provide the project name.
步驟2:創建和管理比較實驗。 提供項目名稱。
gtf = compare(verbose=1);gtf.Comparison("Comparison-1");
This creates files and directories as per the following structure
這將按照以下結構創建文件和目錄
workspace|
|--------comparison
|
|
|-----Compare-1
|
|------stats_best_val_acc.png
|------stats_max_gpu_usage.png
|------stats_training_time.png
|------train_accuracy.png
|------train_loss.png
|------val_accuracy.png
|------val_loss.png
|-----comparison.csv (Contains necessary details of all experiments)
Step-3: Adding the experiments to the comparison object.
步驟3:將實驗添加到比較對象。
- The first argument - Project name. 第一個參數-項目名稱。
 - The second argument - Experiment name. 第二個參數-實驗名稱。
 
gtf.Add_Experiment("Task", "gluon_resnet18_v1");
gtf.Add_Experiment("Task", "gluon_resnet18_v1_train_all_layers");
gtf.Add_Experiment("Task", "gluon-resnet18_v2");
gtf.Add_Experiment("Task", "gluon-resnet34_v1");
Step-4: Run analysis. This step generates seven images.
步驟4:運行分析。 此步驟將生成七個圖像。
gtf.Generate_Statistics();Step-5: Visualize the study comparison metrics.
步驟5:可視化研究比較指標。
- Training Accuracy curve 訓練精度曲線
 
Image(filename="workspace/comparison/Comparison-1/train_accuracy.png")
- Training loss curve 訓練損失曲線
 
- Validation accuracy curve 驗證精度曲線
 
- Validation loss curve 驗證損失曲線
 
- Training time is taken 花費訓練時間
 
- Max GPU usage 最大GPU使用率
 
- Best validation accuracy 最佳驗證精度
 
結論 (Conclusions)
謝謝閱讀。 請提出您的建議。 (Thanks for reading. Please give your suggestions.)
Rohit is a BTech. final year student. He has knowledge of machine learning and deep learning. He is interested to work in the field of AI and ML. Currently, he is working as a computer vision intern at Tessellate Imaging. Connect with him on LinkedIn.
Rohit是一名BTech。 最后一年的學生。 他具有機器學習和深度學習的知識。 他對從事AI和ML領域感興趣。 目前,他在Tessellate Imaging擔任計算機視覺實習生。 在LinkedIn上與他聯系。
翻譯自: https://towardsdatascience.com/image-classifier-house-room-type-classification-using-monk-library-d633795a42ef
圖像分類數據庫
總結
以上是生活随笔為你收集整理的图像分类数据库_图像分类器-使用僧侣库对房屋房间类型进行分类的全部內容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: 现代汽车去年营收同比增长 21.2%,今
 - 下一篇: 亚马逊欲推出《古墓丽影》剧集 新游戏也在