MalloryWittwerEPFL
commited on
Commit
•
0f9c15e
1
Parent(s):
d503812
Add last.ckpt, original_model_config.json, push_to_hub.py
Browse files- last.ckpt +3 -0
- original_model_config.json +1 -0
- push_to_hub.py +28 -0
last.ckpt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2881e191933c255d6a3c198009d8e673ea125b3a469e6a49f6b9fce16d8b1bed
|
3 |
+
size 886173223
|
original_model_config.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"batch_size": 8, "image_size": [768, 768], "max_epochs": 30, "model_name": "tf_efficientnetv2_m", "out_indices": [3, 4], "n_splits": -1, "pseudo_label": "pseudo_labels/round2.csv", "pseudo_conf_threshold": 0.6, "lr_backbone": 0.0016, "lr_head": 0.016, "lr_decay_scale": 0.01, "num_classes": 15587, "num_species_classes": 26, "pretrained": true, "warmup_steps_ratio": 0.2, "val_bbox": "fullbody", "test_bboxes": ["fullbody", "fullbody_charm"], "bboxes": {"fullbody_charm": 0.15, "fullbody": 0.6, "backfin": 0.15, "detic": 0.05, "none": 0.05}, "bbox_conf_threshold": 0.01, "n_data": -1, "global_pool": {"arch": "GeM", "p": 3, "train": false}, "normalization": "batchnorm", "optimizer": "AdamW", "loss_fn": "CrossEntropy", "loss_id_ratio": 0.437338, "margin_coef_id": 0.27126, "margin_coef_species": 0.226253, "margin_power_id": -0.364399, "margin_power_species": -0.720133, "s_id": 20.9588, "s_species": 33.1383, "margin_cons_id": 0.05, "margin_cons_species": 0.05, "n_center_id": 2, "n_center_species": 2, "aug": {"rotate": 15, "translate": 0.25, "shear": 3, "p_affine": 0.5, "crop_scale": 0.9, "crop_l": 0.75, "crop_r": 1.3333333333333333, "p_gray": 0.1, "p_blur": 0.05, "p_noise": 0.05, "p_downscale": 0.0, "p_shuffle": 0.3, "p_posterize": 0.2, "p_bright_contrast": 0.5, "p_cutout": 0.05, "p_snow": 0.1, "p_rain": 0.05}}
|
push_to_hub.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Script used to load a custom model and push it to HuggingFace.
|
3 |
+
Doc: https://huggingface.co/docs/transformers/custom_models#writing-a-custom-model
|
4 |
+
"""
|
5 |
+
import os
|
6 |
+
import json
|
7 |
+
|
8 |
+
os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"
|
9 |
+
|
10 |
+
from configuration_cetacean_classifier import (
|
11 |
+
CetaceanClassifierConfig,
|
12 |
+
)
|
13 |
+
from modeling_cetacean_classifier import (
|
14 |
+
CetaceanClassifierModelForImageClassification,
|
15 |
+
)
|
16 |
+
|
17 |
+
CetaceanClassifierConfig.register_for_auto_class()
|
18 |
+
CetaceanClassifierModelForImageClassification.register_for_auto_class("AutoModelForImageClassification")
|
19 |
+
|
20 |
+
with open("orignal_model_config.json", "r") as file:
|
21 |
+
config= json.load(file)
|
22 |
+
|
23 |
+
cetacean_config = CetaceanClassifierConfig(**config)
|
24 |
+
cetacean_classifier = CetaceanClassifierModelForImageClassification(cetacean_config)
|
25 |
+
|
26 |
+
cetacean_classifier.model.load_from_checkpoint("last.ckpt")
|
27 |
+
|
28 |
+
cetacean_classifier.push_to_hub("Saving-Willy/cetacean-classifier")
|