clean_str() function addition (#1674)

* clean_str() function addition

* cleanup

* add euro symbol €

* add closing exclamation (spanish)

* cleanup
This commit is contained in:
Glenn Jocher authored and GitHub committed 2020-12-17 17:20:20 -08:00
1 parent 7e161d9774
commit d5289b54c4
3 files changed
+13 -7

No files matched your search

+6 -1
View File
@@ -2,6 +2,7 @@
import glob
import logging
import math
import os
import platform
import random
@@ -11,7 +12,6 @@ import time
from pathlib import Path
import cv2
import math
import numpy as np
import torch
import torchvision
@@ -97,6 +97,11 @@ def make_divisible(x, divisor):
return math.ceil(x / divisor) * divisor
def clean_str(s):
# Cleans a string by replacing special characters with underscore _
return re.sub(pattern="[|@#!¡·$€%&()=?¿^*;:,¨´><+]", repl="_", string=s)
def labels_to_class_weights(labels, nc=80):
# Get class weights (inverse frequency) from training labels
if labels[0] is None: # no labels loaded