Skip to content

Instantly share code, notes, and snippets.

View vgaraujov's full-sized avatar

Vladimir Araujo vgaraujov

View GitHub Profile
@vgaraujov
vgaraujov / drive_download.py
Created October 30, 2021 22:56
A PyDrive client-based function to walk through all subfolders of a gdrive folder and download the folder structure with all files inside. Forked from https://stackoverflow.com/a/58207188/13521099
import os
def drive_download(drive, fid):
MIMETYPES = {
# Drive Document files as MS dox
'application/vnd.google-apps.document': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
# Drive Sheets files as MS Excel files.
'application/vnd.google-apps.spreadsheet': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
# Drive presentation as MS pptx
'application/vnd.google-apps.presentation': 'application/vnd.openxmlformats-officedocument.presentationml.presentation'
@vgaraujov
vgaraujov / ucf101.py
Created December 5, 2020 20:31
Modified file to avoid certificate issues when downloading UCF101 dataset. Source: https://cv.gluon.ai/build/examples_datasets/ucf101.html#sphx-glr-build-examples-datasets-ucf101-py
"""This script is largely borrowed from https://github.com/open-mmlab/mmaction.
"""
import argparse
import sys
import os
import os.path as osp
import glob
import fnmatch
import random
@vgaraujov
vgaraujov / squad_utils.py
Last active June 11, 2023 13:30
Function to convert SQuAD dataset from json format to dataframe. Used in this tutorial: https://github.com/vgaraujov/Question-Answering-Tutorial/blob/master/Question_Answering_BERT_Spanish.ipynb
# Code forked from https://www.kaggle.com/jagannathpatta/reading-json-data-getting-dataframe
import pandas as pd
import json
def json_to_dataframe(file):
f = open ( file , "r")
data = json.loads(f.read()) #loading the json file.
iid = []
tit = [] #Creating empty lists to store values.