Skip to content

Instantly share code, notes, and snippets.

View m-klasen's full-sized avatar

mklasen m-klasen

  • Bonn
View GitHub Profile
@m-klasen
m-klasen / supervisely2coco.py
Last active March 31, 2021 08:31 — forked from caiofcm/supervisely2coco.py
Converting Supervisely output to COCO format for bitmaps and polygons
##
# Author: Caio Marcellos
# Email: caiocuritiba@gmail.com
##
import os
import numpy as np
import json
import glob
from datetime import datetime
from pathlib import Path
class Loss_combine(nn.Module):
def __init__(self):
super().__init__()
def forward(self, input, target,reduction='mean'):
x1,x2,x3 = input
x1,x2,x3 = x1.half(),x2.half(),x3.half()
y = target.long()
return 0.7*F.cross_entropy(x1,y[:,0],reduction=reduction)+ 0.1*F.cross_entropy(x2,y[:,1],reduction=reduction) + \
0.1*F.cross_entropy(x3,y[:,2],reduction=reduction)