No project description provided
Project description
Threaded File Loader
Multithreaded Python package for faster file loading in machine learning.
Installation
pip install ThreadedFileLoader
Usage:
Loading Image Files:
from ThreadedFileLoader.ThreadedFileLoader import *
instance = ThreadedImageLoader("path_to_/*.jpg")
instance.start_loading()
images = instance.loaded_objects
print(len(images))
print(images[0].shape)
Loading Text Files:
from ThreadedFileLoader.ThreadedFileLoader import *
instance = ThreadedTextLoader("path_to_/*.txt")
instance.start_loading()
images = instance.loaded_objects
Loading Custom File Formats
Threaded FileLoader can load different file types.
This examples shows how the ThreadedTextLoader
class
overloads the ThreadedFileLoader
class to load text files.
from ThreadedFileLoader.ThreadedFileLoader import *
class ThreadedTextLoader(ThreadedFileLoader):
def object_loader(self, path):
with open(path) as afile:
data = afile.readlines()
return data
instance = ThreadedTextLoader("path_to_/*.txt")
instance.start_loading()
texts = instance.loaded_objects
Machine Learning Example
Loading Dataset
import numpy as np
from ThreadedFileLoader.ThreadedFileLoader import *
from sklearn.cluster import KMeans
instance = ThreadedImageLoader("path_to_dataset/*.jpg")
instance.start_loading()
images = instance.loaded_objects
images = np.array(images)
images = images.reshape(len(images), -1)
kmeans = KMeans(n_clusters=10, random_state=0).fit(images)
print(kmeans.labels_)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for ThreadedFileLoader-1.0.0.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1c015c9d9716859f8333f94decb719044b9a2ca79ce7ce9f1681400a10009ae |
|
MD5 | 054696be844d079d00978bace1e34766 |
|
BLAKE2b-256 | 024efd0874dba1b6597f68578955d802844495dfd0fbf5f75a43e2a3a0957b46 |
Close
Hashes for ThreadedFileLoader-1.0.0.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43b74a573b75b2c1607c92a5a74ff739d1028fea461f48cf17ea1b7052bd85cb |
|
MD5 | ed64a68943120f27a55d775a97f1c582 |
|
BLAKE2b-256 | 7b56364d0db513e7e044920dbfa546c8a086cc5718ca8215e36eefa4e29430ad |