Comments (6)
Currently not able to update and check, but your solution worked. Thanks a lot!
from dali.
Hello @Voveka98
You don't need to calculate the centerpoint - center crop is the default crop.
images = fn.decoders.image(encoded)
resized = fn.resize(images, size=(224, 224), mode="not_smaller")
cropped = fn.crop(resized, crop=(224, 224))
Now, you can get more efficient by decoding only the interesting part - this way you won't need to resize the parts that are out of crop.
shapes = fn.peek_image_shape(encoded)
size = fn.cast(fn.reductions.min(shapes[0:2]), dtype=dali.types.FLOAT)
images = fn.decoders.image_crop(encoded, crop=fn.stack(size, size))
resized = fn.resize(images, size=(224, 224), mode="not_smaller")
from dali.
Thansk for answering, seems like first solution works for me.
When i try second one:
@pipeline_def(batch_size=1, num_threads=8,device_id=1)
def TritonLoadingPipeline():
img_files = fn.external_source(name="DALI_INPUT_0")
shapes = fn.peek_image_shape(img_files)
size = fn.cast(fn.reductions.min(shapes[0:2]), dtype=types.FLOAT)
images = fn.decoders.image_crop(img_files, crop=fn.stack(size, size))
resized = fn.resize(images, size=(224, 224), mode="not_smaller")
normalized_images = fn.normalize(
resized,
mean=MEAN / SCALE,
stddev=STD ,
scale=SCALE,
dtype=types.FLOAT,
device="cpu",
)
# outputs_fp16 = fn.cast(normalized_images, dtype=types.FLOAT)
return normalized_images
I got an error:
TypeError Traceback (most recent call last)
Input In [160], in <cell line: 1>()
----> 1 pipe = TritonLoadingPipeline()
2 pipe.build()
File /opt/conda/lib/python3.8/site-packages/nvidia/dali/pipeline.py:1317, in pipeline_def.<locals>.actual_decorator.<locals>.create_pipeline(*args, **kwargs)
1315 pipe = Pipeline(**{**pipeline_kwargs, **ctor_args}) # Merge and overwrite dict
1316 with pipe:
-> 1317 pipe_outputs = func(*args, **fn_kwargs)
1318 if isinstance(pipe_outputs, tuple):
1319 po = pipe_outputs
Input In [159], in TritonLoadingPipeline()
5 shapes = fn.peek_image_shape(img_files)
6 size = fn.cast(fn.reductions.min(shapes[0:2]), dtype=types.FLOAT)
----> 7 images = fn.decoders.image_crop(img_files, crop=fn.stack(size, size))
8 resized = fn.resize(images, size=(224, 224), mode="not_smaller")
10 normalized_images = fn.normalize(
11 resized,
12 mean=MEAN / SCALE,
(...)
16 device="cpu",
17 )
File /opt/conda/lib/python3.8/site-packages/nvidia/dali/fn.py:84, in _wrap_op_fn.<locals>.fn_wrapper(*inputs, **kwargs)
82 return current_pipeline._wrap_op_call(op_wrapper, inputs, kwargs)
83 else:
---> 84 return op_wrapper(*inputs, **kwargs)
File /opt/conda/lib/python3.8/site-packages/nvidia/dali/fn.py:76, in _wrap_op_fn.<locals>.op_wrapper(*inputs, **kwargs)
73 if "device" not in init_args:
74 init_args["device"] = default_dev
---> 76 return op_class(**init_args)(*inputs, **call_args)
File /opt/conda/lib/python3.8/site-packages/nvidia/dali/ops.py:627, in python_op_factory.<locals>.Operator.__call__(self, *inputs, **kwargs)
625 op_instances = []
626 for input_set in input_sets:
--> 627 op_instances.append(_OperatorInstance(input_set, self, **kwargs))
628 op_instances[-1].generate_outputs()
630 # Tie the instances together
File /opt/conda/lib/python3.8/site-packages/nvidia/dali/ops.py:433, in _OperatorInstance.__init__(self, inputs, op, **kwargs)
426 except Exception as e:
427 raise TypeError(
428 ("Expected inputs of type " +
429 "`DataNode` or convertible to constant nodes. Received " +
430 "input `{}` of type '{}'.")
431 .format(k, type(arg_inp).__name__)) from e
--> 433 _check_arg_input(op._schema, type(self._op).__name__, k)
435 self._spec.AddArgumentInput(k, arg_inp.name)
436 self._inputs = list(self._inputs) + [arg_inp]
File /opt/conda/lib/python3.8/site-packages/nvidia/dali/ops.py:528, in _check_arg_input(schema, op_name, name)
526 return
527 if not schema.IsTensorArgument(name):
--> 528 raise TypeError("The argument `{}` for operator `{}` should not be a `DataNode` but a {}".format(
529 name, op_name, _type_name_convert_to_string(schema.GetArgumentType(name), False)))
TypeError: The argument `crop` for operator `ImageCrop` should not be a `DataNode` but a float or list of float
Maybe i use some old version, will check
from dali.
Can you please check what NVIDIA DALI version are you using?:
python -m pip list | grep nvidia-dali
This feature was introduced in #4422, so this must be quite an old version.
from dali.
I use this version:
nvidia-dali-cuda110 1.11.1
from dali.
@Voveka98 - can you update to the latest version and check again?
from dali.
Related Issues (20)
- Segmentation fault when using 'mixed' HOT 5
- Bbox Pruning Too Aggressive? HOT 5
- Indexing video with binary mask HOT 1
- source_info tensor not guaranteed to contain correct data HOT 1
- 16 bit gray scale Image read error HOT 1
- COCO Reader pixelwise_masks Emtpy Output HOT 7
- Dali on Jetson: nvidia.dali.fn.readers.video_resize is missing HOT 4
- Numpy reader test (GDS) HOT 4
- How to add a scalar value to the loader? HOT 1
- Can DALI be integrated into HuggingFace Trainer? HOT 9
- Bug in creating `TensorGPU` when `stream` key is `None` in CUDA array interface HOT 2
- Configure max image size HOT 3
- Webdataset reader behavior with many sources HOT 1
- ModuleNotFoundError: No module named 'nvidia.dali.python_function_plugin' HOT 3
- Speed up Dino with DALI HOT 3
- error using webdataset
- webdataset cannot stop cycling at end of epoch HOT 11
- Get audio data from external data sources and start iteration HOT 7
- Encountered some issues when using mirror flip HOT 2
- Can AArch64 Numba tests be re-renabled? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dali.