其实当我们使用vot-toolkit-python的时候,在初始化workspace时会自动下载对应stack的数据集,比如在vot/stack下会有这么几种可以选择:


但是现在我们想抽出来自己下载,因为可能网不好,不能一口气下完,所以抽出来能够可控性更大,所以我把抽出来的直接可以运行的代码放在下面,大家可以试用一下,有问题的可以在评论区反馈。

download_vot_dataset.py自动下载

import os
from tqdm import tqdm
import six
import csv
import requests
from urllib.parse import urlparse, urljoin
import tempfile
import shutil# see: https://github.com/votchallenge/toolkit/tree/master/vot/stack
VOT_DATASETS = {"vot2013" : "http://data.votchallenge.net/vot2013/dataset/description.json","vot2014" : "http://data.votchallenge.net/vot2014/dataset/description.json","vot2015" : "http://data.votchallenge.net/vot2015/dataset/description.json","vot-tir2015" : "http://www.cvl.isy.liu.se/research/datasets/ltir/version1.0/ltir_v1_0_8bit.zip","vot2016" : "http://data.votchallenge.net/vot2016/main/description.json","vot-tir2016" : "http://data.votchallenge.net/vot2016/vot-tir2016.zip","vot2017" : "http://data.votchallenge.net/vot2017/main/description.json","vot-st2018" : "http://data.votchallenge.net/vot2018/main/description.json","vot-lt2018" : "http://data.votchallenge.net/vot2018/longterm/description.json","vot-st2019" : "http://data.votchallenge.net/vot2019/main/description.json","vot-lt2019" : "http://data.votchallenge.net/vot2019/longterm/description.json","vot-rgbd2019" : "http://data.votchallenge.net/vot2019/rgbd/description.json","vot-rgbt2019" : "http://data.votchallenge.net/vot2019/rgbtir/meta/description.json","vot-st2020" : "https://data.votchallenge.net/vot2020/shortterm/description.json","vot-rgbt2020" : "http://data.votchallenge.net/vot2020/rgbtir/meta/description.json","vot-st2021": "https://data.votchallenge.net/vot2021/shortterm/description.json","test" : "http://data.votchallenge.net/toolkit/test.zip","segmentation" : "http://box.vicos.si/tracking/vot20_test_dataset.zip","vot2022/rgbd": "https://data.votchallenge.net/vot2022/rgbd/description.json","vot2022/depth": "https://data.votchallenge.net/vot2022/depth/description.json","vot2022/stb": "https://data.votchallenge.net/vot2022/stb/description.json","vot2022/sts": "https://data.votchallenge.net/vot2022/sts/description.json","vot2022/lt": "https://data.votchallenge.net/vot2022/lt/description.json"
}def download_dataset(name, path=".", existed=None):# name: eg. vot-st2020# path: eg. xxx/workspace/sequencesif not name in VOT_DATASETS:raise ValueError("Unknown dataset")url = VOT_DATASETS[name]# url: "https://data.votchallenge.net/vot2020/shortterm/description.json"meta = download_json(url)print(f'Downloading sequence dataset "{meta["name"]}" with {len(meta["sequences"])} sequences.')base_url = get_base_url(url) + "/"  # "http://data.votchallenge.net/vot2019/rgbd/"with Progress("Downloading", len(meta["sequences"])) as progress:for sequence in meta["sequences"]:if existed is not None and sequence["name"] in existed:continuesequence_directory = os.path.join(path, sequence["name"])os.makedirs(sequence_directory, exist_ok=True)data = {'name': sequence["name"], 'fps': sequence["fps"], 'format': 'default'}annotations_url = join_url(base_url, sequence["annotations"]["url"])  # 'https://zenodo.org/record/2640900/files/backpack_blue.zip'try:download_uncompress(annotations_url,sequence_directory)  # xxx/workspace/sequences/backpack_robotarm_lab_occexcept Exception as e:raise Exception("Unable do download annotations bundle")except IOError as e:raise Exception("Unable to extract annotations bundle, is the target directory writable and do you have enough space?")for cname, channel in sequence["channels"].items():channel_directory = os.path.join(sequence_directory, cname)os.makedirs(channel_directory, exist_ok=True)channel_url = join_url(base_url, channel["url"])try:download_uncompress(channel_url, channel_directory)except Exception as e:raise Exception("Unable do download channel bundle")except IOError as e:raise Exception("Unable to extract channel bundle, is the target directory writable and do you have enough space?")if "pattern" in channel:data["channels." + cname] = cname + os.path.sep + channel["pattern"]else:data["channels." + cname] = cname + os.path.sepwrite_properties(os.path.join(sequence_directory, 'sequence'), data)progress.relative(1)with open(os.path.join(path, "list.txt"), "w") as fp:for sequence in meta["sequences"]:fp.write('{}\n'.format(sequence["name"]))def download_json(url):try:return requests.get(url).json()except requests.exceptions.RequestException as e:raise Exception("Unable to read JSON file {}".format(e))def get_base_url(url):return url.rsplit('/', 1)[0]def is_absolute_url(url):return bool(urlparse(url).netloc)def join_url(url_base, url_path):if is_absolute_url(url_path):return url_pathreturn urljoin(url_base, url_path)def extract_files(archive, destination, callback = None):from zipfile import ZipFilewith ZipFile(file=archive) as zip_file:# Loop over each filetotal=len(zip_file.namelist())for file in zip_file.namelist():# Extract each file to another directory# If you want to extract to current working directory, don't specify pathzip_file.extract(member=file, path=destination)if callback:callback(1, total)def download_uncompress(url, path):_, ext = os.path.splitext(urlparse(url).path)tmp_file = tempfile.mktemp(suffix=ext)try:download(url, tmp_file)extract_files(tmp_file, path)finally:if os.path.exists(tmp_file):os.unlink(tmp_file)def download(url, output, callback=None, chunk_size=1024 * 32):with requests.session() as sess:while True:res = sess.get(url, stream=True)if not res.status_code == 200:raise Exception("File not available")if 'Content-Disposition' in res.headers:# This is the filebreakbreakif output is None:output = os.path.basename(url)output_is_path = isinstance(output, str)if output_is_path:tmp_file = tempfile.mktemp()filehandle = open(tmp_file, 'wb')else:tmp_file = Nonefilehandle = outputtry:total = res.headers.get('Content-Length')if total is not None:total = int(total)for chunk in res.iter_content(chunk_size=chunk_size):filehandle.write(chunk)if callback:callback(len(chunk), total)if tmp_file:filehandle.close()shutil.copy(tmp_file, output)except IOError:raise Exception("Error when downloading file")finally:try:if tmp_file:os.remove(tmp_file)except OSError:passreturn outputclass Progress(object):class StreamProxy(object):def write(self, x):# Avoid print() second call (useless \n)if len(x.rstrip()) > 0:tqdm.write(x)def flush(self):# return getattr(self.file, "flush", lambda: None)()pass@staticmethoddef logstream():return Progress.StreamProxy()def __init__(self, description="Processing", total=100):silent = Falseif not silent:self._tqdm = tqdm(disable=None,bar_format=" {desc:20.20} |{bar}| {percentage:3.0f}% [{elapsed}<{remaining}]")self._tqdm.desc = descriptionself._tqdm.total = totalif silent or self._tqdm.disable:self._tqdm = Noneself._value = 0self._total = total if not silent else 0def _percent(self, n):return int((n * 100) / self._total)def absolute(self, value):if self._tqdm is None:if self._total == 0:returnprev = self._valueself._value = max(0, min(value, self._total))if self._percent(prev) != self._percent(self._value):print("%d %%" % self._percent(self._value))else:self._tqdm.update(value - self._tqdm.n)  # will also set self.n = b * bsizedef relative(self, n):if self._tqdm is None:if self._total == 0:returnprev = self._valueself._value = max(0, min(self._value + n, self._total))if self._percent(prev) != self._percent(self._value):print("%d %%" % self._percent(self._value))else:self._tqdm.update(n)  # will also set self.n = b * bsizedef total(self, t):if self._tqdm is None:if self._total == 0:returnself._total = telse:if self._tqdm.total == t:returnself._tqdm.total = tself._tqdm.refresh()def __enter__(self):return selfdef __exit__(self, exc_type, exc_value, traceback):self.close()def close(self):if self._tqdm:self._tqdm.close()def write_properties(filename, dictionary, delimiter='='):''' Writes the provided dictionary in key sorted order to a propertiesfile with each line in the format: key<delimiter>valuefilename -- the name of the file to be writtendictionary -- a dictionary containing the key/value pairs.'''open_kwargs = {'mode': 'w', 'newline': ''} if six.PY3 else {'mode': 'wb'}with open(filename, **open_kwargs) as csvfile:writer = csv.writer(csvfile, delimiter=delimiter, escapechar='\\',quoting=csv.QUOTE_NONE)writer.writerows(sorted(dictionary.items()))if __name__ == '__main__':NAME = 'vot-st2020'SAVE_DIR = '/home/lz/dataset'Existed_Seqs = ['agility', 'ants1', 'ball2', 'ball3', 'basketball', 'birds1', 'bolt1', 'book', 'butterfly', 'car1']download_dataset(name=NAME, path=SAVE_DIR, existed=Existed_Seqs)

这里有几点说明一下:

  • NAME:就是你想要下载的stack的名字,具体可以看脚本最上方的VOT_DATASETS字典的键
  • SAVE_DIR:就是你想要保存的路径目录
  • Existed_Seqs:比如你上次因为断电或断网中断了下载,但是你可以填上已经下好的序列名列表,就不用重复下载这些序列了

注意这里面链接后缀为json可以用上面的方法,为.zip就直接手动复制下吧。

get_links.py手动下载

如果你上面的脚本下载速度很慢,可以运行下面的脚本获取到下载序列的url,自己复制到浏览器里面手动下载。或者上面自动下载卡在一个序列了,就可以把这个序列下载好放到上面的SAVE_DIR里面,然后在Existed_Seqs填上这个序列,然后再自动下载也行:

import os
import requests
from urllib.parse import urlparse, urljoindef is_absolute_url(url):return bool(urlparse(url).netloc)def join_url(url_base, url_path):if is_absolute_url(url_path):return url_pathreturn urljoin(url_base, url_path)VOT_DATASETS = {"vot2013" : "http://data.votchallenge.net/vot2013/dataset/description.json","vot2014" : "http://data.votchallenge.net/vot2014/dataset/description.json","vot2015" : "http://data.votchallenge.net/vot2015/dataset/description.json","vot-tir2015" : "http://www.cvl.isy.liu.se/research/datasets/ltir/version1.0/ltir_v1_0_8bit.zip","vot2016" : "http://data.votchallenge.net/vot2016/main/description.json","vot-tir2016" : "http://data.votchallenge.net/vot2016/vot-tir2016.zip","vot2017" : "http://data.votchallenge.net/vot2017/main/description.json","vot-st2018" : "http://data.votchallenge.net/vot2018/main/description.json","vot-lt2018" : "http://data.votchallenge.net/vot2018/longterm/description.json","vot-st2019" : "http://data.votchallenge.net/vot2019/main/description.json","vot-lt2019" : "http://data.votchallenge.net/vot2019/longterm/description.json","vot-rgbd2019" : "http://data.votchallenge.net/vot2019/rgbd/description.json","vot-rgbt2019" : "http://data.votchallenge.net/vot2019/rgbtir/meta/description.json","vot-st2020" : "https://data.votchallenge.net/vot2020/shortterm/description.json","vot-rgbt2020" : "http://data.votchallenge.net/vot2020/rgbtir/meta/description.json","vot-st2021": "https://data.votchallenge.net/vot2021/shortterm/description.json","test" : "http://data.votchallenge.net/toolkit/test.zip","segmentation" : "http://box.vicos.si/tracking/vot20_test_dataset.zip"
}
stack = "vot-rgbd2019"
url = VOT_DATASETS[stack]
base_url = url.rsplit('/', 1)[0] + "/"
try:meta = requests.get(url).json()
except requests.exceptions.RequestException as e:raise Exception("Unable to read JSON file {}".format(e))for sequence in meta["sequences"]:seq_url = sequence["annotations"]["url"]download_url = join_url(base_url, seq_url)print(f'Download annotations at: {download_url}')for cname, channel in sequence["channels"].items():channel_url = join_url(base_url, channel["url"])print(f'Download {cname} zip at: {channel_url}')print("===========================================")

这里也就是把stack替换成你自己想要的就行。

生成sequence文件

可以发现自动下载的里面每个都会有个名叫sequence的文件,里面的信息长下面这样,还有个list.txt

所以我们还得写个脚本生成一下,也很容易

generate_file.py

import requests
import os
import six
import csv
def download_json(url):try:return requests.get(url).json()except requests.exceptions.RequestException as e:raise Exception("Unable to read JSON file {}".format(e))def write_properties(filename, dictionary, delimiter='='):''' Writes the provided dictionary in key sorted order to a propertiesfile with each line in the format: key<delimiter>valuefilename -- the name of the file to be writtendictionary -- a dictionary containing the key/value pairs.'''open_kwargs = {'mode': 'w', 'newline': ''} if six.PY3 else {'mode': 'wb'}with open(filename, **open_kwargs) as csvfile:writer = csv.writer(csvfile, delimiter=delimiter, escapechar='\\',quoting=csv.QUOTE_NONE)writer.writerows(sorted(dictionary.items()))
stack = "" # your choice
url = VOT_DATASETS[stack]
meta = download_json(url)
root = '' # your choice
for sequence in meta["sequences"]:sequence_directory = os.path.join(root, sequence['name'])write_path = os.path.join(sequence_directory, 'sequence')if os.path.exists(write_path):print(f"{sequence['name']} has existed!")continueprint(f"Writing {sequence['name']}")data = {'name': sequence["name"], 'fps': sequence["fps"], 'format': 'default'}for cname, channel in sequence["channels"].items():if "pattern" in channel:data["channels." + cname] = cname + os.path.sep + channel["pattern"]else:data["channels." + cname] = cname + os.path.sepwrite_properties(write_path, data)
with open(os.path.join(root, "list.txt"), "w") as fp:for sequence in meta["sequences"]:fp.write('{}\n'.format(sequence["name"]))

VOT数据集自动/手动下载相关推荐

  1. Fluid 0.6 版本发布:数据感知的Pod调度与数据集自动弹性扩缩容

    简介:Fluid 是 CNCF 基金会旗下云原生环境中数据密集型应用的高效支撑平台,由南京大学.阿里云云原生团队以及 Alluxio 开源社区联合发起.项目自开源发布以来吸引了众多相关方向领域专家和工 ...

  2. windows下的VOT数据集配置

    windows下的VOT数据集配置 一.运行环境 二.预先下载 1.VOT-toolkit 2.Trax 3.ncc 4.VOT数据集 三.正文开始 1.文件位置 2.创建workspace 3.配置 ...

  3. Dataset之MNIST:MNIST(手写数字图片识别+ubyte.gz文件)数据集简介、下载、使用方法(包括数据增强)之详细攻略

    Dataset之MNIST:MNIST(手写数字图片识别+ubyte.gz文件)数据集简介+数据增强(将已有MNIST数据集通过移动像素上下左右的方法来扩大数据集为初始数据集的5倍) 目录 MNIST ...

  4. Linux 下离线手动下载安装 C++ 开发环境

    1.前言 本人使用的操作系统是 Fedora 24. 1.1 在线安装软件的方法 Linux 下我们习惯了使用软件包管理器来安装我们需要的软件,比如 Red Hat 公司的 Fedora.RHEL(R ...

  5. maven的依赖下载不下来,解决的几种方法(包括手动下载导入)

    问题: 项目是从跟着B站的尚融宝项目进行的,但是刚开始添加依赖那一步就出现了很多问题,有些依赖死活下载不下来,我百度整理了一个早上,基本解决了.相信有很多人跟我一样出现过这些问题,这里可以提供一些解决 ...

  6. VOT数据集报错问题

    使用pysot评估VOT数据集时,训练结果保存在如下文件夹 The testing results will in the current directory(results/dataset/mode ...

  7. 单目标跟踪OTB、VOT数据集介绍

    OTB分为:OTB50和OTB100 官方下载链接为:OTB官方数据集网站 http://cvlab.hanyang.ac.kr/tracker_benchmark/datasets.html 百度云 ...

  8. OTB数据集和VOT数据集融合跟踪算法接口示例

    OTB数据集和VOT数据集自己存数据接口参考代码: 一.OTB数据集(不使用tracker_benchmark_v1.0) 1.OTB数据结果最基本的格式 type为目标框类型: res为目标框的所在 ...

  9. 目标跟踪评估绘图(3):ubuntu18.04在MATLAB2016b下的vot-toolkit配置,绘制VOT数据集的EAO评估图,与其他算法进行比较

    本文的视频讲解目标跟踪_OTB数据集和VOT数据集评估图的绘制 博主电脑配置: CPU:酷睿i9-9900kf, 显卡:RTX2070S, gcc版本:7.5.0, 以下实验在MATLAB2016b平 ...

  10. 遥感影像云检测-云检测数据集信息及下载

    常用云检测数据集信息及下载 1.LandSat7云量评估数据集 2.LandSat8-Biome生物群落云量评估数据集 3.LandSat8-38Cloud数据集 4.高分系列-GF1-WHU遥感影像 ...

最新文章

  1. json_encode 中文不乱码
  2. 模拟 POJ 2632 Crashing Robots
  3. npm package.json文件中的依赖关系,devDependencies和peerDependencies之间有什么区别?
  4. 区块链BaaS云服务(21)腾讯CCGP跨链平台“系统架构”
  5. 计算机错误2 找不到指定文件,无法执行目录中的文件 错误2系统找不到指定文件怎么办?...
  6. 让OpenCV2.4.9支持虚拟环境python3.5
  7. python中的doc_在windows 10上读取python中的.doc文件
  8. python中二维数组如何查找_【剑指offer】---二维数组中的查找(Python)
  9. ES5实现ES6的一些方法-call,bind,is,promise
  10. 测试设备和Android机怎么传递消息,在运行2.3的设备上进行测试时,android-Activit......
  11. IN与EXISTS优化
  12. PowerMock简单使用
  13. Ceph浅析”系列之四——Ceph的结构
  14. php dwg文件,dwf文件怎么转成dwg
  15. SAR变化检测的性能指标(kappa系数)——简化版
  16. 青年志愿者演讲稿范⽂5篇
  17. Echarts图的图例为自定义图片
  18. 程序员必看:一款巨好用的免费简历“神器”(据说有了它,再也不发愁找工作啦!)
  19. 全国信息竞赛语言有python吗_2019年全国信息学竞赛有哪些
  20. 家用千兆路由器排行榜前十名_求家用路由器排名前十名,有哪些比较推荐?

热门文章

  1. [Usaco2010 Dec]Treasure Chest 藏宝箱
  2. Linux下几种文件传输命令
  3. 2020叉车司机考试及叉车司机模拟考试题库
  4. CodeForces 581A Vasya the Hipster
  5. 数字类型与列表——python
  6. win10如何一键还原系统
  7. win10计算机恢复到一天前,win10怎么系统还原到某一时刻 win10系统还原之后会怎么样...
  8. 悲伤是一种毒,会上瘾
  9. Redis的数据变成backup
  10. .ipynb_checkpoints隐藏文件引发的错误