mirror of
https://github.com/luxfhe/examples.git
synced 2026-10-30 18:13:15 +00:00
ML examples: - credit_scoring: Credit risk prediction with HMEQ data - disease_prediction: Healthcare ML on encrypted records - cifar: Encrypted image classification - federated_learning: Distributed FHE training - hybrid_model: Mixed FHE/plaintext inference Deployment: - breast_cancer: Cancer detection API - sentiment_analysis: Encrypted NLP - server: FHE inference server Blockchain: - hardhat-template: Solidity + FHE - react-template: Full dApp with FHE
30 lines
920 B
Python
30 lines
920 B
Python
import os
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
|
|
def main():
|
|
path_of_script = Path(__file__).parent.resolve()
|
|
os.environ["TRANSFORMERS_CACHE"] = str((path_of_script / "hf_cache").resolve())
|
|
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
|
|
|
# Load the tokenizer (converts text to tokens)
|
|
tokenizer = AutoTokenizer.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment-latest")
|
|
|
|
# Load the pre-trained model
|
|
transformer_model = AutoModelForSequenceClassification.from_pretrained(
|
|
"cardiffnlp/twitter-roberta-base-sentiment-latest"
|
|
)
|
|
del tokenizer
|
|
del transformer_model
|
|
|
|
# Build image
|
|
os.chdir(path_of_script)
|
|
command = f'docker build --tag cml_client_sentiment_analysis --file "{path_of_script}/Dockerfile.client" .'
|
|
print(command)
|
|
subprocess.check_output(command, shell=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|