GithubHelp home page GithubHelp logo

Comments (1)

AdeelH avatar AdeelH commented on August 26, 2024

I agree that it would be useful to support other TorchVision object detection models. Adding something like an architecture field to ObjectDetectionModelConfig and then modifying ObjectDetectionModelConfig.build_default_model() might be the way to go.

That said, one way to do this without any changes to RV is to use the workaround described here:

if external_model:
"""This demonstrates how to use an external model for object detection,
but to successfully use this functionality with different settings, the
following things should be kept in mind:
(1) Torchvision does not expose its object detection models via
torch hub (https://github.com/pytorch/vision/issues/1945). So, to
use those, you will need to fork the torchvision repo and manually
add those models or corresponding factory functions to hubconf.py.
Example: github.com/AdeelH/vision/blob/det_hubconf_0.10/hubconf.py.
Further, you should ensure that the branch of the fork is the same
version as the version in Raster Vision's Docker image; or, if
using outside Docker, it should match the version of the local
torchvision installation.
(2) The external model should behave exactly like torchvision
object detection models. This includes, but might not be limited
to:
- Accepting targets as dicts with keys: 'boxes' and 'labels'.
- Accepting 1-indexed class labels.
- Computing losses internally and returning them in a dict
during training.
- Returning predictions as dicts with keys: 'boxes', 'labels',
and 'scores'.
"""
model = ObjectDetectionModelConfig(
external_def=ExternalModuleConfig(
github_repo='AdeelH/vision:det_hubconf_0.12',
name='ssd',
entrypoint='ssd300_vgg16',
force_reload=True,
entrypoint_kwargs={
# torchvision OD models need add an additional null class,
# so +1 is needed here
'num_classes': len(class_config.names) + 1,
'pretrained': False,
'pretrained_backbone': True
}))

You'll need to fork the torchvision repo and create a branch with hubconf.py modified like this: https://github.com/AdeelH/vision/blob/356a78a894acf2a377353a4cdb2df52c1cea84b4/hubconf.py#L68-L72

from raster-vision.

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.