Spaces:
Sleeping
Sleeping
phoebehxf
commited on
Commit
·
d3a435a
1
Parent(s):
5205f3a
add spaces
Browse files
app.py
CHANGED
|
@@ -16,6 +16,7 @@ from matplotlib import cm
|
|
| 16 |
from glob import glob
|
| 17 |
from natsort import natsorted
|
| 18 |
from huggingface_hub import HfApi, upload_file
|
|
|
|
| 19 |
|
| 20 |
# ===== 导入三个推理模块 =====
|
| 21 |
from inference_seg import load_model as load_seg_model, run as run_seg
|
|
@@ -210,6 +211,7 @@ def colorize_mask(mask: np.ndarray, num_colors: int = 512) -> np.ndarray:
|
|
| 210 |
return palette_arr[color_idx]
|
| 211 |
|
| 212 |
# ===== 分割功能 =====
|
|
|
|
| 213 |
def segment_with_choice(use_box_choice, annot_value):
|
| 214 |
"""分割主函数 - 每个实例不同颜色+轮廓"""
|
| 215 |
if annot_value is None or len(annot_value) < 1:
|
|
@@ -301,6 +303,7 @@ def segment_with_choice(use_box_choice, annot_value):
|
|
| 301 |
return Image.fromarray(overlay), temp_mask_file.name
|
| 302 |
|
| 303 |
# ===== 计数功能 =====
|
|
|
|
| 304 |
def count_cells_handler(use_box_choice, annot_value):
|
| 305 |
"""Counting handler - supports bounding box, returns only density map"""
|
| 306 |
if annot_value is None or len(annot_value) < 1:
|
|
@@ -704,7 +707,7 @@ def create_tracking_visualization(tif_dir, output_dir, valid_tif_files):
|
|
| 704 |
except:
|
| 705 |
return valid_tif_files[0]
|
| 706 |
|
| 707 |
-
|
| 708 |
def track_video_handler(use_box_choice, first_frame_annot, zip_file_obj):
|
| 709 |
"""
|
| 710 |
支持 ZIP 压缩包上传的 Tracking 处理函数 - 支持首帧边界框
|
|
|
|
| 16 |
from glob import glob
|
| 17 |
from natsort import natsorted
|
| 18 |
from huggingface_hub import HfApi, upload_file
|
| 19 |
+
import spaces
|
| 20 |
|
| 21 |
# ===== 导入三个推理模块 =====
|
| 22 |
from inference_seg import load_model as load_seg_model, run as run_seg
|
|
|
|
| 211 |
return palette_arr[color_idx]
|
| 212 |
|
| 213 |
# ===== 分割功能 =====
|
| 214 |
+
@spaces.GPU
|
| 215 |
def segment_with_choice(use_box_choice, annot_value):
|
| 216 |
"""分割主函数 - 每个实例不同颜色+轮廓"""
|
| 217 |
if annot_value is None or len(annot_value) < 1:
|
|
|
|
| 303 |
return Image.fromarray(overlay), temp_mask_file.name
|
| 304 |
|
| 305 |
# ===== 计数功能 =====
|
| 306 |
+
@spaces.GPU
|
| 307 |
def count_cells_handler(use_box_choice, annot_value):
|
| 308 |
"""Counting handler - supports bounding box, returns only density map"""
|
| 309 |
if annot_value is None or len(annot_value) < 1:
|
|
|
|
| 707 |
except:
|
| 708 |
return valid_tif_files[0]
|
| 709 |
|
| 710 |
+
@spaces.GPU
|
| 711 |
def track_video_handler(use_box_choice, first_frame_annot, zip_file_obj):
|
| 712 |
"""
|
| 713 |
支持 ZIP 压缩包上传的 Tracking 处理函数 - 支持首帧边界框
|