Fe d dl Z d dlmZmZ e j r ed e j d ZnUe j j r ed e j d Zn ed e j d Zd Z ej e Z ej e d e Zd ZdS ) N)RobertaTokenizer RobertaForSequenceClassificationz USING CUDAcudazUSING Apple Metalmpsz USING CPUcpuzmshenoda/roberta-spam ) num_labelsc t | dddd }d | D }t j 5 t d i |}d d d n# 1 swxY w Y t j |j d S ) Npt max_lengthTi )return_tensorspadding truncationr c J i | ] \ }}|| t !S )todevice).0kvs 0/Users/kobaltz/Projects/spam-checker/detector.py <dictcomp>zdetect.<locals>.<dictcomp> s( 666!AqttF||666 )dimr ) tokenizeritemstorchno_gradmodelargmaxlogits)textinputsoutputss r detectr&