Git Product home page Git Product logo

accimage's People

Contributors

colesbury avatar erotemic avatar facebook-github-bot avatar maratyszcza avatar soumith avatar willprice avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

accimage's Issues

Bug when applying RandomHorizontalFlip()

This is what I get when I applying RandomHorizontalFlip():
bug
As you can see the upper part of some images is totally disrupted.
Here is how I use the accimage:
`
import accimage

def get_img_loader(batch_size, shuffle=True, num_workers=8, mode='train', img_size=227):
    t_dir = os.path.join(imagenet_ssd_dir, 'train')
    v_dir = os.path.join(imagenet_ssd_dir, 'val')

    transform_t = Compose([
        RandomResizedCrop(img_size, (1.0, 1.0), (1.0, 1.0)),
        RandomHorizontalFlip(),
        ToTensor(),
        # Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
    ])
    transform_v = Compose([
        CenterCrop(img_size),
        ToTensor(),
        Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
    ])
    if mode == 'val':
        data_folder = ImageFolder(v_dir, transform_v, loader=accimage.Image)
    else:
        data_folder = ImageFolder(t_dir, transform_t, loader=accimage.Image)

    return DataLoader(data_folder, batch_size=batch_size,shuffle=shuffle, num_workers=num_workers)

`

PNG support

Are there any plans to offer PNG support?

chicago.jpg is absent

test.py loads chicago.jpg by default but this file is not shipped with the source code.

Conversion to numpy

Hi,

is it possible to convert an image that was loaded to numpy? I would like to load images with accimage but then chain a custom image transform in CV2. np.asarray() seems to do nothing.

Thanks!

cannot install on ubuntu 20.04.1 LTS

$ sudo python setup.py install
running install
running build
running build_ext
building 'accimage' extension
creating build
creating build/temp.linux-x86_64-3.6
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/opt/jpeg-turbo/include -I/opt/intel/ipp/include -I/home/user1/anaconda3/envs/mxgpu/include/python3.6m -c accimagemodule.c -o build/temp.linux-x86_64-3.6/accimagemodule.o
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/opt/jpeg-turbo/include -I/opt/intel/ipp/include -I/home/user1/anaconda3/envs/mxgpu/include/python3.6m -c jpegloader.c -o build/temp.linux-x86_64-3.6/jpegloader.o
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/opt/jpeg-turbo/include -I/opt/intel/ipp/include -I/home/user1/anaconda3/envs/mxgpu/include/python3.6m -c imageops.c -o build/temp.linux-x86_64-3.6/imageops.o
imageops.c:5:10: fatal error: ippi.h: No such file or directory
    5 | #include <ippi.h>
      |          ^~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1

Add support to load image from io.BytesIO

PIL could open image directly from io.BytesIO, like

import io
image_buffer = io.BytesIO()
image_buffer.write(image_string)
image_buffer.seek(0)
image = Image.open(image_buffer)

This is helpful for loading image from a database. Thanks!

Is it possible to make a wheel or conda build for this lib?

Currently accimage is used as a backend for torchvision, however it's not clear how to build it (what dependencies are required etc). I have been trying to build it this morning and it doesn't play nice if libjpeg is already in the system.

Would it be possible to release a distribution (a wheel or conda tar) of this so it's easier to install?

As a side note, this would allow us to easily install accimage as part of the travis job in torchvision so that we can run the tests that require accimage.

Graysacle image

When loading graysacle images by accimage.Image('a.jpg'), it outputs 3 channels images instead of 1. Any plan to fix it? Thanks.

How can I solve this problem:Swin Transformer training and evaluation script: error: the following arguments are required: --cfg

(swin) D:\vit\Swin-Transformer>python main.py --eval --cfg configs/swin_tiny_patch4_window7_224.yaml --resume swin_tiny_patch4_window7_224.--data-path
D:\vit\Swin-Transformer\MINIST
usage: Swin Transformer training and evaluation script --cfg FILE
[--opts OPTS [OPTS ...]]
[--batch-size BATCH_SIZE]
[--data-path DATA_PATH]
[--zip]
[--cache-mode {no,full,part}]
[--resume RESUME]
[--accumulation-steps ACCUMULATION_STEPS]
[--use-checkpoint]
[--amp-opt-level {O0,O1,O2}]
[--output PATH]
[--tag TAG] [--eval]
[--throughput]
Swin Transformer training and evaluation script: error: the following arguments are required: --cfg

Solving environment: failed with initial frozen solve. Retrying with flexible solve.

I run conda install -c conda-forge accimage
I get
PackagesNotFoundError: The following packages are not available from current channels:

  • accimage

Current channels:

To search for alternate channels that may provide the conda package you're
looking for, navigate to

https://anaconda.org

and use the search bar at the top of the page.

How can I solve this problem:FileNotFoundError: [WinError 3] The system could mot find the specified path: 'D:\vit\Swin-Transformer\data\MINIST\train'?

Traceback (most recent call last):
File "main.py", line 365, in
main(config)
File "main.py", line 86, in main
dataset_train, dataset_val, data_loader_train, data_loader_val, mixup_fn = build_loader(config)
File "D:\vit\Swin-Transformer\data\build.py", line 24, in build_loader
dataset_train, config.MODEL.NUM_CLASSES = build_dataset(is_train=True, config=config)
File "D:\vit\Swin-Transformer\data\build.py", line 83, in build_dataset
dataset = datasets.ImageFolder(root, transform=transform)
File "C:\Users\86183\anaconda3\envs\swin\lib\site-packages\torchvision\datasets\folder.py", line 229, in init
is_valid_file=is_valid_file)
File "C:\Users\86183\anaconda3\envs\swin\lib\site-packages\torchvision\datasets\folder.py", line 108, in init
classes, class_to_idx = self._find_classes(self.root)
File "C:\Users\86183\anaconda3\envs\swin\lib\site-packages\torchvision\datasets\folder.py", line 137, in _find_classes
classes = [d.name for d in os.scandir(dir) if d.is_dir()]
FileNotFoundError: [WinError 3] The system could mot find the specified path: 'D:\vit\Swin-Transformer\data\MINIST\train'

"Integer argument expected" for img.crop

Installing and switching to the accimage backend breaks my transforms.RandomResizedCrop. The fix I've found is modifying crop() in torchvisions.transforms.functional so that it does

img.crop((int(j), int(i), int(j + w), int(i + h)))

instead of

img.crop((j, i, j + w, i + h))

(sidenote: this library is deliciously fast)

in place operations only breaks FiveCrop.

Hi, I was writing some augmentation transforms and I noticed that all operations are done in place.
I forked and added a .copy() method for my use, but I wonder if this is the correct way of doing it.
I like accimage quite as it is 4 to 6 times faster in my profiling than either going thru opencv or PIL to tensor.
I like, as well, that accimage operates in place by default, but as it stands, accimage breaks transformations that rely on data copies, such as FiveCrop. PIL default behaviour always returns a copy.
On my augmentation library Im changing the FiveCrop to bypass accimage by running Image.copy() if accimage.

img = ...
import PIL
import accimage
import torchvision.transforms as ttrans
fcrop = ttrans.Compose([ttrans.FiveCrop(100),
         ttrans.Lambda(lambda crops: torch.stack([ttrans.ToTensor()(crop) for crop in crops]))])
aim = PIL.Image.open(img)
f = fcrop(aim)
# OK

fcrop = ttrans.Compose([ttrans.FiveCrop(100),
         ttrans.Lambda(lambda crops: torch.stack([ttrans.ToTensor()(crop) for crop in crops]))])
aim = accimage.Image(img)
f = fcrop(aim)
# Fails 

If you are interested you can look at my forked solution. BUT it is a half way solution since it requires a fix to torvision.transforms.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.