Comments (13)
The next step is to think how each record would be transformed to the specific item
from icevision.
If we take close attention, Item
already is a very specialized version for torchvision RCNNs
.. This makes the point of sub-dividing into classes even stronger
from icevision.
Record
is also very specialized already..
this is like so because Parser
s can't return a specific item already.
We can try having the parser return one specific type of item, defined by the user, linked to the model..
The records can be built with mixins
class MaskRecordMixin(ABC):
...
class BBoxRecordMixin(ABC):
...
class MaskRCNNRecord(MaskRecordMixin, BBoxRecordMixin, Record):
...
from icevision.
If working with mixins, we cannot rely on constructors like so:
ImageInfo(imageid=42, filepath='mypath/hello.jpg', h=420, w=480)
Because mixins cannot have constructors...
Instead we would need to do something like:
info = ImageInfo()
info.imageid = 42
info.filepath = 'mypath/hello.jpg'
But that is bad because it does not immediately tell the user what to modify
from icevision.
So, mixins ended up working quite well:
class ParserMixin(ABC):
@abstractmethod
def collect_parse_funcs(self, funcs=None):
return funcs or {}
class ImageidParserMixin(ParserMixin):
def collect_parse_funcs(self, funcs=None):
funcs = super().collect_parse_funcs(funcs)
return {"imageid": self.imageid, **funcs}
@abstractmethod
def imageid(self, o) -> int:
pass
This way we can stack as many mixins as we want:
class DefaultImageInfoParser(
ImageInfoParser,
ImageidParserMixin,
FilepathParserMixin,
SizeParserMixin,
SplitParserMixin,
ABC,
):
pass
from icevision.
The result of the parser is currently a dict
, differently from what we had before as a Record
.
I'm still not sure if it's better to have a dict
or a different Record
for each use case. The problem of using Record
is that we will have a lot of different permutations: BBoxRecord
, BBoxMaskRecord
, MaskRecord
, and so on
Using the dynamic feature of the dict can is a good factor here.
Now, the problem is, how to make this standard across all library? When using dict we loose auto completion =/
from icevision.
Previously we went from Record
-> Item
, and this was what was used in the transforms and subsequently fed to the model
Should we also substitute Item
to a dict
?
In the Dataset
we have to "prepare" our data, meaning we have to open images, convert masks and etc..
The thing is that again, we are not sure of the keys we have in the dict... Mixins again? =)
We can do something like
def __getitem__(self, i):
record = self.records[i]
data = {k: prepare_data(k, v) for k, v in record.items()}
class BBoxMixin:
def prepare_data(self, k, v):
if k == "bbox":
return v
return super().prepare_data(k, v)
from icevision.
We only implement the previously mentioned mixins for keys that need to change (like image and mask), else we can return the default value
from icevision.
We can define a parser for each type of model:
MaskRCNNParser
DetrParser
from icevision.
How to combine ImageInfo
and Annotation
?
Like before, this will be done inside a class DataParser
, but it's not so clear what this class should return. In the previous version we had a dataclass
Record
being returned, should we stick with the same?
Record can always have the fields: imageid
, image_info
, annotation
from icevision.
The split
should be decided inside DataParser
from icevision.
Instead of separating imageid
, image_info
and annotation
we can just combine everything in a single dict.
This way we can actually remove the difference between an AnnotationParser
and a ImageInfoParser
, all is parsers!
from icevision.
The dream is to have something to be able to have something like this:
class MyParser(DefaultImageInfoParser, FasterRCNNParser):
pass
You basically can mix and match all you want =)
from icevision.
Related Issues (20)
- Tutorial about using Lightning and Fastai callbacks for model checkpoint by metric HOT 1
- Icevision no longer works with the latest `sahi` release HOT 5
- Failing to create TorchScript module using torch.jit.script()
- batch inference for semantic segmentation does not work HOT 1
- Error learn.export( pkl_export_path )
- Error: cannot import name 'intersect_dicts' from 'yolov5.utils.torch_utils when using icevision==0.12.0 with yolov5==6.2.3 HOT 1
- 'mmseg' module missing from 'icevision.models' HOT 1
- cant find module create_coco_eval
- Error when loading icevision in colab HOT 2
- Fix unit tests failing on CI and/or local env
- Support for pytorch 1.13
- Support for EncodedRLE in COCO Dataset HOT 1
- Adding a maskrcnn_resnet50_fpn_v2 from TorchVision models
- name 'process_bbox_predictions' is not defined in inference.ipynb
- 'RecordCollection' object has no attribute 'load' HOT 1
- Call to predict_from_dl failing when calling convert_raw_prediction HOT 1
- Semantic Segmentation Issue
- Unable to install icevision in google colab HOT 4
- AttributeError: module 'numpy' has no attribute 'int'.
- Not able to plot graphs and sample images HOT 1
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 icevision.