Views
No views yet

1
2from transformers import AutoModelForSequenceClassification, AutoTokenizer
3from huggingface_hub import hf_hub_download
4
5model = AutoModelForSequenceClassification.from_pretrained("shyeon5898/paxmeter")
6tokenizer = AutoTokenizer.from_pretrained("shyeon5898/paxmeter")
7
8rep=hf_hub_download(repo_id="shyeon5898/paxmeter", filename="id2label.json")
9with open(rep, "r") as json_file:
10 i2l = json.load(json_file)
11f_pipe = pipeline("text-classification", model=f_model, tokenizer=tokenizer)
12input_text = "The South's unification minister, Jeong Se-hyun, told Kim Yong-nam in Pyongyang that the revelation had darkened the mood, and urged the North to end its programme"
13outputs = f_pipe(a)
14outputs[0]['label']
15print(i2l[outputs[0]['label'].split('_')[1]])
16-0.108