GithubHelp home page GithubHelp logo

sahi support in v0.2.0 about mmyolo HOT 33 CLOSED

open-mmlab avatar open-mmlab commented on May 5, 2024
sahi support in v0.2.0

from mmyolo.

Comments (33)

fcakyon avatar fcakyon commented on May 5, 2024 2

I have fixed it by adding: register_all_modules()

from mmyolo.

fcakyon avatar fcakyon commented on May 5, 2024 1

I have another question, why is pycocotools a hard dependency for mmyolo? It is not necessary when doing only inference?

Opened a separate issue: #235

This problem is solved.

from mmyolo.

hhaAndroid avatar hhaAndroid commented on May 5, 2024 1

@fcakyon Temporary solution:

from mmengine.registry import DefaultScope

with DefaultScope.overwrite_default_scope('mmdet'):
    self.predictor = init_detector(cfg, cfg.model_path)

from mmyolo.

liuyanyi avatar liuyanyi commented on May 5, 2024 1

For slice inference, there's already a huge_image_demo in mmrotate for large image slice inference, maybe we can refactor this feature in mmdet or mmcv to share this feature cross libraries.

Except for slice inference, I also expect there will be a slice evaluate just like coco evaluate in sahi. But evaluate in sahi only support coco, i hope that could support more dataset or more universal.

Slicing training is also a feature I was looking forward to. In DOTA dataset for rotate object detection, all image will be sliced to patches before training and testing, sliced datasets take up a lot of storage space. During paper reproduction, if some papers use a different slice size or strategy, the images need to be sliced again, its a huge burden for my hard drive.

Looking for your suggestion too.

from mmyolo.

fcakyon avatar fcakyon commented on May 5, 2024 1

Slicing training is also a feature I was looking forward to. In DOTA dataset for rotate object detection, all image will be sliced to patches before training and testing, sliced datasets take up a lot of storage space. During paper reproduction, if some papers use a different slice size or strategy, the images need to be sliced again, its a huge burden for my hard drive.

Creating a sliced dataset and then training on these images is the trivial solution. But if you want to save some disk space, these slicing operation can be performed during training on the fly as an augmentation with the help of dataloader maybe. For each loaded image, crop augmentation can be applied in a structured way (instead of randomly cropping) then these crop augmentations can be input into the model.

from mmyolo.

fcakyon avatar fcakyon commented on May 5, 2024 1

@hhaAndroid OK will work on it today.

from mmyolo.

fcakyon avatar fcakyon commented on May 5, 2024 1

I have made great progress, and will be able to open a pr with working large_image_demo.py using sahi this week ๐Ÿ‘

from mmyolo.

hhaAndroid avatar hhaAndroid commented on May 5, 2024 1

Thank you. I have replied

from mmyolo.

hhaAndroid avatar hhaAndroid commented on May 5, 2024 1

Thank you. I have replied

I have resolved your replies, can you check again in your free time? :)

OK

from mmyolo.

fcakyon avatar fcakyon commented on May 5, 2024

I am having this error when trying to download mmyolo config via python: open-mmlab/mim#170

from mmyolo.

RangeKing avatar RangeKing commented on May 5, 2024

I am having this error when trying to download mmyolo config via python: open-mmlab/mim#170

Hi @fcakyon, using mmyolo==0.1.2 will solve this problem.

from mmyolo.

hhaAndroid avatar hhaAndroid commented on May 5, 2024

@fcakyon Hi, We plan to integrate sahi in v0.1.3. The current plan is:

  • First make a draft in mmyolo to see the generality
  • If the generality is very strong, we can consider submitting PR directly to mmengine so that all openmmlab repo can be used directly

Can we write a draft version first and then discuss the next steps?

from mmyolo.

fcakyon avatar fcakyon commented on May 5, 2024

Can we write a draft version first and then discuss the next steps?

Sure ๐Ÿ‘

from mmyolo.

fcakyon avatar fcakyon commented on May 5, 2024

@RangeKing when I run this code snippet:

from mmdet.apis import init_detector

config_path = 'yolov5_n-v61_syncbn_fast_8xb16-300e_coco.py'
model_path = 'yolov5_n-v61_syncbn_fast_8xb16-300e_coco_20220919_090739-b804c1ad.pth'

model = init_detector(
    config=config_path,
    checkpoint=model_path,
    device='cuda:0',
)

I get this error:

KeyError: 'YOLODetector is not in the model registry. Please check whether the value of `YOLODetector` is correct or it was registered as expected. More details can be found at https://mmengine.readthedocs.io/en/latest/tutorials/config.html#import-custom-python-modules'

env:
mmcv 2.0.0rc2 pypi_0 pypi
mmdet 3.0.0rc2 pypi_0 pypi
mmengine 0.3.0 pypi_0 pypi
mmyolo 0.1.2 pypi_0 pypi

Is there any way to use the inference API for mmyolo models?

from mmyolo.

fcakyon avatar fcakyon commented on May 5, 2024

@hhaAndroid I am having another issue:

KeyError: 'LoadImageFromNDArray is not in the transform registry. Please check whether the value of `LoadImageFromNDArray` is correct or it was registered as expected. More details can be found at https://mmengine.readthedocs.io/en/latest/tutorials/config.html#import-custom-python-modules'

trying to perform inference using inference_detector(self.model, image) with numpy image.

from mmyolo.

fcakyon avatar fcakyon commented on May 5, 2024

@hhaAndroid now gives the following error during inference:

KeyError: 'YOLOv5KeepRatioResize is not in the transform registry. Please check whether the value of `YOLOv5KeepRatioResize` is correct or it was registered as expected. More details can be found at https://mmengine.readthedocs.io/en/latest/tutorials/config.html#import-custom-python-modules'

from mmyolo.

fcakyon avatar fcakyon commented on May 5, 2024

@hhaAndroid here is a list of issues I am facing:

Scenario1:

import numpy as np
from mmdet.apis import inference_detector, init_detector
from mmyolo.utils import register_all_modules
from mmengine.registry import DefaultScope

config_path = 'yolov5_n-v61_syncbn_fast_8xb16-300e_coco.py'
model_path = 'yolov5_n-v61_syncbn_fast_8xb16-300e_coco_20220919_090739-b804c1ad.pth'

register_all_modules()

model = init_detector(
    config=config_path,
    checkpoint=model_path,
    device='cuda:0',
)

prediction_result = inference_detector(model, np.random.randn(1, 3, 640, 640))

Error:

KeyError: 'LoadImageFromNDArray is not in the transform registry. Please check whether the value of `LoadImageFromNDArray` is correct or it was registered as expected. More details can be found at https://mmengine.readthedocs.io/en/latest/tutorials/config.html#import-custom-python-modules'

Scenario2:

import numpy as np
from mmdet.apis import inference_detector, init_detector
from mmyolo.utils import register_all_modules
from mmengine.registry import DefaultScope

config_path = 'yolov5_n-v61_syncbn_fast_8xb16-300e_coco.py'
model_path = 'yolov5_n-v61_syncbn_fast_8xb16-300e_coco_20220919_090739-b804c1ad.pth'

register_all_modules()

with DefaultScope.overwrite_default_scope("mmdet"):
    model = init_detector(
        config=config_path,
        checkpoint=model_path,
        device="cuda:0",
    )

prediction_result = inference_detector(model, np.random.randn(1, 3, 640, 640))

Error:

'YOLODetector is not in the model registry. Please check whether the value of `YOLODetector` is correct or it was registered as expected. More details can be found at https://mmengine.readthedocs.io/en/latest/tutorials/config.html#import-custom-python-modules'

Scenario3:

import numpy as np
from mmdet.apis import inference_detector, init_detector
from mmyolo.utils import register_all_modules
from mmengine.registry import DefaultScope

config_path = 'yolov5_n-v61_syncbn_fast_8xb16-300e_coco.py'
model_path = 'yolov5_n-v61_syncbn_fast_8xb16-300e_coco_20220919_090739-b804c1ad.pth'

with DefaultScope.overwrite_default_scope("mmdet"):
    register_all_modules()

    model = init_detector(
        config=config_path,
        checkpoint=model_path,
        device="cuda:0",
    )

prediction_result = inference_detector(model, np.random.randn(1, 3, 640, 640))

Error:

'LoadImageFromNDArray is not in the transform registry. Please check whether the value of `LoadImageFromNDArray` is correct or it was registered as expected. More details can be found at https://mmengine.readthedocs.io/en/latest/tutorials/config.html#import-custom-python-modules'

Scenario4:

import numpy as np
from mmdet.apis import inference_detector, init_detector
from mmyolo.utils import register_all_modules
from mmengine.registry import DefaultScope

config_path = 'yolov5_n-v61_syncbn_fast_8xb16-300e_coco.py'
model_path = 'yolov5_n-v61_syncbn_fast_8xb16-300e_coco_20220919_090739-b804c1ad.pth'

with DefaultScope.overwrite_default_scope("mmdet"):
    register_all_modules()

    model = init_detector(
        config=config_path,
        checkpoint=model_path,
        device="cuda:0",
    )

    prediction_result = inference_detector(model, np.random.randn(1, 3, 640, 640))

Error:

'LoadImageFromNDArray is not in the transform registry. Please check whether the value of `LoadImageFromNDArray` is correct or it was registered as expected. More details can be found at https://mmengine.readthedocs.io/en/latest/tutorials/config.html#import-custom-python-modules'

Scenario5:

import numpy as np
from mmdet.apis import inference_detector, init_detector
from mmyolo.utils import register_all_modules
from mmengine.registry import DefaultScope

config_path = 'yolov5_n-v61_syncbn_fast_8xb16-300e_coco.py'
model_path = 'yolov5_n-v61_syncbn_fast_8xb16-300e_coco_20220919_090739-b804c1ad.pth'

register_all_modules()

with DefaultScope.overwrite_default_scope("mmdet"):
    model = init_detector(
        config=config_path,
        checkpoint=model_path,
        device="cuda:0",
    )

    prediction_result = inference_detector(model, np.random.randn(1, 3, 640, 640))

Error:

'YOLODetector is not in the model registry. Please check whether the value of `YOLODetector` is correct or it was registered as expected. More details can be found at https://mmengine.readthedocs.io/en/latest/tutorials/config.html#import-custom-python-modules'

from mmyolo.

hhaAndroid avatar hhaAndroid commented on May 5, 2024

@fcakyon I'm very sorry. I didn't realize there were so many problems with cross-library calls now. It seems that overwrite_default_scope is not working and I have to rely on open-mmlab/mmdetection#9242 to fix it.

from mmyolo.

fcakyon avatar fcakyon commented on May 5, 2024

@fcakyon I'm very sorry. I didn't realize there were so many problems with cross-library calls now. It seems that overwrite_default_scope is not working and I have to rely on open-mmlab/mmdetection#9242 to fix it.

Is that update included in mmdet==v3.0.0rc3 or should I install mmdet v3 from source?

from mmyolo.

fcakyon avatar fcakyon commented on May 5, 2024

For slice inference, there's already a huge_image_demo in mmrotate for large image slice inference, maybe we can refactor this feature in mmdet or mmcv to share this feature cross libraries.

yes that would be a great solution

from mmyolo.

fcakyon avatar fcakyon commented on May 5, 2024

Except for slice inference, I also expect there will be a slice evaluate just like coco evaluate in sahi. But evaluate in sahi only support coco, i hope that could support more dataset or more universal.

Actually sahi coco evaluate is similar to standard coco evaluation. It is not a sliced evaluation. We create coco formatted result.json after merging slice results.

from mmyolo.

liuyanyi avatar liuyanyi commented on May 5, 2024

Slicing training is also a feature I was looking forward to. In DOTA dataset for rotate object detection, all image will be sliced to patches before training and testing, sliced datasets take up a lot of storage space. During paper reproduction, if some papers use a different slice size or strategy, the images need to be sliced again, its a huge burden for my hard drive.

Creating a sliced dataset and then training on these images is the trivial solution. But if you want to save some disk space, these slicing operation can be performed during training on the fly as an augmentation with the help of dataloader maybe. For each loaded image, crop augmentation can be applied in a structured way (instead of randomly cropping) then these crop augmentations can be input into the model.

A slice dataset wrapper and pipeline may be a good solution, this can solve the preprocess, but how to handle the postprocess such as merge results? should the slicing during evaluation and inference be considered as type of test time augmentation

from mmyolo.

fcakyon avatar fcakyon commented on May 5, 2024

A slice dataset wrapper and pipeline may be a good solution, this can solve the preprocess, but how to handle the postprocess such as merge results? should the slicing during evaluation and inference be considered as type of test time augmentation

You are right, it would be better to handle it as test time augmentation so all slice results are merged back into the original image before performing image evaluation.

from mmyolo.

hhaAndroid avatar hhaAndroid commented on May 5, 2024

mmdet==v3.0.0rc3

mmdet==v3.0.0rc3

from mmyolo.

hhaAndroid avatar hhaAndroid commented on May 5, 2024

@liuyanyi Thank you very much for your feedback. I think you have a very good idea and it's something we really want to do. I'm not sure how much of a challenge it is for sahi to do this in combination with the OpenMMLab framework? Maybe we have to keep communicating and collaborating. Do we design a draft version of the proposal based on the requirements we have gathered so far? @fcakyon

from mmyolo.

hhaAndroid avatar hhaAndroid commented on May 5, 2024

@fcakyon Can you just provide a version that supports image_demo.py?

from mmyolo.

fcakyon avatar fcakyon commented on May 5, 2024

@hhaAndroid @PeterH0323 created a pr adding large image demo using sahi: #284

Tested with yolov5_n-v61_syncbn_fast_8xb16-300e_coco and works fine.

What are your thoughts?

from mmyolo.

fcakyon avatar fcakyon commented on May 5, 2024

Thank you. I have replied

I have resolved your replies, can you check again in your free time? :)

from mmyolo.

hhaAndroid avatar hhaAndroid commented on May 5, 2024

@fcakyon Thank you very much, I made a few comments

from mmyolo.

fcakyon avatar fcakyon commented on May 5, 2024

@hhaAndroid thanks for the feedback. What is your opinion on adding large_image_inference api to mmdet?

from mmyolo.

hhaAndroid avatar hhaAndroid commented on May 5, 2024

@fcakyon My suggestion is to let users try it for a month and improve it before migrating to mmdet. What's your opinion?

from mmyolo.

fcakyon avatar fcakyon commented on May 5, 2024

@hhaAndroid sounds great ๐Ÿ‘๐Ÿป

from mmyolo.

thiagoribeirodamotta avatar thiagoribeirodamotta commented on May 5, 2024

Was Sahi support added for online training? Is there any examples demonstrating how to use it?

from mmyolo.

Related Issues (20)

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.