Upload modutils.py
Browse files- modutils.py +6 -2
modutils.py
CHANGED
@@ -331,11 +331,15 @@ def save_gallery_history(images, files, history_gallery, history_files, progress
|
|
331 |
|
332 |
def save_image_history(image, gallery, files, model_name: str, progress=gr.Progress(track_tqdm=True)):
|
333 |
basename = f"{model_name.split('/')[-1]}_{datetime.now(FILENAME_TIMEZONE).strftime('%Y%m%d_%H%M%S')}"
|
334 |
-
if image is None or not isinstance(image, str): return gr.update(), gr.update()
|
335 |
if not gallery: gallery = []
|
336 |
if not files: files = []
|
337 |
filename = f"{basename}.png"
|
338 |
-
|
|
|
|
|
|
|
|
|
339 |
newpath = oldpath
|
340 |
try:
|
341 |
if newpath != oldpath and oldpath.exists():
|
|
|
331 |
|
332 |
def save_image_history(image, gallery, files, model_name: str, progress=gr.Progress(track_tqdm=True)):
|
333 |
basename = f"{model_name.split('/')[-1]}_{datetime.now(FILENAME_TIMEZONE).strftime('%Y%m%d_%H%M%S')}"
|
334 |
+
if image is None or (not isinstance(image, str) and not isinstance(image, Image.Image) and not isinstance(image, tuple)): return gr.update(), gr.update()
|
335 |
if not gallery: gallery = []
|
336 |
if not files: files = []
|
337 |
filename = f"{basename}.png"
|
338 |
+
if isinstance(image, tuple): image = image[0]
|
339 |
+
if isinstance(image, str): oldpath = Path(image)
|
340 |
+
else:
|
341 |
+
oldpath = "temp.png"
|
342 |
+
image.save(oldpath)
|
343 |
newpath = oldpath
|
344 |
try:
|
345 |
if newpath != oldpath and oldpath.exists():
|