Skip to content

Commit

Permalink
Fix minor issues for final release
Browse files Browse the repository at this point in the history
  • Loading branch information
washingtonsk8 committed Apr 1, 2022
1 parent 4beea9e commit b63fc5d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 33 deletions.
27 changes: 16 additions & 11 deletions TextDrivenVideoAcceleration_TPAMI_2022.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,26 @@
},
"outputs": [],
"source": [
"VIDEO_ID = 'eQZEf3NCCo4'\n",
"document = ['combine rice vinegar sugar and salt',\n",
" 'mix the sauce and pour on the rice',\n",
" 'prepare some crab meat chop and peel an avocado into thin slices',\n",
" 'wrap the mat with plastic',\n",
" 'place the seaweed down and put the rice on it',\n",
" 'add sesame seeds crab meat and avocado roll it up and press firmly',\n",
" 'slice the roll']\n",
"VIDEO_ID = 'jnewhlK2USg'\n",
"document = ['chop some tuna meat into small pieces',\n",
" 'mix the tuna pieces and some fish eggs in a bowl',\n",
" 'add hot sauce and mayo and then mix them together',\n",
" 'spread some cooked rice on seaweed sushi wrapper',\n",
" 'add the tuna mix on top and season with some sesame seeds',\n",
" 'roll it up and press firmly',\n",
" 'cut the roll into small rolls']\n",
"\n",
"! yt-dlp https://www.youtube.com/watch?v=$VIDEO_ID -o $VIDEO_ID # Download Video File\n",
"! yt-dlp https://www.youtube.com/watch?v=$VIDEO_ID -o $VIDEO_ID --merge-output-format mp4 # Download Video File\n",
"\n",
"sf = model.fast_forward_video(video_filename=f'{VIDEO_ID}.webm',\n",
"print('\\nExtracting VDAN+ Features...')\n",
"semantic_embeddings = model.get_semantic_embeddings(video_filename=f'{VIDEO_ID}.mp4', document=document)\n",
"\n",
"print('\\nFast Forwarding Video...')\n",
"sf = model.fast_forward_video(video_filename=f'{VIDEO_ID}.mp4',\n",
" document=document,\n",
" desired_speedup=12,\n",
" output_video_filename=f'{VIDEO_ID}_FF.avi')"
" output_video_filename=f'{VIDEO_ID}_FF.avi',\n",
" semantic_embeddings=semantic_embeddings)"
]
},
{
Expand Down
30 changes: 16 additions & 14 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
gym==0.18.3
matplotlib==3.4.2
nltk==3.6.2
numpy==1.20.3
opencv_python==4.5.2.54
pandas==1.3.5
pandas_stubs==1.2.0.39
Pillow==9.0.1
scipy==1.7.0
seaborn==0.11.1
torch==1.10.0
torchvideo==0.0.1
torchvision==0.8.2
tqdm==4.61.2
gym>=0.18.3
matplotlib>=3.4.2
nltk>=3.6.2
numpy>=1.20.3
opencv_python>=4.5.2.54
pandas>=1.3.5
pandas_stubs>=1.2.0.39
Pillow>=8.2.0
scipy>=1.7.0
seaborn>=0.11.1
torch>=1.10.0
torchvideo>=0.0.1
torchvision>=0.8.2
tqdm>=4.61.2
youtube-dl
yt-dlp
5 changes: 1 addition & 4 deletions semantic_encoding/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,7 @@ def validate(validation_dataloader, validation_data, model, criterion, epoch, wr

def main(model_params, train_params):

if not os.path.isdir(train_params['log_folder']):
print('Log folder "{}" does not exist. We are attempting creating it... '.format(train_params['log_folder']))
os.mkdir(train_params['log_folder'])
print('Folder created!')
os.makedirs(train_params['log_folder'], exist_ok=True)

if train_params['model_checkpoint_filename']:
print('[{}] Loading saved model weights to finetune (or continue training): {}...'.format(datetime.now().strftime('%Y-%m-%d %H:%M:%S'), train_params['model_checkpoint_filename']))
Expand Down
5 changes: 1 addition & 4 deletions semantic_encoding/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,7 @@ def save_checkpoint(epoch, model, optimizer, word_map, datetimestamp, model_para
'model_params': model_params,
'train_params': train_params}

if not os.path.isdir(train_params['checkpoint_folder']):
print('Folder "{}" does not exist. We are attempting creating it... '.format(train_params['checkpoint_folder']))
os.mkdir(train_params['checkpoint_folder'])
print('Folder created!')
os.makedirs(train_params['checkpoint_folder'], exist_ok=True)

if train_params['model_checkpoint_filename']:
filename = '{}/{}_checkpoint_lr{}_{}eps{}{}_{}_{}_ft{}.pth'.format(train_params['checkpoint_folder'], datetimestamp, train_params['learning_rate'], train_params['num_epochs'], '_w-att' if model_params['use_word_level_attention'] else '', '_s-att' if model_params['use_sentence_level_attention'] else '', train_params['hostname'], train_params['username'], train_params['model_checkpoint_filename'].split('/')[-1].split('.')[0])
Expand Down

0 comments on commit b63fc5d

Please sign in to comment.