Spaces:
Running on Zero
Running on Zero
Use simpler live-visible brush config for region drawing
Browse files
app.py
CHANGED
|
@@ -22,7 +22,6 @@ 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 |
-
HAS_LAYER_OPTIONS = hasattr(gr, "LayerOptions")
|
| 26 |
|
| 27 |
# Model options — swap MODEL_NAME to reduce VRAM usage on GPUs with <= 8GB
|
| 28 |
#
|
|
@@ -1354,12 +1353,11 @@ with gr.Blocks(title="DeepSeek-OCR-2") as demo:
|
|
| 1354 |
editor_kwargs = {}
|
| 1355 |
if HAS_BRUSH:
|
| 1356 |
try:
|
| 1357 |
-
highlight = ("#2563eb", 0.58)
|
| 1358 |
editor_kwargs["brush"] = gr.Brush(
|
| 1359 |
-
colors=[
|
| 1360 |
-
default_color=
|
| 1361 |
color_mode="fixed",
|
| 1362 |
-
default_size=
|
| 1363 |
)
|
| 1364 |
except TypeError:
|
| 1365 |
try:
|
|
@@ -1367,7 +1365,7 @@ with gr.Blocks(title="DeepSeek-OCR-2") as demo:
|
|
| 1367 |
colors=["#2563eb"],
|
| 1368 |
default_color="#2563eb",
|
| 1369 |
color_mode="fixed",
|
| 1370 |
-
default_size=
|
| 1371 |
)
|
| 1372 |
except TypeError:
|
| 1373 |
editor_kwargs["brush"] = gr.Brush()
|
|
@@ -1376,11 +1374,6 @@ with gr.Blocks(title="DeepSeek-OCR-2") as demo:
|
|
| 1376 |
editor_kwargs["eraser"] = gr.Eraser(default_size=26)
|
| 1377 |
except TypeError:
|
| 1378 |
editor_kwargs["eraser"] = gr.Eraser()
|
| 1379 |
-
if HAS_LAYER_OPTIONS:
|
| 1380 |
-
try:
|
| 1381 |
-
editor_kwargs["layers"] = gr.LayerOptions(allow_additional_layers=False)
|
| 1382 |
-
except TypeError:
|
| 1383 |
-
pass
|
| 1384 |
region_editor = gr.ImageEditor(
|
| 1385 |
label="Main image workspace. Recommended: freehand/highlight the target area, then click Add Region. (Crop tool for rectangles is optional.)",
|
| 1386 |
type="pil",
|
|
|
|
| 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 |
#
|
|
|
|
| 1353 |
editor_kwargs = {}
|
| 1354 |
if HAS_BRUSH:
|
| 1355 |
try:
|
|
|
|
| 1356 |
editor_kwargs["brush"] = gr.Brush(
|
| 1357 |
+
colors=["#2563eb"],
|
| 1358 |
+
default_color="#2563eb",
|
| 1359 |
color_mode="fixed",
|
| 1360 |
+
default_size=22,
|
| 1361 |
)
|
| 1362 |
except TypeError:
|
| 1363 |
try:
|
|
|
|
| 1365 |
colors=["#2563eb"],
|
| 1366 |
default_color="#2563eb",
|
| 1367 |
color_mode="fixed",
|
| 1368 |
+
default_size=22,
|
| 1369 |
)
|
| 1370 |
except TypeError:
|
| 1371 |
editor_kwargs["brush"] = gr.Brush()
|
|
|
|
| 1374 |
editor_kwargs["eraser"] = gr.Eraser(default_size=26)
|
| 1375 |
except TypeError:
|
| 1376 |
editor_kwargs["eraser"] = gr.Eraser()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1377 |
region_editor = gr.ImageEditor(
|
| 1378 |
label="Main image workspace. Recommended: freehand/highlight the target area, then click Add Region. (Crop tool for rectangles is optional.)",
|
| 1379 |
type="pil",
|