Skip to content

Instantly share code, notes, and snippets.

View bhimrazy's full-sized avatar
🎯
Focusing

Bhimraj Yadav bhimrazy

🎯
Focusing
View GitHub Profile
@bhimrazy
bhimrazy / concurrent_task_executor.py
Created March 10, 2024 17:05
This Python code defines a function concurrent_task_executor that allows executing tasks concurrently on a list of data objects using ThreadPoolExecutor from the concurrent.futures module. It includes a progress bar using tqdm to track the completion of tasks. The function is useful for processing data in parallel, improving efficiency when deal…
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.
@bhimrazy
bhimrazy / download.py
Created May 8, 2022 09:07
Image Classification in 5 simple steps. Using pre-trained DenseNet model in PyTorch
#[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: