Upload 2 files
Browse files- dc.py +2 -3
- modutils.py +2 -2
dc.py
CHANGED
@@ -191,7 +191,7 @@ class GuiSD:
|
|
191 |
|
192 |
if self.model.base_model_id != model_name:
|
193 |
load_now_time = datetime.now()
|
194 |
-
elapsed_time = (load_now_time - self.last_load).total_seconds()
|
195 |
|
196 |
if elapsed_time <= 8:
|
197 |
print("Waiting for the previous model's time ops...")
|
@@ -220,7 +220,7 @@ class GuiSD:
|
|
220 |
yield f"Model loaded: {model_name}"
|
221 |
|
222 |
#@spaces.GPU
|
223 |
-
|
224 |
def generate_pipeline(
|
225 |
self,
|
226 |
prompt,
|
@@ -549,7 +549,6 @@ class GuiSD:
|
|
549 |
|
550 |
def dynamic_gpu_duration(func, duration, *args):
|
551 |
|
552 |
-
@torch.inference_mode()
|
553 |
@spaces.GPU(duration=duration)
|
554 |
def wrapped_func():
|
555 |
yield from func(*args)
|
|
|
191 |
|
192 |
if self.model.base_model_id != model_name:
|
193 |
load_now_time = datetime.now()
|
194 |
+
elapsed_time = max((load_now_time - self.last_load).total_seconds(), 0)
|
195 |
|
196 |
if elapsed_time <= 8:
|
197 |
print("Waiting for the previous model's time ops...")
|
|
|
220 |
yield f"Model loaded: {model_name}"
|
221 |
|
222 |
#@spaces.GPU
|
223 |
+
@torch.inference_mode()
|
224 |
def generate_pipeline(
|
225 |
self,
|
226 |
prompt,
|
|
|
549 |
|
550 |
def dynamic_gpu_duration(func, duration, *args):
|
551 |
|
|
|
552 |
@spaces.GPU(duration=duration)
|
553 |
def wrapped_func():
|
554 |
yield from func(*args)
|
modutils.py
CHANGED
@@ -332,7 +332,7 @@ def save_gallery_history(images, files, history_gallery, history_files, progress
|
|
332 |
|
333 |
def save_image_history(image, gallery, files, model_name: str, progress=gr.Progress(track_tqdm=True)):
|
334 |
basename = f"{model_name.split('/')[-1]}_{datetime.now(FILENAME_TIMEZONE).strftime('%Y%m%d_%H%M%S')}"
|
335 |
-
if image is None or not isinstance(image, (str, Image.Image, np.
|
336 |
if not gallery: gallery = []
|
337 |
if not files: files = []
|
338 |
filename = f"{basename}.png"
|
@@ -341,7 +341,7 @@ def save_image_history(image, gallery, files, model_name: str, progress=gr.Progr
|
|
341 |
elif isinstance(image, Image.Image):
|
342 |
oldpath = "temp.png"
|
343 |
image.save(oldpath)
|
344 |
-
elif isinstance(image, np.
|
345 |
oldpath = "temp.png"
|
346 |
Image.fromarray(image).convert('RGBA').save(oldpath)
|
347 |
newpath = oldpath
|
|
|
332 |
|
333 |
def save_image_history(image, gallery, files, model_name: str, progress=gr.Progress(track_tqdm=True)):
|
334 |
basename = f"{model_name.split('/')[-1]}_{datetime.now(FILENAME_TIMEZONE).strftime('%Y%m%d_%H%M%S')}"
|
335 |
+
if image is None or not isinstance(image, (str, Image.Image, np.ndarray, tuple)): return gr.update(), gr.update()
|
336 |
if not gallery: gallery = []
|
337 |
if not files: files = []
|
338 |
filename = f"{basename}.png"
|
|
|
341 |
elif isinstance(image, Image.Image):
|
342 |
oldpath = "temp.png"
|
343 |
image.save(oldpath)
|
344 |
+
elif isinstance(image, np.ndarray):
|
345 |
oldpath = "temp.png"
|
346 |
Image.fromarray(image).convert('RGBA').save(oldpath)
|
347 |
newpath = oldpath
|