代码拉取完成,页面将自动刷新
同步操作将从 天涯/RobustVideoMattingGUI 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
'''
file name: File name
Data: Do not edit
LastEditors: YuanMing
LastEditTime: 2023-10-10 10:22:49
Describe:
'''
import requests
import os
import ffmpeg
from tqdm import tqdm
def isFileExist(path):
if os.path.exists(path) == True:
if os.path.isfile(path) == True:
return True
pass
else:
return False
pass
pass
else:
return False
pass
pass
#检查目录是否存在
def isDirExist(path):
if os.path.exists(path) == True:
if os.path.isdir(path) == True:
return True
pass
else:
return False
pass
pass
else:
return False
pass
pass
def resolve_relative_path(path: str) -> str:
return os.path.abspath(os.path.join(os.path.dirname(__file__), path))
def download(url: str, fname: str):
# 用流stream的方式获取url的数据
resp = requests.get(url, stream=True)
# 拿到文件的长度,并把total初始化为0
total = int(resp.headers.get('content-length', 0))
# 打开当前目录的fname文件(名字你来传入)
# 初始化tqdm,传入总数,文件名等数据,接着就是写入,更新等操作了
with open(fname, 'wb') as file, tqdm(
desc=fname,
total=total,
unit='iB',
unit_scale=True,
unit_divisor=1024,
) as bar:
for data in resp.iter_content(chunk_size=1024):
size = file.write(data)
bar.update(size)
#获取视频文件的相关信息
def getVideoFileInfo(filepath):
videofileinfo={}
videofileinfo['isExist']=False
if isFileExist(filepath) == False:
return videofileinfo
videofileinfo['isExist']=True
finfo=ffmpeg.probe(filename=filepath,cmd="./Dependencies/ffmpeg/ffprobe.exe")
vs = next(c for c in finfo['streams'] if c['codec_type'] == 'video')
format_name = finfo['format']['format_name']
videofileinfo['codec_name'] = vs['codec_name']
duration_ts = float(vs['duration_ts'])
videofileinfo['fps'] = float(eval(vs['r_frame_rate']))
width = vs['width']
height = vs['height']
videofileinfo['bit_rate']=vs['bit_rate']
# print("format_name:{} \ncodec_name:{} \nduration_ts:{} \nwidth:{} \nheight:{} \nfps:{}".format(format_name, codec_name, duration_ts, width, height, fps))
return videofileinfo
pass
aot_args = {
'phase': 'PRE_YTB_DAV',
'model': 'r50_deaotl',
'model_path': './AOT/pretrain_models/R50_DeAOTL_PRE_YTB_DAV.pth',
'long_term_mem_gap': 9999,
'max_len_long_term': 9999,
'gpu_id': 0,
}
aot_model2ckpt = {
"deaotb": "./AOT/pretrain_models/DeAOTB_PRE_YTB_DAV.pth",
"deaotl": "./AOT/pretrain_models/DeAOTL_PRE_YTB_DAV",
"r50_deaotl": "./models/AOT_models/R50_DeAOTL_PRE_YTB_DAV.pth",
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。