Code Monkey home page Code Monkey logo

comyco's Introduction

Comyco

July 22, 2023: For Comyco with linear-based QoE, please refer to https://github.com/godka/comyco-lin.

This is a simple Tensorflow implementation of

  • Comyco: Quality-Aware Adaptive Video Streaming via Imitation Learning
  • PiTree: Practical Implementation of ABR Algorithms Using Decision Trees

Cite

If you find this work useful to you, please cite the conference version:

@inproceedings{huang2019comyco,
  title={Comyco: Quality-Aware Adaptive Video Streaming via Imitation Learning},
  author={Huang, Tianchi and Zhou, Chao and Zhang, Rui-Xiao and Wu, Chenglei and Yao, Xin and Sun, Lifeng},
  booktitle={Proceedings of the 27th ACM International Conference on Multimedia},
  pages={429--437},
  year={2019},
  organization={ACM}
}

or the arXiv version:

@article{huang2019comyco,
  title={Comyco: Quality-Aware Adaptive Video Streaming via Imitation Learning},
  author={Huang, Tianchi and Zhou, Chao and Zhang, Rui-Xiao and Wu, Chenglei and Yao, Xin and Sun, Lifeng},
  journal={arXiv preprint arXiv:1908.02270},
  year={2019}
}

What's Comyco

Comyco is a video quality-aware ABR approach that enormously improves the learning-based methods by tackling the issues, i.e., low sample efficiency and lacks video quality information. Comyco trains the policy via imitating expert trajectories given by the instant solver, which can not only avoid redundant exploration but also make better use of the collected samples. Meanwhile, Comyco attempts to pick the chunk with higher perceptual video qualities rather than video bitrates. To achieve this, we construct Comyco's neural network architecture, video datasets and QoE metrics with video quality features.

Quick Start

Steps to train and test Comyco:

Requirements

This work is based on python3.6+. You can also use python 2.7 instead. Run the following command to install dependencies.

pip install numpy tensorflow tflearn sklearn swig

Instant Solver

Please note that the instant solver is written by c++. To build this module, you need to install g++ first. We pre-build the module for two platforms, i.e., Windows (_envcpp.pyd) and Linux (_envcpp.so). The source code of instant solver is demonstrated in cpp-windows/ and cpp-linux/.

For Windows users, please install Swig and Visual Studio 2017.

swig -c++ -python abr.i

For Linux users, please install Swig and type this code.

swig -c++ -python abr.i

g++ abr_wrap.cxx env.cpp -fPIC -shared -I /usr/include/python2.7/ -L /usr/lib/python2.7 -o _envcpp.so -O4

Note: Windows is the recommended platform.

Pretrained model

If you have trouble on building the environment, we also publish the pretrained model for Comyco and Comyco-Pitree in results/pretrained/.

Try to type these code to evaluate Comyco.

cd src

python rl_test.py ../results/pretrained/pretrain.ckpt

And, for Comyco-pitree

cd src

python dt_test.py ../results/pretrained/pretrain-pitree.model

How to train Comyco

We provide a relatively simple Comyco which uses i) the same network traces of Pensieve's public repo; ii) only Envivo video dataset rather than 86 video dataset; iii) single agent version.

Detailed implementation are demonstrated in libcomyco.py. You can type these code to retrain Comyco.

cd src/

python train.py

The model will be automatically validated and saved in results.log during the training process (10 epoches).

Besides, we also provide several ABR baselines, including, Pensieve-retrained (via QoE_v) [we exclude this work in this repo since it's somewhat a big guy.], Supervised, and RobustMPC (cpp-linux/mpc.cpp). Comyco with single agent's training time will last about only 20 - 40 minutes if you are lucky enough.

How to train Comyco-Pitree

Moreover, we also implement Comyco-Pitree w.r.t the original paper. Specifically, we only use 4 critical features, i.e., last chunk's VMAF score, current buffer occupancy, average throughput, std throughput. We train Comyco-Pitree via directly imitating the expert answer generated by instant solver. Moreover, we leverage a simple yet effective entropy trick for better exploration (entropy < 0.3: randomly picks an action; entropy >= 0.3: roulette algorithm).

Surprisingly, Comyco-Pitree achieves comparable result compared with Pensieve. You can type these code to retrain Comyco-Pitree, and the trained model will be stored in src/pitree/.

cd src/
python train_dt.py

Unlike Comyco, the Comyco-Pitree's training time will take almost 10 - 12 hours. The visualization of Comyco-Pitree is shown like this.

overview

Comyco-Pitree Code

Besides, you can type these code to convert tree-model to python code.

cd src/

python code.py

The python code of pretrained Comyco-Pitree is described as follows.

# src/tree/comyco-pitree.py
def predict(last_vmaf, buf, thr_avg, thr_std):
  if thr_avg <= 0.1278446540236473:
    if thr_avg <= 0.07279053330421448:
      if buf <= 5.917577266693115:
        if thr_std <= 0.006877874955534935:
          if thr_avg <= 0.048280853778123856:
            if thr_std <= 0.0019393544062040746:
              return [1723, 32, 5, 0, 0, 0]
...

Feb. 5th Updated

Video Description Dataset

To better improve Comyco’s generalization ability, we propose a video quality DASH dataset involves movies, sports, TV-shows, games, news and MVs. Specifically, we first collect video clips with the highest resolution from Youtube, then leverage FFmpeg to encode the video by H.264 codec and MP4Box to dashify videos according to the encoding ladder of video sequences. The bitrate ladder is represented as {235, 375, 560, 750, 1050, 1750, 2350, 3000, 4300}kbps.

Each chunk is encoded as 4 seconds. During the trans-coding process, for each video, we measure VMAF, VMAF-4K, and VMAF-phone metric with the reference resolution of 1920 × 1080 respectively. In general, the dataset contains 86 complete videos, with 394,551 video chunks and 1,578,204 video quality assessments.

Contact Us

Please feel free to let me know if you have any questions.

Contact: [email protected],

or,

create an issue.

comyco's People

Contributors

godka avatar yaox12 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

comyco's Issues

Can't get the same result as the pretrain model

Thank you for your work!I have some problems.
1、I used cook_traces as the training set and cook_test_traces as the test set for training. The average QoE obtained in the end was 49+, while the average QoE obtained by the pretrain model was 51+. How can I train to get similar results to pretrain?
2、And the network structure in the code is different from the network structure described in the paper (for example, delay uses CNN in the code, but FC in the figure of the paper), which one should be used?
Look forward to your kind reply!

Some problems about instant solver implement for linux

Thank you for your work.

auto net_env = new Environment(all_cooked_time, all_cooked_bw);

I am very confused about this line of code. The constructor of the environment class requires a string argument, but this gives two vectors. If replace the parameter with the file address, maybe this is correct. But what is the meaning of the previous line of code:
load_trace("./norway/", all_cooked_time, all_cooked_bw, all_file_names);

Question about pitree's inputs

I see that in the pitree implementation last_vmaf in an input. Is that last chunks vmaf? If yes, is that vmaf calculated on client side and how is that calculated?

a question about comyco

thank u for your work.
now i'm running this project but i meet some trouble.
when I run this code,the error occurs and it will say module 'pdb' has no attribute 'Pdb'.
i wonder why and i'm looking for help.
thanks a lot!

Experiments with different QoE definitions

Thank you for your work !

I would like to evaluate your methodology with another QoE definition (Pensieve's QoE) as well. I have made changes to the source code but have not had good results.
Specifically, I have changed all the QoE definitions on the source code, what else do I need to do besides changing the QoE definitions?

Example; this is what I changed in cpp-linux/env.cpp
//reward_ = 0.8469011 * vmaf_sum - 28.79591348 * curr_rebuffer_time + 0.29797156 * vmaf_smoothness0 - 1.06099887 * vmaf_smoothness1 -2.661618558192494;
 ↓
reward_ = VIDEO_BIT_RATE[chunk_quality]/1000- 4.3 * curr_rebuffer_time - std::abs(VIDEO_BIT_RATE[chunk_quality] - VIDEO_BIT_RATE[last_bitrate])/1000;

thanks!

Help for instant solver

Hello, I ran into a problem while reproducing this code. Hope to communicate with you. I saw the description of the instant solver in the paper 4.2, but I don't know how this part is reflected in the code, and I haven't found it after searching for it for a long time. Can you help me?

Can't plot anything.

Hello:
I retry to run plot_results.py at the folder src, but it can not show anything. How can I fix it? Thanks~

ModuleNotFoundError: No module named '_envcpp'

When running python train.py I am hit with the error that says there is no _envcpp module

WARNING:tensorflow:From /home/adithya/miniconda3/lib/python3.9/site-packages/tensorflow/python/compat/v2_compat.py:96: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.
Instructions for updating:
non-resource variables are not supported in the long term
Traceback (most recent call last):
  File "/home/adithya/ub/ub/research/Comyco/src/envcpp.py", line 14, in swig_import_helper
    return importlib.import_module(mname)
  File "/home/adithya/miniconda3/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named '_envcpp'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/adithya/ub/ub/research/Comyco/src/train.py", line 6, in <module>
    import envcpp as env
  File "/home/adithya/ub/ub/research/Comyco/src/envcpp.py", line 17, in <module>
    _envcpp = swig_import_helper()
  File "/home/adithya/ub/ub/research/Comyco/src/envcpp.py", line 16, in swig_import_helper
    return importlib.import_module('_envcpp')
  File "/home/adithya/miniconda3/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_envcpp'

a question about comyco

Thank you for your work.
I have a question about your paper.
In section 4.2,the ideas and formulas used by your instant solver are not much different from the MPC(cite 51).Intuitively,comyco should not be better than MPC,if you use imitation learning.In your results,comyco is better than MPC.why is that?any other tips?

thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.