pytorch / pytorch/vision

First layer with single channel

Open
#4,297 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
17.9k
Forks
7.3k
Avg merge
1d 15h
Merged PRs (30d)
13

Description

🚀 Feature

When calling the model, it would be nice to be able to set the number of channels in the first layer.

Motivation

When using a grayscale image, I want the input to be a single channel.

Pitch

ex)

self.conv1 = nn.Conv2d(3, self.inplanes, kernel_size=7, stride=2, padding=3, bias=False)
-> self.conv1 = nn.Conv2d(1, self.inplanes, kernel_size=7, stride=2, padding=3, bias=False)

layers.append(ConvBNActivation(3, firstconv_output_channels, kernel_size=3, stride=2, norm_layer=norm_layer, activation_layer=nn.Hardswish))
-> layers.append(ConvBNActivation(1, firstconv_output_channels, kernel_size=3, stride=2, norm_layer=norm_layer,  activation_layer=nn.Hardswish))

Alternatives

My idea is to use parameters when calling the model.
ex)
self.conv1 = nn.Conv2d(input, self.inplanes, kernel_size=7, stride=2, padding=3, bias=False)

Additional context

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named; start by locating the model entry points and first convolution definitions referenced by the issue. Check how model-call parameters are handled, then verify that a caller can select one input channel for grayscale images without breaking the existing three-channel behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-vision, machine-learning
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.