Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from detoxify import Detoxify | |
| all_categories = {'all_categories': [ | |
| 'toxicity', | |
| 'obscene', | |
| 'threat', | |
| 'insult', | |
| 'identity_attack', | |
| 'sexual_explicit' | |
| ] | |
| } | |
| examples = [ | |
| ['Yes indeed. She sort of reminds me of the elder lady that played the part in the movie "Titanic" who was telling her story!!! And I wouldn\'t have wanted to cover who I really am!! I would be proud!!!! WE should be proud of our race no matter what it is!!', | |
| 50], | |
| ['The trans women reading this tweet right now is beautiful', 50], | |
| ["Question: These 4 broads who criticize America, what country did they flee to get here? And now they want to make OUR America like THEIR former HELL HOLE. I don't think so!!!!!!!!!! Let them explain their GRATITUDE for letting them in OUR country.", | |
| 50], | |
| ['Well being subtle you could not have been born because black people don\'t matter', | |
| 50], | |
| ["For starters bend over the one in pink and kick that ass and pussy to get a taste until she's begging for a dick inside her.", | |
| 50] | |
| ] | |
| model = Detoxify('multilingual') | |
| def toxicity(sentence, threshold): | |
| predicts = model.predict(sentence) | |
| return [ x for x in predicts if predicts[x] > threshold/100 ], all_categories | |
| gr.Interface(fn=toxicity, | |
| inputs=[ | |
| gr.Textbox(placeholder="Enter sentence here..."), | |
| gr.Slider(0, 100) | |
| ], | |
| outputs=[ | |
| 'text', | |
| gr.JSON(all_categories) | |
| ], | |
| examples=examples).launch() | |