Skip to content

Commit

Permalink
place ependency scipy from runtime to optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Ezra-Yu committed Aug 15, 2022
1 parent 7b1af11 commit 37f0469
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mmcls/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from .mnist import MNIST, FashionMNIST
from .multi_label import MultiLabelDataset
from .samplers import DistributedSampler, RepeatAugSampler
from .stanford_car import StanfordCars
from .stanford_cars import StanfordCars
from .voc import VOC

__all__ = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from typing import Optional

import numpy as np
import scipy.io as sio

from .base_dataset import BaseDataset
from .builder import DATASETS
Expand Down Expand Up @@ -184,6 +183,12 @@ def __init__(self,
**kwargs)

def load_annotations(self):
try:
import scipy.io as sio
except ImportError:
raise ImportError(
'please run `pip install scipy` to install package `scipy`.')

data_infos = []
if self.test_mode:
data = sio.loadmat(self.test_ann_file)
Expand Down
1 change: 1 addition & 0 deletions requirements/optional.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ albumentations>=0.3.2 --no-binary qudida,albumentations
colorama
requests
rich
scipy
1 change: 0 additions & 1 deletion requirements/runtime.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
matplotlib
numpy
packaging
scipy
7 changes: 6 additions & 1 deletion tests/test_data/test_datasets/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from unittest.mock import patch

import numpy as np
import scipy.io as sio
import torch

from mmcls.datasets import DATASETS
Expand Down Expand Up @@ -827,6 +826,12 @@ def setUpClass(cls) -> None:
cls.DEFAULT_ARGS = dict(
data_prefix=cls.data_prefix, pipeline=[], test_mode=False)

try:
import scipy.io as sio
except ImportError:
raise ImportError(
'please run `pip install scipy` to install package `scipy`.')

sio.savemat(
cls.train_ann_file, {
'annotations': [(
Expand Down

0 comments on commit 37f0469

Please sign in to comment.