1 Star 0 Fork 20

绒花雪冷/RobustVideoMattingGUI

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
sctoolglobal.py 2.77 KB
一键复制 编辑 原始数据 按行查看 历史
天涯 提交于 2023-10-10 13:24 . modified: README.md
'''
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",
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/getready/RobustVideoMatting.git
git@gitee.com:getready/RobustVideoMatting.git
getready
RobustVideoMatting
RobustVideoMattingGUI
RVMGUI.SCTOOL

搜索帮助