File size: 1,549 Bytes
9313bc1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bf0e4cf
 
9313bc1
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import json
import os
import pickle
import random
import tarfile
import zipfile
from collections import Counter
from glob import glob

import gdown
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
import streamlit as st
from PIL import Image

import SessionState


def download_files(
    root_visualization_dir,
    viz_url,
    viz_archivefile,
    demonstration_url,
    demonst_zipfile,
    picklefile_url,
    prediction_root,
    prediction_pickle,
):
    # Get Visualization
    if not os.path.exists(root_visualization_dir):
        gdown.download(viz_url, viz_archivefile, quiet=False)
        os.makedirs(root_visualization_dir, exist_ok=True)

        if viz_archivefile.endswith("tar.gz"):
            tar = tarfile.open(viz_archivefile, "r:gz")
            tar.extractall(path=root_visualization_dir)
            tar.close()
        elif viz_archivefile.endswith("zip"):
            with zipfile.ZipFile(viz_archivefile, "r") as zip_ref:
                zip_ref.extractall(root_visualization_dir)

    # Get Demonstrations
    if not os.path.exists(demonst_zipfile):
        gdown.download(demonstration_url, demonst_zipfile, quiet=False)
        # os.makedirs(roo_demonstration_dir, exist_ok=True)

        with zipfile.ZipFile(demonst_zipfile, "r") as zip_ref:
            zip_ref.extractall("./")

    # Get Predictions
    if not os.path.exists(prediction_pickle):
        os.makedirs(prediction_root, exist_ok=True)
        gdown.download(picklefile_url, prediction_pickle, quiet=False)