model loading change
Browse files- tasks/text.py +13 -8
tasks/text.py
CHANGED
@@ -18,14 +18,19 @@ router = APIRouter()
|
|
18 |
DESCRIPTION = "Electra_Base"
|
19 |
ROUTE = "/text"
|
20 |
|
21 |
-
# Load model and tokenizer
|
22 |
-
model_weights_path = hf_hub_download(repo_id="jennasparks/electra-tf", filename="tf_model.h5")
|
23 |
-
model_config_path = hf_hub_download(repo_id="jennasparks/electra-tf", filename="config.json")
|
24 |
-
|
25 |
-
config = ElectraConfig.from_json_file(model_config_path)
|
26 |
-
model = TFElectraForSequenceClassification(config)
|
27 |
-
model.load_weights(model_weights_path)
|
28 |
-
tokenizer = ElectraTokenizer.from_pretrained("google/electra-base-discriminator")
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
|
31 |
@router.post(ROUTE, tags=["Text Task"],
|
|
|
18 |
DESCRIPTION = "Electra_Base"
|
19 |
ROUTE = "/text"
|
20 |
|
21 |
+
# # Load model and tokenizer
|
22 |
+
# model_weights_path = hf_hub_download(repo_id="jennasparks/electra-tf", filename="tf_model.h5")
|
23 |
+
# model_config_path = hf_hub_download(repo_id="jennasparks/electra-tf", filename="config.json")
|
24 |
+
|
25 |
+
# config = ElectraConfig.from_json_file(model_config_path)
|
26 |
+
# model = TFElectraForSequenceClassification(config)
|
27 |
+
# model.load_weights(model_weights_path)
|
28 |
+
# tokenizer = ElectraTokenizer.from_pretrained("google/electra-base-discriminator")
|
29 |
+
|
30 |
+
model_repo = "jennasparks/electra-tf"
|
31 |
+
config = AutoConfig.from_pretrained(model_repo)
|
32 |
+
model = TFAutoModelForSequenceClassification.from_pretrained(model_repo)
|
33 |
+
tokenizer = AutoTokenizer.from_pretrained(model_repo)
|
34 |
|
35 |
|
36 |
@router.post(ROUTE, tags=["Text Task"],
|