Spaces:
Runtime error
Runtime error
Upload hy3dgen/texgen/utils/counter_utils.py with huggingface_hub
Browse files
hy3dgen/texgen/utils/counter_utils.py
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Open Source Model Licensed under the Apache License Version 2.0
|
2 |
+
# and Other Licenses of the Third-Party Components therein:
|
3 |
+
# The below Model in this distribution may have been modified by THL A29 Limited
|
4 |
+
# ("Tencent Modifications"). All Tencent Modifications are Copyright (C) 2024 THL A29 Limited.
|
5 |
+
|
6 |
+
# Copyright (C) 2024 THL A29 Limited, a Tencent company. All rights reserved.
|
7 |
+
# The below software and/or models in this distribution may have been
|
8 |
+
# modified by THL A29 Limited ("Tencent Modifications").
|
9 |
+
# All Tencent Modifications are Copyright (C) THL A29 Limited.
|
10 |
+
|
11 |
+
# Hunyuan 3D is licensed under the TENCENT HUNYUAN NON-COMMERCIAL LICENSE AGREEMENT
|
12 |
+
# except for the third-party components listed below.
|
13 |
+
# Hunyuan 3D does not impose any additional limitations beyond what is outlined
|
14 |
+
# in the repsective licenses of these third-party components.
|
15 |
+
# Users must comply with all terms and conditions of original licenses of these third-party
|
16 |
+
# components and must ensure that the usage of the third party components adheres to
|
17 |
+
# all relevant laws and regulations.
|
18 |
+
|
19 |
+
# For avoidance of doubts, Hunyuan 3D means the large language models and
|
20 |
+
# their software and algorithms, including trained model weights, parameters (including
|
21 |
+
# optimizer states), machine-learning model code, inference-enabling code, training-enabling code,
|
22 |
+
# fine-tuning enabling code and other elements of the foregoing made publicly available
|
23 |
+
# by Tencent in accordance with TENCENT HUNYUAN COMMUNITY LICENSE AGREEMENT.
|
24 |
+
|
25 |
+
|
26 |
+
class RunningStats():
|
27 |
+
def __init__(self) -> None:
|
28 |
+
self.count = 0
|
29 |
+
self.sum = 0
|
30 |
+
self.mean = 0
|
31 |
+
self.min = None
|
32 |
+
self.max = None
|
33 |
+
|
34 |
+
def add_value(self, value):
|
35 |
+
self.count += 1
|
36 |
+
self.sum += value
|
37 |
+
self.mean = self.sum / self.count
|
38 |
+
|
39 |
+
if self.min is None or value < self.min:
|
40 |
+
self.min = value
|
41 |
+
|
42 |
+
if self.max is None or value > self.max:
|
43 |
+
self.max = value
|
44 |
+
|
45 |
+
def get_count(self):
|
46 |
+
return self.count
|
47 |
+
|
48 |
+
def get_sum(self):
|
49 |
+
return self.sum
|
50 |
+
|
51 |
+
def get_mean(self):
|
52 |
+
return self.mean
|
53 |
+
|
54 |
+
def get_min(self):
|
55 |
+
return self.min
|
56 |
+
|
57 |
+
def get_max(self):
|
58 |
+
return self.max
|