Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
sudo apt-get -y update
sudo apt-get -y install build-essential ca-certificates curl ffmpeg git wget unzip python3-dev python3-pip software-properties-common python3-numpy youtube-dl
#install for GPU
sudo apt-get install mesa-common-dev libegl1-mesa-dev libgles2-mesa-dev
sudo apt purge nvidia-*
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo apt install nvidia-384
#install opencv and ffmpeg
sudo apt-get -y install libopencv-core-dev libopencv-highgui-dev \
libopencv-calib3d-dev libopencv-features2d-dev \
libopencv-imgproc-dev libopencv-video-dev
sudo add-apt-repository ppa:jonathonf/ffmpeg-4
sudo apt-get -y update
sudo apt-get -y upgrade ffmpeg libavcodec-dev libavformat-dev libavutil-dev libswresample-dev libswscale-dev
mkdir ~/src ; cd ~/src
git clone https://github.com/google/youtube-8m.git
git clone https://github.com/google/mediapipe.git
#install bazel
cd /tmp
sudo apt-get -y install build-essential openjdk-8-jdk python zip unzip
wget https://github.com/bazelbuild/bazel/releases/download/3.0.0/bazel-3.0.0-dist.zip
unzip bazel-3.0.0-dist.zip
env EXTRA_BAZEL_ARGS="--host_javabase=@local_jdk//:jdk" bash ./compile.sh
sudo cp output/bazel /usr/local/bin/
pip3 install --upgrade pip
pip3 install --upgrade setuptools
pip3 install wheel
pip3 install future
pip3 install six==1.14.0
#pip3 install tensorflow==1.14.0
pip3 install tensorflow-gpu==1.14.0
pip3 install tf_slim
pip3 install youtube_dl
pip3 install opencv-python
#install without GPU
export GPU="--define MEDIAPIPE_DISABLE_GPU=1"
#install with GPU
export GPU="--copt -DMESA_EGL_NO_X11_HEADERS --copt -DEGL_NO_X11"
#build mediapipe example
export GLOG_logtostderr=1
cd ~/src/mediapipe
bazel run $WITH_GPU mediapipe/examples/desktop/hello_world:hello_world
#####
#YT8M
#####
mkdir /tmp/mediapipe
curl -o /tmp/mediapipe/inception3_mean_matrix_data.pb http://data.yt8m.org/pca_matrix_data/inception3_mean_matrix_data.pb
curl -o /tmp/mediapipe/inception3_projection_matrix_data.pb http://data.yt8m.org/pca_matrix_data/inception3_projection_matrix_data.pb
curl -o /tmp/mediapipe/vggish_mean_matrix_data.pb http://data.yt8m.org/pca_matrix_data/vggish_mean_matrix_data.pb
curl -o /tmp/mediapipe/vggish_projection_matrix_data.pb http://data.yt8m.org/pca_matrix_data/vggish_projection_matrix_data.pb
curl -o /tmp/mediapipe/inception-2015-12-05.tgz http://download.tensorflow.org/models/image/imagenet/inception-2015-12-05.tgz
curl -o /tmp/mediapipe/yt8m_baseline_saved_model.tar.gz http://data.yt8m.org/models/baseline/saved_model.tar.gz
tar -xvf /tmp/mediapipe/inception-2015-12-05.tgz -C /tmp/mediapipe
tar -xvf /tmp/mediapipe/yt8m_baseline_saved_model.tar.gz -C /tmp/mediapipe
rm /usr/bin/python
ln -s /usr/bin/python3 /usr/bin/python
cd ~/src/mediapipe
#audio extraction model
python3 -m mediapipe.examples.desktop.youtube8m.generate_vggish_frozen_graph
#extract_features
bazel build -c opt $GPU --linkopt=-s --define no_aws_support=true mediapipe/examples/desktop/youtube8m:extract_yt8m_features
#inference
bazel build -c opt $GPU --linkopt=-s mediapipe/examples/desktop/youtube8m:model_inference
#fetch
youtube-dl 'https://youtu.be/jOJbXvjZ-cQ'
mv BLACKPINK* /tmp/BLACKPINK.mp4
#generates /tmp/mediapipe/metadata.pb for BLACKPINK.mp4
python3 -m mediapipe.examples.desktop.youtube8m.generate_input_sequence_example \
--path_to_input_video=/tmp/BLACKPINK.mp4 --clip_end_time_sec=180
#generates the featutres pb for the video
bazel-bin/mediapipe/examples/desktop/youtube8m/extract_yt8m_features \
--calculator_graph_config_file=mediapipe/graphs/youtube8m/feature_extraction.pbtxt \
--input_side_packets=input_sequence_example=/tmp/mediapipe/metadata.pb \
--output_side_packets=output_sequence_example=/tmp/mediapipe/features.pb
bazel-bin/mediapipe/examples/desktop/youtube8m/model_inference \
--calculator_graph_config_file=mediapipe/graphs/youtube8m/local_video_model_inference.pbtxt \
--input_side_packets=input_sequence_example_path=/tmp/mediapipe/features.pb,input_video_path=/tmp/BLACKPINK.mp4,output_video_path=/tmp/BLACKPINK-labeled.mp4,segment_size=5,overlap=4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.