multimodalart HF Staff commited on
Commit
a4b85bd
·
verified ·
1 Parent(s): 0fc8001

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. README.md +1 -1
  2. app.py +10 -3
  3. requirements.txt +0 -1
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 🌾
4
  colorFrom: purple
5
  colorTo: yellow
6
  sdk: gradio
7
- sdk_version: 6.24.0
8
  app_file: app.py
9
  short_description: Global field boundary delineation from satellite imagery
10
  python_version: "3.12"
 
4
  colorFrom: purple
5
  colorTo: yellow
6
  sdk: gradio
7
+ sdk_version: 6.22.0
8
  app_file: app.py
9
  short_description: Global field boundary delineation from satellite imagery
10
  python_version: "3.12"
app.py CHANGED
@@ -18,6 +18,10 @@ from huggingface_hub import hf_hub_download
18
  from shapely.geometry import Polygon
19
  from shapely.ops import unary_union
20
  from ultralytics import YOLO
 
 
 
 
21
 
22
  # --------------------------------------------------------------------------------------
23
  # Model
@@ -248,7 +252,9 @@ def delineate(
248
  for i in range(0, len(origins), BATCH):
249
  chunk = origins[i : i + BATCH]
250
  tiles = [big[y : y + TILE, x : x + TILE] for (x, y) in chunk]
251
- results = model.predict(tiles, conf=float(confidence), half=True, retina_masks=True, verbose=False)
 
 
252
  for (x0, y0), res in zip(chunk, results):
253
  if res.masks is None or res.masks.data.shape[0] == 0:
254
  continue
@@ -310,7 +316,8 @@ CSS = """
310
  .dark .gradio-container { color: var(--body-text-color); }
311
  """
312
 
313
- with gr.Blocks(theme=gr.themes.Citrus(), css=CSS, title="Delineate Anything v2") as demo:
 
314
  with gr.Column(elem_id="col-container"):
315
  gr.Markdown(
316
  """
@@ -369,4 +376,4 @@ and returns clean, non-overlapping field polygons.
369
  )
370
 
371
  if __name__ == "__main__":
372
- demo.launch(mcp_server=True)
 
18
  from shapely.geometry import Polygon
19
  from shapely.ops import unary_union
20
  from ultralytics import YOLO
21
+ from ultralytics.cfg import DEFAULT_CFG_DICT
22
+
23
+ # ultralytics >= 8.4 replaced `half=True` with `quantize="fp16"`
24
+ FP16_KW = {"quantize": "fp16"} if "quantize" in DEFAULT_CFG_DICT else {"half": True}
25
 
26
  # --------------------------------------------------------------------------------------
27
  # Model
 
252
  for i in range(0, len(origins), BATCH):
253
  chunk = origins[i : i + BATCH]
254
  tiles = [big[y : y + TILE, x : x + TILE] for (x, y) in chunk]
255
+ results = model.predict(
256
+ tiles, conf=float(confidence), retina_masks=True, verbose=False, **FP16_KW
257
+ )
258
  for (x0, y0), res in zip(chunk, results):
259
  if res.masks is None or res.masks.data.shape[0] == 0:
260
  continue
 
316
  .dark .gradio-container { color: var(--body-text-color); }
317
  """
318
 
319
+ # NOTE: Gradio 6 moved `theme` / `css` from `Blocks(...)` to `launch(...)`.
320
+ with gr.Blocks(title="Delineate Anything v2") as demo:
321
  with gr.Column(elem_id="col-container"):
322
  gr.Markdown(
323
  """
 
376
  )
377
 
378
  if __name__ == "__main__":
379
+ demo.launch(theme=gr.themes.Citrus(), css=CSS, mcp_server=True)
requirements.txt CHANGED
@@ -1,5 +1,4 @@
1
  ultralytics
2
- opencv-python-headless
3
  shapely
4
  numpy
5
  pillow
 
1
  ultralytics
 
2
  shapely
3
  numpy
4
  pillow