This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import concurrent.futures | |
from typing import Any, Callable, List | |
from tqdm import tqdm | |
def concurrent_task_executor(task: Callable[[Any], None], data_list: List[Any], max_workers: int = 32, description: str = None) -> None: | |
""" | |
Execute tasks concurrently on a list of data objects using ThreadPoolExecutor. | |
Args: | |
task (Callable): The function to apply to each data object. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[STEP-2] : Downloading an example Image and imagenet output classes | |
# Download an example image from the pytorch website | |
!wget "https://github.com/pytorch/hub/raw/master/images/dog.jpg" -O "dog.jpg" | |
# Download ImageNet labels | |
!wget https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt | |
# Read the image classes | |
with open("imagenet_classes.txt", "r") as f: |