Spaces:
Build error
Build error
changed app.py
Browse files3 unmodified lines4567891011121314151617183 unmodified linesfrom transformers import BertTokenizerfrom datetime import datetimedevice = torch.device('cpu')model_name = 'bert-base-uncased'model = BertClassifier(model_name, 0.5)model.to(device)model.load_state_dict(torch.load('models/bert-all-data.pth', map_location=device))tokenizer = BertTokenizer.from_pretrained(model_name)def ai_text_classifier(text: str):tokens = tokenizer(text, return_tensors='pt', max_length=512, padding='max_length', truncation=True).to(device)prob = model(tokens['input_ids'], tokens['attention_mask']).item()3 unmodified lines4567891011121314151617183 unmodified linesfrom transformers import BertTokenizerfrom datetime import datetimedef ai_text_classifier(text: str):device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')model_name = 'bert-base-uncased'model = BertClassifier(model_name, 0.5)model.to(device)model.load_state_dict(torch.load('models/bert-all-data.pth', map_location=device))tokenizer = BertTokenizer.from_pretrained(model_name)tokens = tokenizer(text, return_tensors='pt', max_length=512, padding='max_length', truncation=True).to(device)prob = model(tokens['input_ids'], tokens['attention_mask']).item()
app.py+6-6