提交 e0d46c60 编写于 作者: L LielinJiang

fix apps

上级 f5b1277d
......@@ -62,13 +62,13 @@ class BasePredictor(object):
return out
def is_video(self, input):
def is_image(self, input):
try:
img = Image.open(input)
_ = img.size
return False
except:
return True
except:
return False
def run(self):
raise NotImplementedError
......@@ -128,7 +128,7 @@ class DeOldifyPredictor(BasePredictor):
return frame_pattern_combined, vid_out_path
def run(self, input):
if self.is_video(input):
if not self.is_image(input):
return self.run_video(input)
else:
pred_img = self.run_image(input)
......
......@@ -101,7 +101,7 @@ class RealSRPredictor(BasePredictor):
if not os.path.exists(self.output):
os.makedirs(self.output)
if self.is_video(input):
if not self.is_image(input):
return self.run_video(input)
else:
pred_img = self.run_image(input)
......
......@@ -2,10 +2,9 @@ import numpy as np
import paddle
import paddle.nn as nn
import paddle.nn.functional as F
from paddle.vision.models import resnet101
from .hook import hook_outputs, model_sizes, dummy_eval
from ..backbones import resnet34, resnet101
# from paddle.vision.models import resnet101
from ...modules.nn import Spectralnorm
......@@ -273,7 +272,7 @@ class PixelShuffle_ICNR(nn.Layer):
self.shuf = PixelShuffle(scale)
self.pad = ReplicationPad2d((1, 0, 1, 0))
self.pad = ReplicationPad2d([1, 0, 1, 0])
self.blur = nn.Pool2D(2, pool_stride=1, pool_type='avg')
self.relu = relu(True, leaky=leaky)
......@@ -339,7 +338,7 @@ class CustomPixelShuffle_ICNR(nn.Layer):
self.shuf = PixelShuffle(scale)
self.pad = ReplicationPad2d((1, 0, 1, 0))
self.pad = ReplicationPad2d([1, 0, 1, 0])
self.blur = nn.Pool2D(2, pool_stride=1, pool_type='avg')
self.relu = nn.LeakyReLU(
leaky) if leaky is not None else nn.ReLU() #relu(True, leaky=leaky)
......@@ -410,7 +409,7 @@ class ReplicationPad2d(nn.Layer):
self.size = size
def forward(self, x):
return F.pad2d(x, self.size, mode="edge")
return F.pad(x, self.size, mode="replicate")
def conv1d(ni: int,
......@@ -420,7 +419,7 @@ def conv1d(ni: int,
padding: int = 0,
bias: bool = False):
"Create and initialize a `nn.Conv1d` layer with spectral normalization."
conv = nn.Conv1d(ni, no, ks, stride=stride, padding=padding, bias_attr=bias)
conv = nn.Conv1D(ni, no, ks, stride=stride, padding=padding, bias_attr=bias)
return Spectralnorm(conv)
......
......@@ -77,7 +77,7 @@ class Hooks():
def _hook_inner(m, i, o):
return o if isinstance(
o, paddle.framework.Variable) else o if is_listy(o) else list(o)
o, paddle.fluid.framework.Variable) else o if is_listy(o) else list(o)
def hook_output(module, detach=True, grad=False):
......
......@@ -109,9 +109,9 @@ class MobileResnetBlock(nn.Layer):
p = 0
if self.padding_type == 'reflect':
self.conv_block.extend([nn.ReflectionPad2d([1, 1, 1, 1])])
self.conv_block.extend([nn.Pad2D([1, 1, 1, 1], mode='reflect')])
elif self.padding_type == 'replicate':
self.conv_block.extend([nn.ReplicationPad2d([1, 1, 1, 1])])
self.conv_block.extend([nn.Pad2D([1, 1, 1, 1], mode='replicate')])
elif self.padding_type == 'zero':
p = 1
else:
......
......@@ -128,7 +128,7 @@ class NetworkR(nn.Layer):
super(NetworkR, self).__init__()
self.layers = nn.Sequential(
nn.ReplicationPad3d((1, 1, 1, 1, 1, 1)),
nn.Pad3D((1, 1, 1, 1, 1, 1), mode='replicate'),
TempConv(1,
64,
kernel_size=(3, 3, 3),
......@@ -165,7 +165,7 @@ class NetworkC(nn.Layer):
super(NetworkC, self).__init__()
self.down1 = nn.Sequential(
nn.ReplicationPad3d((1, 1, 1, 1, 0, 0)),
nn.Pad3D((1, 1, 1, 1, 0, 0), mode='replicate'),
TempConv(1, 64, stride=(1, 2, 2), padding=(0, 0, 0)),
TempConv(64, 128), TempConv(128, 128),
TempConv(128, 256, stride=(1, 2, 2)), TempConv(256, 256),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册