Answers.Body: <p>My suggestion is to transfom the resolution of all images equal proportion.
  You can use this python code:</p>
  
  <pre><code>from PIL import Image
  import os
  import argparse
  
  
  def rescale_images(directory, size):
      for img in os.listdir(directory):
          im = Image.open(directory + img)
          im_resized = im.resize(size, Image.ANTIALIAS)
          im_resized.save(directory + img)
  
  
  if __name__ == '__main__':
      parser = argparse.ArgumentParser(description="Rescale images")
      parser.add_argument('-d', '--directory', type=str, required=True, help='Directory containing the images')
      parser.add_argument('-s', '--size', type=int, nargs=2, required=True, metavar=('width', 'height'),
                          help='Image size')
      args = parser.parse_args()
      rescale_images(args.directory, args.size)
  
  
  
  # save this python code as transform_image_resoluthion.py 
  # run this with cmd with the below command 
  # python transform_image_resolution.py -d images/ -s 800 600
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-29T17:36:55.097Z
Answers.LastActivityDate: 2019-07-29T17:36:55.097Z
Answers.UserDisplayName: Varshitha N S
Answers.Body: <p>My guess:</p>
  <p>If you add a few CNN layers before the input of the given model and train only those layers while keeping the given model's parameters frozen, you might get better result.</p>
  <p>Essentially these few extra layers would &quot;transform&quot; your input image into the appropriate shape, but with more accuracy since its trained and not hard coded.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-22T05:03:28.993Z
Answers.LastActivityDate: 2020-12-22T05:03:28.993Z
Answers.UserDisplayName: Joel Joseph
Body: <p>Most image classifiers like Inception-v3 accept images of about size 299 x 299 x 3 as input. In this particular case, I cannot resize the image and lose resolution. Is there an easy solution of dealing with this rather than retraining the model? (Particularly in tensorflow)</p>
  
Tags: <convolutional-neural-networks><image-recognition><tensorflow><models>
Title: Is there a simple way of classifying images of size differing from the input of existing image classifiers?
UserDisplayName: JobHunter69
ThreadText: # Is there a simple way of classifying images of size differing from the input of existing image classifiers?
  
  (Asked by: username_0 on 2019-07-06)
  
  Most image classifiers like Inception-v3 accept images of about size 299 x 299 x 3 as input. In this particular case, I cannot resize the image and lose resolution. Is there an easy solution of dealing with this rather than retraining the model? (Particularly in tensorflow)
  
  **Tags:** convolutional-neural-networks, image-recognition, tensorflow, models
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2020-12-22. Score: 3 | Accepted answer
  
  My guess:
  
  If you add a few CNN layers before the input of the given model and train only those layers while keeping the given model's parameters frozen, you might get better result.
  
  Essentially these few extra layers would "transform" your input image into the appropriate shape, but with more accuracy since its trained and not hard coded.
  
  
  ---
  
  ### Answer by username_1 on 2019-07-29. Score: 2
  
  My suggestion is to transfom the resolution of all images equal proportion.
  You can use this python code:
  from PIL import Image
  import os
  import argparse
  
  
  def rescale_images(directory, size):
      for img in os.listdir(directory):
          im = Image.open(directory + img)
          im_resized = im.resize(size, Image.ANTIALIAS)
          im_resized.save(directory + img)
  
  
  if __name__ == '__main__':
      parser = argparse.ArgumentParser(description="Rescale images")
      parser.add_argument('-d', '--directory', type=str, required=True, help='Directory containing the images')
      parser.add_argument('-s', '--size', type=int, nargs=2, required=True, metavar=('width', 'height'),
                          help='Image size')
      args = parser.parse_args()
      rescale_images(args.directory, args.size)
  
  
  
  # save this python code as transform_image_resoluthion.py 
  # run this with cmd with the below command 
  # python transform_image_resolution.py -d images/ -s 800 600
  
  
  ---
  
  