This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from iou import intersection_over_union | |
def nms( | |
predictions, | |
iou_threshold, | |
threshold, | |
box_format='corners' | |
): | |
''' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
def intersection_over_union(prediction_box, label_box, box_format='corners'): | |
''' | |
Funtion to calculate IOU between boxs | |
Parametters: | |
- prediction_box: a tensor with shape (N,4) - N boxs | |
- label_box: a tensor with shape (N,4) - N boxs | |
- box_format: enum between 'corner' and 'midpoint' | |
''' | |
if box_format == 'corners': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from collections import Counter | |
from iou import intersection_over_union | |
def mean_average_precision( | |
pred_boxes, true_boxes, iou_threshold=0.5, box_format="midpoint", num_classes=20 | |
): | |
""" | |
Calculates mean average precision |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from abc import ABC, abstractmethod | |
class Polygon(ABC): | |
@abstractmethod | |
def noofsides(self): | |
pass | |
class Triangle(Polygon): | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Employee: | |
def __init__(self, first, last): | |
self.first = first | |
self.last = last | |
@property | |
def email(self): | |
return '{}.{}@email.com'.format(self.first, self.last) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Employee: | |
raise_amt = 1.04 | |
def __init__(self, first, last, pay): | |
self.first = first | |
self.last = last | |
self.email = first + '.' + last + '@email.com' | |
self.pay = pay |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Employee: | |
raise_amount = 1.05 | |
num_of_emps = 0 | |
def __init__(self, first, last, pay): | |
self.first = first | |
self.last = last | |
self.pay = pay | |
self.email = first+'.'+last+'@company.com' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Employee: | |
raise_amount = 1.05 | |
num_of_emps = 0 | |
def __init__(self, first, last, pay): | |
self.first = first | |
self.last = last | |
self.pay = pay | |
self.email = first+'.'+last+'@company.com' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Employee: | |
def __init__(self, first, last, pay): | |
self.first = first | |
self.last = last | |
self.pay = pay | |
self.email = first+'.'+last+'@company.com' | |
def fullname(self): | |
return f"{self.first} {self.last}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
async def count(): | |
print("One") | |
await asyncio.sleep(1) | |
print("Two") | |
async def main(): | |
await asyncio.gather(count(), count(), count()) |