while running the code it stop after generating 1 image looks like it is unable to store the file getting error in this line plt.savefig(save_path) and at last it can't find file giving [Errno 2] No such file or directory: 'test/gen_1_0_0.png' if you know the solution please reply thanks.
Input In [14], in StackGanStage1.train_stage1(self)
115 genimages, = self.stage1_generator.predict_on_batch([embedding_batch, latent_space])
117 for i, image in enumerate(gen_images[:10]):
--> 118 save_image(image, f'test/gen1{epoch}_{i}')
120 if epoch % 25 == 0:
121 self.stage1_generator.save_weights('weights/stage1_gen.h5')
Input In [13], in save_image(file, save_path)
111 ax.imshow(file)
112 ax.axis("off")
--> 113 plt.savefig(save_path)
File C:\anaconda\lib\site-packages\matplotlib\pyplot.py:958, in savefig(*args, kwargs)
955 @_copy_docstring_and_deprecators(Figure.savefig)
956 def savefig(*args, *kwargs):
957 fig = gcf()
--> 958 res = fig.savefig(args, kwargs)
959 fig.canvas.draw_idle() # need this if 'transparent=True' to reset colors
960 return res
File C:\anaconda\lib\site-packages\matplotlib\figure.py:3019, in Figure.savefig(self, fname, transparent, kwargs)
3015 for ax in self.axes:
3016 stack.enter_context(
3017 ax.patch._cm_set(facecolor='none', edgecolor='none'))
-> 3019 self.canvas.print_figure(fname, kwargs)
File C:\anaconda\lib\site-packages\matplotlib\backend_bases.py:2319, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, kwargs)
2315 try:
2316 # _get_renderer may change the figure dpi (as vector formats
2317 # force the figure dpi to 72), so we need to set it again here.
2318 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2319 result = print_method(
2320 filename,
2321 facecolor=facecolor,
2322 edgecolor=edgecolor,
2323 orientation=orientation,
2324 bbox_inches_restore=_bbox_inches_restore,
2325 kwargs)
2326 finally:
2327 if bbox_inches and restore_bbox:
File C:\anaconda\lib\site-packages\matplotlib\backend_bases.py:1648, in _check_savefig_extra_args..wrapper(*args, *kwargs)
1640 _api.warn_deprecated(
1641 '3.3', name=name, removal='3.6',
1642 message='%(name)s() got unexpected keyword argument "'
1643 + arg + '" which is no longer supported as of '
1644 '%(since)s and will become an error '
1645 '%(removal)s')
1646 kwargs.pop(arg)
-> 1648 return func(args, **kwargs)
File C:\anaconda\lib\site-packages\matplotlib_api\deprecation.py:412, in delete_parameter..wrapper(inner_args, inner_kwargs)
402 deprecation_addendum = (
403 f"If any parameter follows {name!r}, they should be passed as "
404 f"keyword, not positionally.")
405 warn_deprecated(
406 since,
407 name=repr(name),
(...)
410 else deprecation_addendum,
411 kwargs)
--> 412 return func(inner_args, **inner_kwargs)
File C:\anaconda\lib\site-packages\matplotlib\backends\backend_agg.py:541, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs, args)
494 """
495 Write the figure to a PNG file.
496
(...)
538 metadata*, including the default 'Software' key.
539 """
540 FigureCanvasAgg.draw(self)
--> 541 mpl.image.imsave(
542 filename_or_obj, self.buffer_rgba(), format="png", origin="upper",
543 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
while running the code it stop after generating 1 image looks like it is unable to store the file getting error in this line plt.savefig(save_path) and at last it can't find file giving [Errno 2] No such file or directory: 'test/gen_1_0_0.png' if you know the solution please reply thanks.
FileNotFoundError Traceback (most recent call last) Input In [16], in <cell line: 136>() 147 dataset_path = "D:/GAN/CUB_200_2011" 149 stage1 = StackGanStage1() --> 150 stage1.train_stage1() 152 stage2 = StackGanStage2() 153 stage2.train_stage2()
Input In [14], in StackGanStage1.train_stage1(self) 115 genimages, = self.stage1_generator.predict_on_batch([embedding_batch, latent_space]) 117 for i, image in enumerate(gen_images[:10]): --> 118 save_image(image, f'test/gen1{epoch}_{i}') 120 if epoch % 25 == 0: 121 self.stage1_generator.save_weights('weights/stage1_gen.h5')
Input In [13], in save_image(file, save_path) 111 ax.imshow(file) 112 ax.axis("off") --> 113 plt.savefig(save_path)
File C:\anaconda\lib\site-packages\matplotlib\pyplot.py:958, in savefig(*args, kwargs) 955 @_copy_docstring_and_deprecators(Figure.savefig) 956 def savefig(*args, *kwargs): 957 fig = gcf() --> 958 res = fig.savefig(args, kwargs) 959 fig.canvas.draw_idle() # need this if 'transparent=True' to reset colors 960 return res
File C:\anaconda\lib\site-packages\matplotlib\figure.py:3019, in Figure.savefig(self, fname, transparent, kwargs) 3015 for ax in self.axes: 3016 stack.enter_context( 3017 ax.patch._cm_set(facecolor='none', edgecolor='none')) -> 3019 self.canvas.print_figure(fname, kwargs)
File C:\anaconda\lib\site-packages\matplotlib\backend_bases.py:2319, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, kwargs) 2315 try: 2316 # _get_renderer may change the figure dpi (as vector formats 2317 # force the figure dpi to 72), so we need to set it again here. 2318 with cbook._setattr_cm(self.figure, dpi=dpi): -> 2319 result = print_method( 2320 filename, 2321 facecolor=facecolor, 2322 edgecolor=edgecolor, 2323 orientation=orientation, 2324 bbox_inches_restore=_bbox_inches_restore, 2325 kwargs) 2326 finally: 2327 if bbox_inches and restore_bbox:
File C:\anaconda\lib\site-packages\matplotlib\backend_bases.py:1648, in _check_savefig_extra_args..wrapper(*args, *kwargs)
1640 _api.warn_deprecated(
1641 '3.3', name=name, removal='3.6',
1642 message='%(name)s() got unexpected keyword argument "'
1643 + arg + '" which is no longer supported as of '
1644 '%(since)s and will become an error '
1645 '%(removal)s')
1646 kwargs.pop(arg)
-> 1648 return func(args, **kwargs)
File C:\anaconda\lib\site-packages\matplotlib_api\deprecation.py:412, in delete_parameter..wrapper(inner_args, inner_kwargs)
402 deprecation_addendum = (
403 f"If any parameter follows {name!r}, they should be passed as "
404 f"keyword, not positionally.")
405 warn_deprecated(
406 since,
407 name=repr(name),
(...)
410 else deprecation_addendum,
411 kwargs)
--> 412 return func(inner_args, **inner_kwargs)
File C:\anaconda\lib\site-packages\matplotlib\backends\backend_agg.py:541, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs, args) 494 """ 495 Write the figure to a PNG file. 496 (...) 538 metadata*, including the default 'Software' key. 539 """ 540 FigureCanvasAgg.draw(self) --> 541 mpl.image.imsave( 542 filename_or_obj, self.buffer_rgba(), format="png", origin="upper", 543 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File C:\anaconda\lib\site-packages\matplotlib\image.py:1675, in imsave(fname, arr, vmin, vmax, cmap, format, origin, dpi, metadata, pil_kwargs) 1673 pil_kwargs.setdefault("format", format) 1674 pil_kwargs.setdefault("dpi", (dpi, dpi)) -> 1675 image.save(fname, **pil_kwargs)
File C:\anaconda\lib\site-packages\PIL\Image.py:2317, in Image.save(self, fp, format, **params) 2315 fp = builtins.open(filename, "r+b") 2316 else: -> 2317 fp = builtins.open(filename, "w+b") 2319 try: 2320 save_handler(self, fp, filename)
FileNotFoundError: [Errno 2] No such file or directory: 'test/gen_1_0_0.png'