GluonCV

raw JSON →
0.10.5.post0 verified Fri May 01 auth: no python maintenance

GluonCV is a deep learning computer vision toolkit originally built on Apache MXNet, now also supporting PyTorch. Version 0.10.5.post0 is the latest release. The project is in maintenance mode with infrequent releases.

pip install gluoncv
error ImportError: No module named 'gluoncv.model_zoo'
cause Attempting to import model_zoo as a top-level module instead of a subpackage.
fix
Use 'from gluoncv import model_zoo' instead of 'import gluoncv.model_zoo'.
error ModuleNotFoundError: No module named 'mxnet'
cause MXNet is not installed but required for default GluonCV usage.
fix
Install mxnet: pip install mxnet (or mxnet-cuXXX for GPU).
error AttributeError: module 'gluoncv' has no attribute 'data'
cause The 'data' subpackage is not automatically imported with 'import gluoncv'.
fix
Explicitly import: 'from gluoncv import data'.
breaking GluonCV 0.10.x drops Python 2 support and requires MXNet >= 1.8.0.
fix Upgrade MXNet to 1.8+ and use Python 3.6+.
deprecated MXNet backend is deprecated in favor of PyTorch. New development is on PyTorch models.
fix Migrate to PyTorch backend using gluoncv.torch module.
gotcha model_zoo.get_model() may download large pretrained weights on first use; ensure internet connectivity and sufficient disk space.
fix Use gluoncv.model_zoo.get_model('...', pretrained=False) to skip download.
pip install gluoncv[torch]

Load a pre-trained YOLOv3 model and run inference on a random image (MXNet backend).

from gluoncv import model_zoo, data, utils
import mxnet as mx

# Load a pre-trained model
net = model_zoo.get_model('yolo3_darknet53_coco', pretrained=True)

# Prepare a sample image
from mxnet import nd
import numpy as np

# Simulate an image array
x = nd.random.uniform(0, 255, (1, 3, 416, 416))

# Perform inference
class_ids, scores, bounding_boxes = net(x)
print('Detected objects:', class_ids, scores, bounding_boxes)