CoolFace
Apppublic

XAI/VisualCorrespondenceHumanStudy

sourceHugging Facemitupdated 4y agoView on Hugging Face
1likes
download_utils.py56 linesDownload Raw Back to root
1import json2import os3import pickle4import random5import tarfile6import zipfile7from collections import Counter8from glob import glob9 10import gdown11import matplotlib.pyplot as plt12import numpy as np13import pandas as pd14import seaborn as sns15import streamlit as st16from PIL import Image17 18import SessionState19 20 21def download_files(22    root_visualization_dir,23    viz_url,24    viz_archivefile,25    demonstration_url,26    demonst_zipfile,27    picklefile_url,28    prediction_root,29    prediction_pickle,30):31    # Get Visualization32    if not os.path.exists(root_visualization_dir):33        gdown.download(viz_url, viz_archivefile, quiet=False)34        os.makedirs(root_visualization_dir, exist_ok=True)35 36        if viz_archivefile.endswith("tar.gz"):37            tar = tarfile.open(viz_archivefile, "r:gz")38            tar.extractall(path=root_visualization_dir)39            tar.close()40        elif viz_archivefile.endswith("zip"):41            with zipfile.ZipFile(viz_archivefile, "r") as zip_ref:42                zip_ref.extractall(root_visualization_dir)43 44    # Get Demonstrations45    if not os.path.exists(demonst_zipfile):46        gdown.download(demonstration_url, demonst_zipfile, quiet=False)47        # os.makedirs(roo_demonstration_dir, exist_ok=True)48 49        with zipfile.ZipFile(demonst_zipfile, "r") as zip_ref:50            zip_ref.extractall("./")51 52    # Get Predictions53    if not os.path.exists(prediction_pickle):54        os.makedirs(prediction_root, exist_ok=True)55        gdown.download(picklefile_url, prediction_pickle, quiet=False)56