Unverified Commit 3ba8d2f7 authored by Hang Zhang's avatar Hang Zhang Committed by GitHub
Browse files

rm (#62)

* rm

* Delete demo.py
parent ed5456d3
import torch
import encoding
# Get the model
model = encoding.models.get_model('fcn_resnet50_ade', pretrained=True).cuda()
model.eval()
# Prepare the image
url = 'https://github.com/zhanghang1989/image-data/blob/master/' + \
'encoding/segmentation/ade20k/ADE_val_00001142.jpg?raw=true'
filename = 'example.jpg'
img = encoding.utils.load_image(
encoding.utils.download(url, filename)).cuda().unsqueeze(0)
# Make prediction
output = model.evaluate(img)
predict = torch.max(output, 1)[1].cpu().numpy() + 1
# Get color pallete for visualization
mask = encoding.utils.get_mask_pallete(predict, 'ade20k')
mask.save('output.png')
import importlib
import torch
import encoding
from option import Options
from torch.autograd import Variable
if __name__ == "__main__":
args = Options().parse()
model = encoding.models.get_segmentation_model(args.model, dataset=args.dataset, aux=args.aux,
se_loss=args.se_loss, norm_layer=torch.nn.BatchNorm2d)
print('Creating the model:')
print(model)
model.cuda()
x = Variable(torch.Tensor(4, 3, 480, 480)).cuda()
with torch.no_grad():
out = model(x)
for y in out:
print(y.size())
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