EgeEken commited on
Commit
1075c64
·
1 Parent(s): 808b311

new front page demo settings, remove pillow_avif import entirely

Browse files
Files changed (1) hide show
  1. server.py +16 -7
server.py CHANGED
@@ -15,14 +15,14 @@ from PIL import Image
15
  import numpy as np
16
  import cv2
17
 
18
- try:
19
- import pillow_avif # noqa: F401 registers the AVIF codec with Pillow
20
- except Exception:
21
- pass
22
-
23
  from PBC2_4 import PBC, PBC2Config, PBC2Result, preload_numba
24
  from PBC3 import PBC3, PBC3Config
25
 
 
 
 
 
 
26
  app = FastAPI(title="PBC Compression Demo")
27
 
28
  # Maps the UI's resampling labels to PBC2.4 config resample names.
@@ -296,8 +296,17 @@ async def stream_compress(image: UploadFile = File(...), downsample_initialize:
296
  img = Image.open(io.BytesIO(raw)).convert("RGB")
297
 
298
  def gen():
299
- for ev in PBC3.compress_stream(img, auto_downsample_init=_truthy(downsample_initialize),
300
- patch_count=600, frame_every=6):
 
 
 
 
 
 
 
 
 
301
  if ev["event"] == "frame":
302
  yield json.dumps({"image": _png_b64(ev["image"])}) + "\n"
303
 
 
15
  import numpy as np
16
  import cv2
17
 
 
 
 
 
 
18
  from PBC2_4 import PBC, PBC2Config, PBC2Result, preload_numba
19
  from PBC3 import PBC3, PBC3Config
20
 
21
+ import importlib.util
22
+ from PIL import features, __version__ as PIL_VERSION
23
+ print(f"[startup] Pillow {PIL_VERSION} · native AVIF={features.check('avif')} · "
24
+ f"plugin_installed={importlib.util.find_spec('pillow_avif') is not None}", flush=True)
25
+
26
  app = FastAPI(title="PBC Compression Demo")
27
 
28
  # Maps the UI's resampling labels to PBC2.4 config resample names.
 
296
  img = Image.open(io.BytesIO(raw)).convert("RGB")
297
 
298
  def gen():
299
+ for ev in PBC3.compress_stream(
300
+ img,
301
+ auto_downsample_init=_truthy(downsample_initialize),
302
+ patch_count=150,
303
+ max_patch_size=48, # each patch covers a small region, not the whole image
304
+ min_cell_size=1, # coarse cells → low-detail blocks
305
+ max_cell_size=16,
306
+ q_start=0.5, q_end=0.1,
307
+ search_q_start=0.5, search_q_end=0.1,
308
+ frame_every=3,
309
+ ):
310
  if ev["event"] == "frame":
311
  yield json.dumps({"image": _png_b64(ev["image"])}) + "\n"
312