Comments (4)
I found the _training_transforms method in some data loading classes, such as the coco_segmentation.py file, the code snippet is as follows:
def _training_transforms(self, size: tuple, ignore_idx: Optional[int] = 255):
aug_list = [
T.RandomResize(opts=self.opts),
T.RandomCrop(opts=self.opts, size=size),
T.RandomHorizontalFlip(opts=self.opts),
T.ToTensor(opts=self.opts),
]
return T.Compose(opts=self.opts, img_transforms=aug_list)
T.ToTensor(opts=self.opts),
The call is the ToTensor(BaseTransformation) class in image_pil.py,
There is the following code snippet in the _call method:
data["image"] = img.to(dtype=self.img_dtype).div(255.0)
Therefore, the input image should be normalized, between 0 and 1?
from ml-cvnets.
At the same time, in the getitem method of the coco_segmentation.py file, there is the following code:
rgb_img = self.read_image_opencv(os.path.join(self.img_dir, path))
The code of the read_image_opencv method in dataset_base.py is as follows:
@staticmethod
def read_image_opencv(path: str):
return cv2.imread(
path, cv2.IMREAD_COLOR
) # Image is read in BGR Format and not RGB format
Image is read in BGR Format and not RGB format
But in the getitem method of other data loading classes, such as pascal_voc.py, the call is:
img = self.read_image_pil(self.images[img_index])
The code snippet of the read_image_pil method of dataset_base.py is as follows:
def read_image_pil(self, path: str, *args, **kwargs):
def convert_to_rgb(inp_data: Union[str, io.BytesIO]):
try:
rgb_img = Image.open(inp_data).convert("RGB")
except:
rgb_img = None
return rgb_img
if self.cached_data is not None:
# code for caching data on RAM
used_memory = float(psutil.virtual_memory().percent)
if path in self.cached_data:
img_byte = self.cached_data[path]
elif (path not in self.cached_data) and (used_memory <= self.cache_limit):
# image is not present in cache and RAM usage is less than the threshold, add to cache
with open(path, "rb") as bin_file:
bin_file_data = bin_file.read()
img_byte = io.BytesIO(bin_file_data)
self.cached_data[path] = img_byte
else:
with open(path, "rb") as bin_file:
bin_file_data = bin_file.read()
img_byte = io.BytesIO(bin_file_data) # in-memory data
img = convert_to_rgb(img_byte)
else:
img = convert_to_rgb(path)
return img
Image is read in RGB format
My doubt is, should the input image be in bgr format or rgb format?
from ml-cvnets.
Initial version of this library uses OpenCV, which read images in BGR format. With v0.2, we migrated to PIL and now use only RGB format. OpenCV data loading is only for backward compatibility. So, we recommend to use RGB format.
We normalize the images between 0 and 1, and recommend to do so.
hope this helps
from ml-cvnets.
Thank you for your reply
from ml-cvnets.
Related Issues (20)
- Questions about the file bytes length of ByteFormer HOT 3
- How to solve this problem:ModuleNotFoundError: No module named 'cvnets.models.classification.' HOT 5
- Normalization Params
- 'nan' loss when training 'ByteFormer' using ImageNet
- Runtime error on single GPU Linux environment training HOT 1
- Not possible to test ByteFormer HOT 5
- Cross Attention Computation in LinearSelfAttention()
- [Feature Request] Docker container
- Segmentation model conversion size mismatch HOT 1
- Size mismatch error when loading a pretrained model HOT 1
- The license of pretrained weights
- Question: Do you have removed the support for video classification? HOT 2
- crash if different number of classess within `train/test` set HOT 6
- VIT-tiny weights and config dont match? HOT 1
- How to convert segmentation model results into VNInstanceMaskObservation? HOT 4
- ModuleNotFoundError: No module named 'main_train' HOT 2
- Using vision transformers for different image resolutions HOT 1
- ModuleNotFoundError: No module named 'main_train'
- ModuleNotFoundError: No module named 'main_train'
- AttributeError: 'NoneType' object has no attribute 'size' 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 ml-cvnets.