DataScience
article thumbnail
728x90

논문 

https://www.mdpi.com/2220-9964/8/12/549

 

WeatherNet: Recognising Weather and Visual Conditions from Street-Level Images Using Deep Residual Learning

Extracting information related to weather and visual conditions at a given time and space is indispensable for scene awareness, which strongly impacts our behaviours, from simply walking in a city to riding a bike, driving a car, or autonomous drive-assist

www.mdpi.com

 

 

 

 

1. 모델 파이프라인

새벽/황혼, 낮, 밤, 눈부심, 비, 눈, 안개를 각각 감지하는 4개의 심층 CNN 모델로 구성

(1) NightNet은 새벽/황혼, 낮과 밤의 차이를 감지합니다. 기상 조건과 도시 구조의 역동성에도 불구하고 거리 수준 이미지의 미묘함을 이해하는 것을 목표로 합니다. 

(2) GlareNet은 다양한 기상 조건의 새벽/해질녘, 낮과 밤 모두에 대해 광원(태양 또는 인공 조명)에 관계없이 눈부신 이미지를 감지합니다. 눈부심은 보정 없이 카메라 길이에 링이나 별 효과를 일으키는 것으로 볼 수 있는 직접적인 광원으로 정의됩니다. 

(3) PreciptationNet은 낮과 밤 모두 맑은 날씨, 비가 오는 날씨, 눈 오는 날씨를 감지합니다. 

(4) FogNet은 새벽/황혼의 안개 발생을 감지합니다.

 

모델 2와 4는 앞서 언급한 이벤트 중 하나가 발생하는지 여부를 감지하는 이진 분류기(0,1)로 학습된 반면 모델 1과 3은 세 가지 클래스 중 하나를 출력하도록 학습되었습니다

 

2. 방법론

pretrained 모델 4개를 정의하고

input형식을 dict형식으로 넣어줘야겠습니다.

각각 loss를 구해서 loss합치면 될듯한데 

loss값이 1.6에서 안떨어지네요 조금 더 연구해봐야겠습니다.

 

 model define

<python />
class model1(nn.Module): def __init__(self, num_classes=): super(model1, self).__init__() def forward(self, x): class model2(): def __init__(self, num_classes=): super(model2, self).__init__() def forward(self, x): class model3(): def __init__(self, num_classes=): super(model3, self).__init__() def forward(self, x): class model4(): def __init__(self, num_classes=): super(model3, self).__init__() def forward(self, x):

 

train

<python />
def train(**arg) ... output1 = model1(image) output2 = model2(image) output3 = model3(image) output4 = model4(image) label1_ = output1['label1'] label2_ = output2['label2'] label3_ = output3['label3'] label4_ = output4['label4'] loss1=nn.CrossEntropyLoss(preds,trues) loss2=nn.CrossEntropyLoss(preds,trues) loss3=nn.CrossEntropyLoss(preds,trues) loss4=nn.CrossEntropyLoss(preds,trues) loss = loss1 + loss2 + loss3 + loss4 loss.backward() # grad optimizer.step()

validation

<python />
def validation(): train과 동일하게 loss계산

 

 

2.1. nn.BCELoss(), nn.CrossEntropyLoss() 마저 찾아보기

CLASStorch.nn.BCELoss(weight=Nonesize_average=Nonereduce=Nonereduction='mean')

<code />
>>> m = nn.Sigmoid() >>> loss = nn.BCELoss() >>> input = torch.randn(3, requires_grad=True) >>> target = torch.empty(3).random_(2) >>> output = loss(m(input), target) >>> output.backward()

https://pytorch.org/docs/stable/generated/torch.nn.BCELoss.html#torch.nn.BCELoss

 

BCELoss — PyTorch 1.13 documentation

Shortcuts

pytorch.org

 

profile

DataScience

@Ninestar

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!