Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
evaluate_every=evaluate_every,
device=device
)
model = trainer.train(model)
save_dir = "testsave/doc_regr"
model.save(save_dir)
processor.save(save_dir)
basic_texts = [
{"text": "The dress is just fabulous and it totally fits my size. The fabric is of great quality and the seams are really well hidden. I am super happy with this purchase and I am looking forward to trying some more from the same brand."},
{"text": "it just did not fit right. The top is very thin showing everything."},
]
model = Inferencer.load(save_dir)
result = model.inference_from_dicts(dicts=basic_texts)
assert isinstance(result[0]["predictions"][0]["pred"], np.float32)
level="INFO",
datefmt="%Y-%m-%d %H:%M:%S",
)
MODELS_DIRS = ["saved_models", "base_models"]
model_paths = []
for model_dir in MODELS_DIRS:
path = Path(model_dir)
if path.is_dir():
models = [f for f in path.iterdir() if f.is_dir()]
model_paths.extend(models)
INFERENCERS = {}
for idx, model_dir in enumerate(model_paths):
INFERENCERS[idx + 1] = Inferencer.load(str(model_dir))
app = Flask(__name__)
CORS(app)
api = Api(app, debug=True, validate=True, version="1.0", title="FARM NLP APIs")
app.config["JSON_SORT_KEYS"] = True
app.config["RESTPLUS_VALIDATE"] = True
@api.route("/models")
class ModelListEndpoint(Resource):
def get(self):
resp = []
for idx, model in INFERENCERS.items():
_res = {
"id": idx,