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.10.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51d697d8b30750be68d2e0c1fb41673967747e1cf9165413b28d05f0e3fa0629 |
|
MD5 | 18f4e797577e17b64c7a82ab03330d97 |
|
BLAKE2b-256 | e3d6cf41d67b10e43ad3658061e532fb4c042f8c955d378360d8778874875fef |
Close
Hashes for ThreadedFileLoader-1.0.0.10-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a70581bd432ce08e2554731334f219ee9db06f012b3ec4ab4903151d25a42fc0 |
|
MD5 | dd37764ed1be92cf7d32599068df635e |
|
BLAKE2b-256 | a7631f5fc903063a07c522637078cb9934dff528091fba025738eeadf909e1e5 |