Download utils.py from ibrim/CLIPModel: direct link, hf CLI and curl.
- Browser
- Download file 505 Bytes
-
https://huggingface.co/spaces/ibrim/CLIPModel/resolve/a4ece866497f9ee177f8e2012e72019af6970a39/utils.py
- Command line
-
hf download hf://spaces/ibrim/CLIPModel@a4ece866497f9ee177f8e2012e72019af6970a39/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/ibrim/CLIPModel/resolve/a4ece866497f9ee177f8e2012e72019af6970a39/utils.py
505 Bytes
| class AvgMeter: | |
| def __init__(self, name="Metric"): | |
| self.name = name | |
| self.reset() | |
| def reset(self): | |
| self.avg, self.sum, self.count = [0] * 3 | |
| def update(self, val, count=1): | |
| self.count += count | |
| self.sum += val * count | |
| self.avg = self.sum / self.count | |
| def __repr__(self): | |
| text = f"{self.name}: {self.avg:.4f}" | |
| return text | |
| def get_lr(optimizer): | |
| for param_group in optimizer.param_groups: | |
| return param_group["lr"] | |