Unverified Commit 0403d287 authored by Hang Zhang's avatar Hang Zhang Committed by GitHub
Browse files
parent b05334f3
...@@ -68,7 +68,7 @@ Test Pre-trained Model ...@@ -68,7 +68,7 @@ Test Pre-trained Model
</code> </code>
<code xml:space="preserve" id="cmd_enc50_ade" style="display: none; text-align: left; white-space: pre-wrap"> <code xml:space="preserve" id="cmd_enc50_ade" style="display: none; text-align: left; white-space: pre-wrap">
CUDA_VISIBLE_DEVICES=0,1,2,3 python train.py --dataset ade20k --model encnetv2 --aux --se-loss CUDA_VISIBLE_DEVICES=0,1,2,3 python train.py --dataset ADE20K --model EncNet --aux --se-loss
</code> </code>
Quick Demo Quick Demo
......
...@@ -13,25 +13,20 @@ Test Pre-trained Model ...@@ -13,25 +13,20 @@ Test Pre-trained Model
- Clone the GitHub repo:: - Clone the GitHub repo::
git clone git@github.com:zhanghang1989/PyTorch-Encoding.git git clone https://github.com/zhanghang1989/PyTorch-Encoding
- Install PyTorch Encoding (if not yet). Please follow the installation guide `Installing PyTorch Encoding <../notes/compile.html>`_. - Install PyTorch Encoding (if not yet). Please follow the installation guide `Installing PyTorch Encoding <../notes/compile.html>`_.
- Download the `MINC-2500 <http://opensurfaces.cs.cornell.edu/publications/minc/>`_ dataset to ``$HOME/data/minc-2500/`` folder. Download pre-trained model (training `curve`_ as bellow, pre-trained on train-1 split using single training size of 224, with an error rate of :math:`19.98\%` using single crop on test-1 set):: - Download the `MINC-2500 <http://opensurfaces.cs.cornell.edu/publications/minc/>`_ dataset to ``$HOME/data/minc-2500/`` folder. Download pre-trained model (pre-trained on train-1 split using single training size of 224, with an error rate of :math:`19.70\%` using single crop on test-1 set)::
cd PyTorch-Encoding/experiments/recognition cd PyTorch-Encoding/experiments/recognition
bash model/download_models.sh python model/download_models.py
.. _curve:
.. image:: ../_static/img/deep_ten_curve.svg
:width: 70%
- Test pre-trained model on MINC-2500:: - Test pre-trained model on MINC-2500::
>>> python main.py --dataset minc --model deepten --nclass 23 --resume model/minc.pth.tar --eval python main.py --dataset minc --model deepten --nclass 23 --resume deepten_minc.pth --eval
# Teriminal Output: # Teriminal Output:
#[======================================== 23/23 ===================================>...] Step: 104ms | Tot: 3s256ms | Loss: 0.719 | Err: 19.983% (1149/5750) # Loss: 1.005 | Err: 19.704% (1133/5750): 100%|████████████████████| 23/23 [00:18<00:00, 1.26it/s]
Train Your Own Model Train Your Own Model
...@@ -39,7 +34,7 @@ Train Your Own Model ...@@ -39,7 +34,7 @@ Train Your Own Model
- Example training command for training above model:: - Example training command for training above model::
python main.py --model deepten --nclass 23 --model deepten --batch-size 64 --lr 0.01 --epochs 60 CUDA_VISIBLE_DEVICES=0,1,2,3 python main.py --dataset minc --model deepten --nclass 23 --model deepten --batch-size 512 --lr 0.004 --epochs 80 --lr-step 60
- Detail training options:: - Detail training options::
......
from .model_zoo import get_model from .model_zoo import get_model
from .model_store import get_model_file
from .base import * from .base import *
from .fcn import * from .fcn import *
from .psp import * from .psp import *
......
...@@ -9,6 +9,7 @@ from ..utils import download, check_sha1 ...@@ -9,6 +9,7 @@ from ..utils import download, check_sha1
_model_sha1 = {name: checksum for checksum, name in [ _model_sha1 = {name: checksum for checksum, name in [
('853f2fb07aeb2927f7696e166b215609a987fd44', 'resnet50'), ('853f2fb07aeb2927f7696e166b215609a987fd44', 'resnet50'),
('5be5422ad7cb6a2e5f5a54070d0aa9affe69a9a4', 'resnet101'), ('5be5422ad7cb6a2e5f5a54070d0aa9affe69a9a4', 'resnet101'),
('6cb047cda851de6aa31963e779fae5f4c299056a', 'deepten_minc'),
('fc8c0b795abf0133700c2d4265d2f9edab7eb6cc', 'fcn_resnet50_ade'), ('fc8c0b795abf0133700c2d4265d2f9edab7eb6cc', 'fcn_resnet50_ade'),
('eeed8e582f0fdccdba8579e7490570adc6d85c7c', 'fcn_resnet50_pcontext'), ('eeed8e582f0fdccdba8579e7490570adc6d85c7c', 'fcn_resnet50_pcontext'),
('54f70c772505064e30efd1ddd3a14e1759faa363', 'psp_resnet50_ade'), ('54f70c772505064e30efd1ddd3a14e1759faa363', 'psp_resnet50_ade'),
......
...@@ -94,11 +94,11 @@ def main(): ...@@ -94,11 +94,11 @@ def main():
loss.backward() loss.backward()
optimizer.step() optimizer.step()
train_loss += loss.data[0] train_loss += loss.data.item()
pred = output.data.max(1)[1] pred = output.data.max(1)[1]
correct += pred.eq(target.data).cpu().sum() correct += pred.eq(target.data).cpu().sum()
total += target.size(0) total += target.size(0)
err = 100-100.*correct/total err = 100.0 - 100.0 * correct / total
tbar.set_description('\rLoss: %.3f | Err: %.3f%% (%d/%d)' % \ tbar.set_description('\rLoss: %.3f | Err: %.3f%% (%d/%d)' % \
(train_loss/(batch_idx+1), err, total-correct, total)) (train_loss/(batch_idx+1), err, total-correct, total))
...@@ -122,7 +122,7 @@ def main(): ...@@ -122,7 +122,7 @@ def main():
correct += pred.eq(target.data).cpu().sum().item() correct += pred.eq(target.data).cpu().sum().item()
total += target.size(0) total += target.size(0)
err = 100-100.0*correct/total err = 100.0 - 100.0 * correct / total
tbar.set_description('Loss: %.3f | Err: %.3f%% (%d/%d)'% \ tbar.set_description('Loss: %.3f | Err: %.3f%% (%d/%d)'% \
(test_loss/(batch_idx+1), err, total-correct, total)) (test_loss/(batch_idx+1), err, total-correct, total))
......
...@@ -14,7 +14,7 @@ import torch.nn as nn ...@@ -14,7 +14,7 @@ import torch.nn as nn
from torch.autograd import Variable from torch.autograd import Variable
import encoding import encoding
import torchvision.models as resnet import encoding.dilated.resnet as resnet
class Net(nn.Module): class Net(nn.Module):
def __init__(self, args): def __init__(self, args):
...@@ -23,11 +23,11 @@ class Net(nn.Module): ...@@ -23,11 +23,11 @@ class Net(nn.Module):
self.backbone = args.backbone self.backbone = args.backbone
# copying modules from pretrained models # copying modules from pretrained models
if self.backbone == 'resnet50': if self.backbone == 'resnet50':
self.pretrained = resnet.resnet50(pretrained=True) self.pretrained = resnet.resnet50(pretrained=True, dilated=False)
elif self.backbone == 'resnet101': elif self.backbone == 'resnet101':
self.pretrained = resnet.resnet101(pretrained=True) self.pretrained = resnet.resnet101(pretrained=True, dilated=False)
elif self.backbone == 'resnet152': elif self.backbone == 'resnet152':
self.pretrained = resnet.resnet152(pretrained=True) self.pretrained = resnet.resnet152(pretrained=True, dilated=False)
else: else:
raise RuntimeError('unknown backbone: {}'.format(self.backbone)) raise RuntimeError('unknown backbone: {}'.format(self.backbone))
n_codes = 32 n_codes = 32
......
import encoding
import shutil
encoding.models.get_model_file('deepten_minc', root='./')
shutil.move('deepten_minc-6cb047cd.pth', 'deepten_minc.pth')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment