Ejemplo n.º 1
0
def _download_image_inner(dest, inp, timeout=4, preserve_filename=False):
    i,url = inp
    url = url.split("?")[0]
    url_path = Path(url)
    suffix = url_path.suffix if url_path.suffix else '.jpg'
    name = _get_downloaded_image_filename(dest, url_path.stem, suffix) if preserve_filename else f"{i:08d}"
    try: download_url(url, dest/f"{name}{suffix}", show_progress=False, timeout=timeout)
    except Exception as e: f"Couldn't download {url}."
Ejemplo n.º 2
0
def download_sample_data(base_url,
                         name,
                         dest,
                         extract=False,
                         timeout=4,
                         show_progress=True):
    dest = Path(dest)
    dest.mkdir(exist_ok=True, parents=True)
    file = download_url(f'{base_url}{name}',
                        dest,
                        show_progress=show_progress,
                        timeout=timeout)
    if extract:
        unzip(dest, file)
        file.unlink()
Ejemplo n.º 3
0
def check_cellpose_installation(show_progress=True):
    tarball = 'cellpose-0.6.6.dev13+g316927e.tar.gz'  # '316927eff7ad2201391957909a2114c68baee309'
    try:
        extract = [x for x in freeze.freeze()
                   if x.startswith('cellpose')][0][-15:]
        assert extract == tarball[-15:]
    except:
        print(f'Installing cellpose. Please wait.')
        home_dir = Path.home() / '.deepflash2'
        home_dir.mkdir(exist_ok=True, parents=True)
        url = f'https://github.com/matjesg/deepflash2/releases/download/0.1.4/{tarball}'
        file = download_url(url, home_dir, show_progress=show_progress)
        subprocess.check_call([
            sys.executable, "-m", "pip", "install", '--no-deps',
            file.as_posix()
        ])