MCPcopy Index your code
hub / github.com/NVIDIA/FastPhotoStyle / memory_limit_image_resize

Function memory_limit_image_resize

process_stylization.py:40–57  ·  view source on GitHub ↗
(cont_img)

Source from the content-addressed store, hash-verified

38
39
40def memory_limit_image_resize(cont_img):
41 # prevent too small or too big images
42 MINSIZE=256
43 MAXSIZE=960
44 orig_width = cont_img.width
45 orig_height = cont_img.height
46 if max(cont_img.width,cont_img.height) < MINSIZE:
47 if cont_img.width > cont_img.height:
48 cont_img.thumbnail((int(cont_img.width*1.0/cont_img.height*MINSIZE), MINSIZE), Image.BICUBIC)
49 else:
50 cont_img.thumbnail((MINSIZE, int(cont_img.height*1.0/cont_img.width*MINSIZE)), Image.BICUBIC)
51 if min(cont_img.width,cont_img.height) > MAXSIZE:
52 if cont_img.width > cont_img.height:
53 cont_img.thumbnail((MAXSIZE, int(cont_img.height*1.0/cont_img.width*MAXSIZE)), Image.BICUBIC)
54 else:
55 cont_img.thumbnail(((int(cont_img.width*1.0/cont_img.height*MAXSIZE), MAXSIZE)), Image.BICUBIC)
56 print("Resize image: (%d,%d)->(%d,%d)" % (orig_width, orig_height, cont_img.width, cont_img.height))
57 return cont_img.width, cont_img.height
58
59
60def stylization(stylization_module, smoothing_module, content_image_path, style_image_path, content_seg_path, style_seg_path, output_image_path,

Callers 2

stylizationFunction · 0.90
stylizationFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected