mirror of
https://github.com/gaomingqi/Track-Anything.git
synced 2025-12-16 00:17:50 +01:00
controler, sam , xmem
This commit is contained in:
2
app.py
2
app.py
@@ -149,7 +149,7 @@ with gr.Blocks() as iface:
|
||||
)
|
||||
|
||||
iface.queue(concurrency_count=1)
|
||||
iface.launch(debug=True, enable_queue=True, server_port=122, server_name="0.0.0.0")
|
||||
iface.launch(debug=True, enable_queue=True, server_port=12200, server_name="0.0.0.0")
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ def download_checkpoint(url, folder, filename):
|
||||
return filepath
|
||||
|
||||
class SamControler():
|
||||
def __init__(self):
|
||||
def __init__(self, sam_checkpoint, model_type, device):
|
||||
'''
|
||||
initialize sam controler
|
||||
'''
|
||||
|
||||
@@ -1,12 +1,28 @@
|
||||
from tools.interact_tools import SamControler
|
||||
from tracker.xmem import XMem
|
||||
|
||||
from tracker.base_tracker import BaseTracker
|
||||
import numpy as np
|
||||
|
||||
|
||||
|
||||
class TrackingAnything():
|
||||
def __init__(self, cfg):
|
||||
self.cfg = cfg
|
||||
self.samcontroler = SamControler()
|
||||
self.xmem =
|
||||
pass
|
||||
self.samcontroler = SamControler(cfg.sam_checkpoint, cfg.model_type, cfg.device)
|
||||
self.xmem = BaseTracker(cfg.device, cfg.xmem_checkpoint)
|
||||
|
||||
|
||||
def inference_step(self, first_flag: bool, interact_flag: bool, image: np.ndarray,
|
||||
same_image_flag: bool, points:np.ndarray, labels: np.ndarray, logits: np.ndarray=None, multimask=True):
|
||||
if first_flag:
|
||||
mask, logit, painted_image = self.samcontroler.first_frame_click(image, points, labels, multimask)
|
||||
return mask, logit, painted_image
|
||||
|
||||
if interact_flag:
|
||||
mask, logit, painted_image = self.samcontroler.interact_loop(image, same_image_flag, points, labels, logits, multimask)
|
||||
return mask, logit, painted_image
|
||||
|
||||
mask, logit, painted_image = self.xmem.track(image, logit)
|
||||
return mask, logit, painted_image
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user