Spaces:
Runtime error
Runtime error
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) | |