MCPcopy Index your code
hub / github.com/thygate/stable-diffusion-webui-depthmap-script / save_images

Function save_images

pix2pix/util/visualizer.py:17–44  ·  view source on GitHub ↗

Save images to the disk. Parameters: webpage (the HTML class) -- the HTML webpage class that stores these imaegs (see html.py for more details) visuals (OrderedDict) -- an ordered dictionary that stores (name, images (either tensor or numpy) ) pairs image_path (str)

(webpage, visuals, image_path, aspect_ratio=1.0, width=256)

Source from the content-addressed store, hash-verified

15
16
17def save_images(webpage, visuals, image_path, aspect_ratio=1.0, width=256):
18 """Save images to the disk.
19
20 Parameters:
21 webpage (the HTML class) -- the HTML webpage class that stores these imaegs (see html.py for more details)
22 visuals (OrderedDict) -- an ordered dictionary that stores (name, images (either tensor or numpy) ) pairs
23 image_path (str) -- the string is used to create image paths
24 aspect_ratio (float) -- the aspect ratio of saved images
25 width (int) -- the images will be resized to width x width
26
27 This function will save images stored in 'visuals' to the HTML file specified by 'webpage'.
28 """
29 image_dir = webpage.get_image_dir()
30 short_path = ntpath.basename(image_path[0])
31 name = os.path.splitext(short_path)[0]
32
33 webpage.add_header(name)
34 ims, txts, links = [], [], []
35
36 for label, im_data in visuals.items():
37 im = util.tensor2im(im_data)
38 image_name = '%s_%s.png' % (name, label)
39 save_path = os.path.join(image_dir, image_name)
40 util.save_image(im, save_path, aspect_ratio=aspect_ratio)
41 ims.append(image_name)
42 txts.append(label)
43 links.append(image_name)
44 webpage.add_images(ims, txts, links, width=width)
45
46
47class Visualizer():

Callers

nothing calls this directly

Calls 4

get_image_dirMethod · 0.80
add_headerMethod · 0.80
appendMethod · 0.80
add_imagesMethod · 0.80

Tested by

no test coverage detected