如何在pytorch中放大图像?

时间:2019-02-19 17:02:20

标签: python-3.x pytorch

如何在不使用变换定义高度和宽度的情况下在Pytorch中放大图像?  ('--upscale_factor',type = int,required = True,help =“ super resolution upscale factor”)

2 个答案:

答案 0 :(得分:0)

如果我正确理解您想通过仅指定因子x(而不是指定目标宽度和高度)来对张量f进行升采样,则可以尝试以下操作:

from  torch.nn.modules.upsampling import Upsample
m = Upsample(scale_factor=f, mode='nearest')
x_upsampled = m(x)

请注意,Upsample允许多种插值模式,例如mode='nearest'mode='bilinear'

答案 1 :(得分:0)

这是一个有趣的例子:

class App extends React.Component {
  render() {
    return ( <
      div > This is Naveen!! < /div>
    );
  }
}
ReactDOM.render( <
  App / > ,
  document.getElementById("root")
);

出局:

<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <!--Import Google Icon Font-->
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
  <!--Import materialize.css-->
  <!-- Compiled and minified CSS -->
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
  <!-- Compiled and minified JavaScript -->
  <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
  <!--Let browser know website is optimized for mobile-->
  <!--Import React Js minified js-->
  <script src="https://unpkg.com/react@15/dist/react.min.js"></script>
  <!--Import React Js DOM minified js-->
  <script src="https://unpkg.com/react-dom@15/dist/react-dom.min.js"></script>
  <!--Import Babel Js-->
  <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.js"></script>
  <!--Import external CSS-->
  <link rel="stylesheet" href="main.css" />
  <style>

  </style>
</head>

<body>
  <!--Root component of the app-->
  <div id="root"></div>
  <!--Import Jquery for materialize css-->
  <script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
  <!--Import Application js files-->
  <script type="text/babel" src="js/App.js"></script>
</body>

</html>