Spaces:
Sleeping
Sleeping
Download scripts/check_install.py from nhdang117/ToxicScope: direct link, hf CLI and curl.
- Browser
- Download file 1.32 kB
-
https://huggingface.co/spaces/nhdang117/ToxicScope/resolve/main/scripts/check_install.py
- Command line
-
hf download hf://spaces/nhdang117/ToxicScope/scripts/check_install.py
-
curl -L -o check_install.py https://huggingface.co/spaces/nhdang117/ToxicScope/resolve/main/scripts/check_install.py
1.32 kB
| from pathlib import Path | |
| import sys,json | |
| ROOT=Path(__file__).resolve().parents[1];sys.path.insert(0,str(ROOT)) | |
| from runtime_setup import activate_java | |
| activate_java() | |
| from model_service import service | |
| from model_registry import registry | |
| if __name__=='__main__': | |
| print('Running real safe + teen-code sentences through every available model...',flush=True) | |
| data=service.predict_many([ | |
| 'Cảm ơn bạn đã hỗ trợ nhóm nghiên cứu hôm nay.', | |
| 'c0n gà 0c h3o', | |
| ]) | |
| for m in data['rows'][0]['models']:print(m['name'],m['label'],m['prob_toxic'] if m['prob_toxic'] is not None else m['decision_score']) | |
| if data['errors']: | |
| print(json.dumps(data['errors'],ensure_ascii=False,indent=2));sys.exit(1) | |
| ready=sum(m['available'] for m in registry()) | |
| assert data['model_count']==ready | |
| teen=data['rows'][1] | |
| assert teen['preprocessing']['inference_text']=='con gà óc heo' | |
| tfidf=[m for m in teen['models'] if m['id'].startswith('tf_idf_')] | |
| assert len(tfidf)==3 and all(m['label']=='TOXIC' for m in tfidf) | |
| print('Teen-code check:',teen['verdict']['label'],teen['vote']['toxic'],'TOXIC votes /',teen['vote']['total']) | |
| print(f'PASS: {ready} models ready; teen code normalized; {len(data["unavailable"])} configurations have no supplied checkpoint.') | |