Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,7 +20,7 @@ except Exception as e:
|
|
| 20 |
app = Flask(__name__, static_folder="static", static_url_path="/")
|
| 21 |
|
| 22 |
# HF checkpoint raw resolve URL (use the 'resolve/main' raw link)
|
| 23 |
-
CHECKPOINT_URL = "https://huggingface.co/Subh775/Segment-Tulsi-TFs-
|
| 24 |
CHECKPOINT_PATH = os.path.join("/tmp", "checkpoint_best_total.pth")
|
| 25 |
|
| 26 |
MODEL_LOCK = threading.Lock()
|
|
@@ -79,7 +79,7 @@ def encode_pil_to_dataurl(pil_img: Image.Image, fmt="PNG"):
|
|
| 79 |
b = base64.b64encode(buf.getvalue()).decode("ascii")
|
| 80 |
return f"data:image/{fmt.lower()};base64,{b}"
|
| 81 |
|
| 82 |
-
def overlay_mask_on_image(pil_img: Image.Image, masks, confidences, threshold=0.
|
| 83 |
"""
|
| 84 |
masks: either list of HxW bool arrays or numpy array (N,H,W)
|
| 85 |
confidences: list of floats
|
|
|
|
| 20 |
app = Flask(__name__, static_folder="static", static_url_path="/")
|
| 21 |
|
| 22 |
# HF checkpoint raw resolve URL (use the 'resolve/main' raw link)
|
| 23 |
+
CHECKPOINT_URL = "https://huggingface.co/Subh775/Segment-Tulsi-TFs-3/resolve/main/checkpoint_best_total.pth"
|
| 24 |
CHECKPOINT_PATH = os.path.join("/tmp", "checkpoint_best_total.pth")
|
| 25 |
|
| 26 |
MODEL_LOCK = threading.Lock()
|
|
|
|
| 79 |
b = base64.b64encode(buf.getvalue()).decode("ascii")
|
| 80 |
return f"data:image/{fmt.lower()};base64,{b}"
|
| 81 |
|
| 82 |
+
def overlay_mask_on_image(pil_img: Image.Image, masks, confidences, threshold=0.01, mask_color=(255,77,166), alpha=0.45):
|
| 83 |
"""
|
| 84 |
masks: either list of HxW bool arrays or numpy array (N,H,W)
|
| 85 |
confidences: list of floats
|