UniConvNet for Image Classification

August 13, 2025 · View on GitHub

This folder contains the implementation of the UniConvNet for Image Classification.

Usage

Install

  • Clone this repo
  • Create a conda virtual environment and activate it:
conda create -n UniConvNet python=3.7 -y
conda activate UniConvNet

For examples, to install torch==1.11 with CUDA==11.3:

pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 --extra-index-url https://download.pytorch.org/whl/cu113
  • Install timm==0.3.2 and mmcv-full==1.5.0:
pip install -U openmim
mim install mmcv-full==1.5.0
pip install timm==0.3.2 mmdet==2.28.1
pip install mmsegmentation==0.30.0
  • Install other requirements:
pip install opencv-python termcolor yacs pyyaml scipy tensorboardX wandb yapf==0.40.1
  • Compiling CUDA operators (Modified DCNV3)
cd ./ops_dcnv3
sh ./make.sh
# unit test (should see all checking is True)
python test.py
  • modify helpers.py in timm
cd ~/anaconda3/envs/UniConvNet/lib/python3.7/site-packages/timm/models/layers/
vim helpers.py
substitute "from torch._six import container_abcs"
with "import collections.abc as container_abcs"

Data Preparation

We use standard ImageNet dataset, you can download it from http://image-net.org/. We provide the following two ways to load data:

  • For standard folder dataset, move validation images to labeled sub-folders. The file structure should look like:

    $ tree data
    imagenet
    ├── train
       ├── class1
       ├── img1.jpeg
       ├── img2.jpeg
       └── ...
       ├── class2
       ├── img3.jpeg
       └── ...
       └── ...
    └── val
        ├── class1
       ├── img4.jpeg
       ├── img5.jpeg
       └── ...
        ├── class2
       ├── img6.jpeg
       └── ...
        └── ...
    
    
  • To boost the slow speed when reading images from massive small files, we also support zipped ImageNet, which includes four files:

    • train.zip, val.zip: which store the zipped folder for train and validate splits.
    • train.txt, val.txt: which store the relative path in the corresponding zip file and ground truth label. Make sure the data folder looks like this:
    $ tree data
    data
    └── ImageNet-Zip
        ├── train_map.txt
        ├── train.zip
        ├── val_map.txt
        └── val.zip
    
    $ head -n 5 meta_data/val.txt
    ILSVRC2012_val_00000001.JPEG	65
    ILSVRC2012_val_00000002.JPEG	970
    ILSVRC2012_val_00000003.JPEG	230
    ILSVRC2012_val_00000004.JPEG	809
    ILSVRC2012_val_00000005.JPEG	516
    
    $ head -n 5 meta_data/train.txt
    n01440764/n01440764_10026.JPEG	0
    n01440764/n01440764_10027.JPEG	0
    n01440764/n01440764_10029.JPEG	0
    n01440764/n01440764_10040.JPEG	0
    n01440764/n01440764_10042.JPEG	0