mirror of
https://github.com/gaomingqi/Track-Anything.git
synced 2025-12-16 08:27:49 +01:00
for beta to merge -- li
This commit is contained in:
17
app.py
17
app.py
@@ -13,10 +13,9 @@ import requests
|
|||||||
import json
|
import json
|
||||||
import torchvision
|
import torchvision
|
||||||
import torch
|
import torch
|
||||||
from tools.interact_tools import SamControler
|
|
||||||
from tracker.base_tracker import BaseTracker
|
|
||||||
from tools.painter import mask_painter
|
from tools.painter import mask_painter
|
||||||
import psutil
|
import psutil
|
||||||
|
import time
|
||||||
try:
|
try:
|
||||||
from mmcv.cnn import ConvModule
|
from mmcv.cnn import ConvModule
|
||||||
except:
|
except:
|
||||||
@@ -82,7 +81,7 @@ def get_frames_from_video(video_input, video_state):
|
|||||||
"""
|
"""
|
||||||
video_path = video_input
|
video_path = video_input
|
||||||
frames = []
|
frames = []
|
||||||
|
user_name = time.time()
|
||||||
operation_log = [("",""),("Upload video already. Try click the image for adding targets to track and inpaint.","Normal")]
|
operation_log = [("",""),("Upload video already. Try click the image for adding targets to track and inpaint.","Normal")]
|
||||||
try:
|
try:
|
||||||
cap = cv2.VideoCapture(video_path)
|
cap = cv2.VideoCapture(video_path)
|
||||||
@@ -103,6 +102,7 @@ def get_frames_from_video(video_input, video_state):
|
|||||||
image_size = (frames[0].shape[0],frames[0].shape[1])
|
image_size = (frames[0].shape[0],frames[0].shape[1])
|
||||||
# initialize video_state
|
# initialize video_state
|
||||||
video_state = {
|
video_state = {
|
||||||
|
"user_name": user_name,
|
||||||
"video_name": os.path.split(video_path)[-1],
|
"video_name": os.path.split(video_path)[-1],
|
||||||
"origin_images": frames,
|
"origin_images": frames,
|
||||||
"painted_images": frames.copy(),
|
"painted_images": frames.copy(),
|
||||||
@@ -375,8 +375,8 @@ folder ="./checkpoints"
|
|||||||
SAM_checkpoint = download_checkpoint(sam_checkpoint_url, folder, sam_checkpoint)
|
SAM_checkpoint = download_checkpoint(sam_checkpoint_url, folder, sam_checkpoint)
|
||||||
xmem_checkpoint = download_checkpoint(xmem_checkpoint_url, folder, xmem_checkpoint)
|
xmem_checkpoint = download_checkpoint(xmem_checkpoint_url, folder, xmem_checkpoint)
|
||||||
e2fgvi_checkpoint = download_checkpoint_from_google_drive(e2fgvi_checkpoint_id, folder, e2fgvi_checkpoint)
|
e2fgvi_checkpoint = download_checkpoint_from_google_drive(e2fgvi_checkpoint_id, folder, e2fgvi_checkpoint)
|
||||||
# args.port = 12214
|
# args.port = 12212
|
||||||
# args.device = "cuda:2"
|
# args.device = "cuda:1"
|
||||||
# args.mask_save = True
|
# args.mask_save = True
|
||||||
|
|
||||||
# initialize sam, xmem, e2fgvi models
|
# initialize sam, xmem, e2fgvi models
|
||||||
@@ -409,6 +409,7 @@ with gr.Blocks() as iface:
|
|||||||
|
|
||||||
video_state = gr.State(
|
video_state = gr.State(
|
||||||
{
|
{
|
||||||
|
"user_name": "",
|
||||||
"video_name": "",
|
"video_name": "",
|
||||||
"origin_images": None,
|
"origin_images": None,
|
||||||
"painted_images": None,
|
"painted_images": None,
|
||||||
@@ -532,6 +533,8 @@ with gr.Blocks() as iface:
|
|||||||
video_input.clear(
|
video_input.clear(
|
||||||
lambda: (
|
lambda: (
|
||||||
{
|
{
|
||||||
|
"user_name": "",
|
||||||
|
"video_name": "",
|
||||||
"origin_images": None,
|
"origin_images": None,
|
||||||
"painted_images": None,
|
"painted_images": None,
|
||||||
"masks": None,
|
"masks": None,
|
||||||
@@ -593,5 +596,5 @@ with gr.Blocks() as iface:
|
|||||||
# cache_examples=True,
|
# cache_examples=True,
|
||||||
)
|
)
|
||||||
iface.queue(concurrency_count=1)
|
iface.queue(concurrency_count=1)
|
||||||
# iface.launch(debug=True, enable_queue=True, server_port=args.port, server_name="0.0.0.0")
|
iface.launch(debug=True, enable_queue=True, server_port=args.port, server_name="0.0.0.0")
|
||||||
iface.launch(debug=True, enable_queue=True)
|
# iface.launch(debug=True, enable_queue=True)
|
||||||
Reference in New Issue
Block a user