Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from flask import Flask, request, jsonify
|
| 2 |
from flask_cors import CORS
|
| 3 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
|
@@ -6,7 +9,6 @@ from sklearn.metrics.pairwise import cosine_similarity
|
|
| 6 |
import torch
|
| 7 |
import numpy as np
|
| 8 |
import pickle
|
| 9 |
-
import os
|
| 10 |
import json
|
| 11 |
import logging
|
| 12 |
import re
|
|
@@ -112,11 +114,11 @@ def load_ood_thresholds(model_path):
|
|
| 112 |
def load_intent_resources():
|
| 113 |
global intent_model, intent_tokenizer, intent_classes, intent_thresholds
|
| 114 |
try:
|
| 115 |
-
print("⏳ Loading intent model from Hugging Face Hub (
|
| 116 |
|
| 117 |
# Load intent model and tokenizer from HF Hub
|
| 118 |
-
intent_model = AutoModelForSequenceClassification.from_pretrained("
|
| 119 |
-
intent_tokenizer = AutoTokenizer.from_pretrained("
|
| 120 |
print("✅ Remote model and tokenizer loaded")
|
| 121 |
|
| 122 |
with open(os.path.join(INTENT_MODEL_PATH, "intent_classes.pkl"), "rb") as f:
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
os.environ["HF_HOME"] = "/tmp/huggingface" # ✅ custom safe cache dir
|
| 3 |
+
|
| 4 |
from flask import Flask, request, jsonify
|
| 5 |
from flask_cors import CORS
|
| 6 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
|
|
|
| 9 |
import torch
|
| 10 |
import numpy as np
|
| 11 |
import pickle
|
|
|
|
| 12 |
import json
|
| 13 |
import logging
|
| 14 |
import re
|
|
|
|
| 114 |
def load_intent_resources():
|
| 115 |
global intent_model, intent_tokenizer, intent_classes, intent_thresholds
|
| 116 |
try:
|
| 117 |
+
print("⏳ Loading intent model from Hugging Face Hub (ZEROSTUDIOS/Bipa-Classification)")
|
| 118 |
|
| 119 |
# Load intent model and tokenizer from HF Hub
|
| 120 |
+
intent_model = AutoModelForSequenceClassification.from_pretrained("ZEROSTUDIOS/Bipa-Classification")
|
| 121 |
+
intent_tokenizer = AutoTokenizer.from_pretrained("ZEROSTUDIOS/Bipa-Classification")
|
| 122 |
print("✅ Remote model and tokenizer loaded")
|
| 123 |
|
| 124 |
with open(os.path.join(INTENT_MODEL_PATH, "intent_classes.pkl"), "rb") as f:
|