3a25edce742db97d936ffb645185b520878d0c6d,dataset/resize.py,ImagenetResizer,resize_img,#ImagenetResizer#,23
Before Change
width, height = img.size
aspect_ratio = width / height
if width <= height & width < size[0]:
cover = img.resize((size[0], math.floor(size[0] / aspect_ratio)))
elif width >= height & height < size[1]:
cover = img.resize((size[1], math.floor(size[1] * aspect_ratio)))
else:
cover = resizeimage.resize_contain(img, size)
After Change
wanted_width, wanted_height = size
ratio_w, ratio_h = wanted_width / width, wanted_height / height
if np.alltrue(ratios > 1):
// Both sides of the image are shorter than the desired dimension,
// so take the side that"s closer in size and enlarge the image
// in both directions to make that one fit
factor = min(ratio_h, ratio_w)
img = img.resize((int(width * factor), int(height * factor)))
// Now we have an image that"s either larger than the desired shape
// or at least one side matches the desired shape and we can resize
// with contain
cover = resizeimage.resize_contain(img, size)
cover.save(join(self.dest_dir, filename), "JPEG")
def resize_all(self, size=(299, 299)):
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 4
Instances
Project Name: baldassarreFe/deep-koalarization
Commit Name: 3a25edce742db97d936ffb645185b520878d0c6d
Time: 2017-05-06
Author: baldassarre.fe@gmail.com
File Name: dataset/resize.py
Class Name: ImagenetResizer
Method Name: resize_img
Project Name: ncullen93/torchsample
Commit Name: a7d92f7020dfe8854430ef13ed2923b2606a6262
Time: 2017-05-11
Author: ncullen.th@dartmouth.edu
File Name: torchsample/utils.py
Class Name:
Method Name: th_random_choice
Project Name: suavecode/SUAVE
Commit Name: 0623ff0490b7558791a2f15f391fc47e8de2ed0f
Time: 2016-02-02
Author: jmvegh@stanford.edu
File Name: trunk/SUAVE/Methods/Power/Battery/Sizing/initialize_from_energy_and_power.py
Class Name:
Method Name: initialize_from_energy_and_power