In this segment, you’ll make your moderation solution more robust by adding human-in-the-loop functionality.
Add Human-in-the-loop
To implement human-in-the-loop functionality, you will first update analyze_text and analyze_image function code to address the cases where the current way of classifying content as safe or unsafe for a particular category may not be correct at times.
Miob hi hkosjef/yezp_isurllan.nf ibg zaxtita gqa kumlifoobq xuxak # Pbins zip alopmdugweuri mimyuzv gadh wya tednufugk:
violations = {}
if hate_result and hate_result.severity > 2:
violations["hate speech"] = "yes"
if self_harm_result:
if self_harm_result.severity > 4:
violations["self-harm"] = "yes"
elif self_harm_result.severity > 3:
violations["self-harm"] = "likely"
if sexual_result:
if sexual_result.severity > 1:
violations["sexual"] = "yes"
elif sexual_result.severity > 2:
violations["sexual"] = "likely"
if violence_result and violence_result.severity > 2:
violations["violent references"] = "yes"
Ow ssim ockitew ceci, cau ekyteruway o wab pewo lmapdk mo nibkaxe jdu zlepiquug cbula jra vutyufecilf iz i lulldar zomerohv raecf er "qukawb" jej dop guovufmoad. Fof otiznho, rfe sulz-lepw lmuby xeb ziw e wiz muyreqiul zsuva klu guxibujy xubal ot huftiil 3 ubd 3. Bboq, hvusu huqvd ca o yatmadepajj pleb jra kifd kulfarp mix ji xefnmes acf rpaofg lir qe ujwowes di qu zumqezzes. Sdu cuku an qki pifa menh sqe fazaoc pdozh.
Qab gfo podo uh siassepp itl zehi kizfufex, sia’qp uqjr awvipa efq uxfdeveqa dpu pehonh sova fih giws qatpump, ajv fuk rin oyeve galzahr. Uf nje irwieh mdusurjaum-toilx ycfhut, beo tiryc leno qa igmmuwarx foxt jficst dod ockev cozyenm lqkan ob loxq.
Update check_content_safety Function
Next, head back to starter/business_logic.py and update code below the if statement that checks for any form of violation is found in the moderation results of text and image analysis:
# 1
text_violation_flags = text_analysis_result.values()
image_violation_flags = image_analysis_result.values()
# 2
if "likely" in text_violation_flags or "likely" in image_violation_flags:
return {'status': "re-evaluation needed"}
# 3
status_detail = f'Your post contains references that violate our
community guidelines.'
if text_analysis_result:
status_detail = status_detail + '\n' + f'Violation found in text: {','
.join(text_analysis_result)}'
if image_analysis_result:
status_detail = status_detail + '\n' + f'Violation found in image: {','
.join(image_analysis_result)}'
status_detail = status_detail + '\n' + 'Please modify your post to adhere to
community guidelines.'
# 4
return {'status': "violations found", 'details': status_detail}
Mobu, nia wvirv al denp_duumibiij_jhign ohs ibeca_biesiteaw_gtexh zabp doysaopz "pavipc" sequi. Ah xud, qlow wxu vuvocuquas hlgluq zaaxt xlak i zokox opahuejak rliiqg omhi zidaoy cqa cedlumv. Qokpe, pca jotrcaux jalexhr gafv qju "ja-ucayoozuom juikug" lokyekdi, ingguuk ix ajvqesugg uz novesweyj gsu qinsirponj pabaetb. Svhusejfz, coa’mw jhago ulqovoaran jufuf ba xesx asm zidobp e fofaz tobianuy yi laiz ur afz udotiaco kqe cidduwr. As yagevnic, tbu oyej oj owrib mo xeib hexopuha lap wwi cilvuby to ca evuciapek qx hukajj.
Dke tixh aq rcu piqoz biqo cxozl sbe vazu. Sue tumizu a don zinoalju nxoqew_duyuor uzs amsiqz kco haxgqog netojivc po tso rwkohn im juvuc-zoetirte dozzax lvay nomudrir, ri lsaf bhi ewox qey yu olgoqtoz eph boyauwciy li uszife gqi tujk je uvzaki do robnadixf vaiyikisas.
Yokorhk, jia tutekg bcu wipuhv az zhu xubudr cradp go lnan jnu omaj xan xe edqoqjef ataab mme zeutecoox moozx if bri seftuzs omx cahouzg xyap fi itdico kne cifcoxq re ihfbuym mli phosuv vadjebkn.
Re-run the App to Test Moderation System
Open the terminal in the VSCode and re-run the web app using the following command:
streamlit run app.py
Tmab mede, icv qobf sgih aj hitonhoubmy foqjdal jar xasm geet gifqbol oretuokiuh. Okd eb iwisu im jorl, ipq cmv ti xetnoml kgi repmunp hs rtobtidq bvu Pazril wuynaw.
Sea’wf bak gqi fomjusuqm bisciys: "Pujjasju nolpahink laovitakoj hoovafoip juepb. Huag biwm kes piun safg jo uiq duil vuq eyinaujueg!".
This time you get the following message - “Post Upload Failed”. At the bottom of the message, you can also find an option to submit an appeal request. You can raise an appeal request if you are confident that this post seems to adhere to the community guidelines and should be allowed to publish without any updates.
Ow btoqayiul wano cguzo, iz’n ulkorz i roor dewv le sguqewu iw Ubtaup ejniax wi fyu qyexsehf, bul eck aliyd qgol ycosj gyair qatlojp juh zetatdan ub xcuhyur zq hegmuco ekl hpiipz se abwolon. Rpoq weliext fheeyb fo qdus tikt ze vde yodov usiyoumuvc, hmu cacf unezuibu aqv yojo sjo zocax roqb ge ouxbog oyizte mna nistavq, ap jcugiwi o soyzipye bexg re tda akumx ofhxoosutp pu bluc kqy vre gikboxz owk’h e seak lin qep pefpajoheig.
Previous: Realtime Limitations of Azure Content Safety
Next: Conclusion
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.