Algorick commited on
Commit
ca86176
·
verified ·
1 Parent(s): 65658e1

1e8d8af893dd

Browse files
Files changed (3) hide show
  1. app.py +1 -1
  2. pixrick/runner.py +10 -0
  3. web/style.css +5 -2
app.py CHANGED
@@ -111,7 +111,7 @@ def _friendly(exc: BaseException) -> str:
111
  if isinstance(exc, (RequestError, SafetyError)):
112
  return str(exc)
113
  text = str(exc)
114
- if "out of memory" in text.lower():
115
  return "La GPU è piena in questo momento. Riprova tra poco o scegli meno immagini."
116
  log.error("Lavoro non riuscito", exc_info=exc)
117
  detail = f" [{type(exc).__name__}: {str(exc)[:200]}]" if os.environ.get("PIXRICK_DEBUG", "1") == "1" else ""
 
111
  if isinstance(exc, (RequestError, SafetyError)):
112
  return str(exc)
113
  text = str(exc)
114
+ if "out of memory" in text.lower() or "NVML_SUCCESS" in text:
115
  return "La GPU è piena in questo momento. Riprova tra poco o scegli meno immagini."
116
  log.error("Lavoro non riuscito", exc_info=exc)
117
  detail = f" [{type(exc).__name__}: {str(exc)[:200]}]" if os.environ.get("PIXRICK_DEBUG", "1") == "1" else ""
pixrick/runner.py CHANGED
@@ -42,7 +42,10 @@ class Models:
42
  self.torch = torch
43
  self.zimage = ZImagePipeline.from_pretrained(config.MODELS["z-image"]["repo"], torch_dtype=dtype).to("cuda")
44
  self.zimage_i2i = ZImageImg2ImgPipeline(**self.zimage.components)
 
45
  self.klein = Flux2KleinPipeline.from_pretrained(config.MODELS["klein"]["repo"], torch_dtype=dtype).to("cuda")
 
 
46
  self.cutout = AutoModelForImageSegmentation.from_pretrained(
47
  config.TOOLS["scontorna"]["repo"], trust_remote_code=True
48
  ).to("cuda").eval()
@@ -351,6 +354,13 @@ class Runner:
351
  return out
352
 
353
  def run(self) -> list[tuple[str, Image.Image, int]]:
 
 
 
 
 
 
 
354
  job, req = self.job, self.job.request
355
  job.started = time.time()
356
  self.check_inputs()
 
42
  self.torch = torch
43
  self.zimage = ZImagePipeline.from_pretrained(config.MODELS["z-image"]["repo"], torch_dtype=dtype).to("cuda")
44
  self.zimage_i2i = ZImageImg2ImgPipeline(**self.zimage.components)
45
+ self.zimage.vae.enable_tiling()
46
  self.klein = Flux2KleinPipeline.from_pretrained(config.MODELS["klein"]["repo"], torch_dtype=dtype).to("cuda")
47
+ if hasattr(self.klein.vae, "enable_tiling"):
48
+ self.klein.vae.enable_tiling()
49
  self.cutout = AutoModelForImageSegmentation.from_pretrained(
50
  config.TOOLS["scontorna"]["repo"], trust_remote_code=True
51
  ).to("cuda").eval()
 
354
  return out
355
 
356
  def run(self) -> list[tuple[str, Image.Image, int]]:
357
+ try:
358
+ return self._run()
359
+ finally:
360
+ if not config.FAKE_ENGINE:
361
+ self.m.torch.cuda.empty_cache()
362
+
363
+ def _run(self) -> list[tuple[str, Image.Image, int]]:
364
  job, req = self.job, self.job.request
365
  job.started = time.time()
366
  self.check_inputs()
web/style.css CHANGED
@@ -1767,7 +1767,10 @@ body[data-scope="cestino"] .selection-bar [data-scope]:not([data-scope="cestino"
1767
  padding-bottom: 2px;
1768
  }
1769
  .shot-actions::-webkit-scrollbar { display: none; }
1770
- .act { height: 40px; min-width: 40px; flex: none; }
 
 
 
1771
 
1772
  .composer { padding: 8px 10px 10px; border-radius: 16px; }
1773
  .composer-top { margin-bottom: 4px; }
@@ -1856,5 +1859,5 @@ body[data-scope="cestino"] .selection-bar [data-scope]:not([data-scope="cestino"
1856
  .picker { height: 92dvh; }
1857
  .guide { inset: 0; width: 100vw; }
1858
  .welcome { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0; }
1859
- .toast { top: auto; bottom: calc(var(--nav) + env(safe-area-inset-bottom) + 12px); width: max-content; max-width: calc(100vw - 24px); }
1860
  }
 
1767
  padding-bottom: 2px;
1768
  }
1769
  .shot-actions::-webkit-scrollbar { display: none; }
1770
+ .act, .single-actions .act, .single-actions .act.secondary { width: auto; height: 40px; min-width: 40px; padding: 0 12px; flex: none; justify-content: center; }
1771
+ .act span, .single-actions .act span, .single-actions .act.secondary span { display: inline; }
1772
+ .act.icon-only { width: 40px; padding: 0; }
1773
+ .shot-actions { mask-image: linear-gradient(90deg, #000 85%, transparent); -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); }
1774
 
1775
  .composer { padding: 8px 10px 10px; border-radius: 16px; }
1776
  .composer-top { margin-bottom: 4px; }
 
1859
  .picker { height: 92dvh; }
1860
  .guide { inset: 0; width: 100vw; }
1861
  .welcome { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0; }
1862
+ .toast { top: calc(var(--topbar) + env(safe-area-inset-top) + 10px); width: max-content; max-width: calc(100vw - 24px); }
1863
  }