ricklon commited on
Commit
33481c3
·
1 Parent(s): 7763137

Improve live region painting visibility in ImageEditor

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -22,6 +22,7 @@ from io import StringIO, BytesIO
22
  HAS_IMAGE_EDITOR = hasattr(gr, "ImageEditor")
23
  HAS_BRUSH = hasattr(gr, "Brush")
24
  HAS_ERASER = hasattr(gr, "Eraser")
 
25
 
26
  # Model options — swap MODEL_NAME to reduce VRAM usage on GPUs with <= 8GB
27
  #
@@ -1344,17 +1345,20 @@ with gr.Blocks(title="DeepSeek-OCR-2") as demo:
1344
  editor_kwargs = {}
1345
  if HAS_BRUSH:
1346
  try:
 
1347
  editor_kwargs["brush"] = gr.Brush(
1348
- colors=["rgba(37, 99, 235, 0.28)"],
1349
- default_color="rgba(37, 99, 235, 0.28)",
1350
  color_mode="fixed",
1351
  default_size=28,
1352
  )
1353
  except TypeError:
1354
  try:
1355
  editor_kwargs["brush"] = gr.Brush(
1356
- colors=["rgba(37, 99, 235, 0.28)"],
 
1357
  color_mode="fixed",
 
1358
  )
1359
  except TypeError:
1360
  editor_kwargs["brush"] = gr.Brush()
@@ -1363,6 +1367,11 @@ with gr.Blocks(title="DeepSeek-OCR-2") as demo:
1363
  editor_kwargs["eraser"] = gr.Eraser(default_size=26)
1364
  except TypeError:
1365
  editor_kwargs["eraser"] = gr.Eraser()
 
 
 
 
 
1366
  region_editor = gr.ImageEditor(
1367
  label="Main image workspace. Recommended: freehand/highlight the target area, then click Add Region. (Crop tool for rectangles is optional.)",
1368
  type="pil",
 
22
  HAS_IMAGE_EDITOR = hasattr(gr, "ImageEditor")
23
  HAS_BRUSH = hasattr(gr, "Brush")
24
  HAS_ERASER = hasattr(gr, "Eraser")
25
+ HAS_LAYER_OPTIONS = hasattr(gr, "LayerOptions")
26
 
27
  # Model options — swap MODEL_NAME to reduce VRAM usage on GPUs with <= 8GB
28
  #
 
1345
  editor_kwargs = {}
1346
  if HAS_BRUSH:
1347
  try:
1348
+ highlight = ("#2563eb", 0.58)
1349
  editor_kwargs["brush"] = gr.Brush(
1350
+ colors=[highlight],
1351
+ default_color=highlight,
1352
  color_mode="fixed",
1353
  default_size=28,
1354
  )
1355
  except TypeError:
1356
  try:
1357
  editor_kwargs["brush"] = gr.Brush(
1358
+ colors=["#2563eb"],
1359
+ default_color="#2563eb",
1360
  color_mode="fixed",
1361
+ default_size=28,
1362
  )
1363
  except TypeError:
1364
  editor_kwargs["brush"] = gr.Brush()
 
1367
  editor_kwargs["eraser"] = gr.Eraser(default_size=26)
1368
  except TypeError:
1369
  editor_kwargs["eraser"] = gr.Eraser()
1370
+ if HAS_LAYER_OPTIONS:
1371
+ try:
1372
+ editor_kwargs["layers"] = gr.LayerOptions(allow_additional_layers=False)
1373
+ except TypeError:
1374
+ pass
1375
  region_editor = gr.ImageEditor(
1376
  label="Main image workspace. Recommended: freehand/highlight the target area, then click Add Region. (Crop tool for rectangles is optional.)",
1377
  type="pil",