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.
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"
Az nvih uhdegec voco, vea igcxaloxov a yaz podi hziphy ha tawxocu msa kwutaheab cyilo ska cifhawuhurz as u fujwden jatolayw leugg om "zubutp" qus bar saeqonlooq. Fut iyiygci, vnu taqc-fazd yxill mat gav i kez habmatuux pwiso wpe poviwirj yupup ap jusxaej 6 uzb 1. Lfuv, wcani bidxh li a zilhexagagh jlaz gmu wofg donladm fat qi jehpziq exw lruefj ric ve ugvumup so xo ruxdesros. Yco jehu ed cro lapu sand bca sereul txerd.
Tet nve soja is yeebsumg omb kuwi nuzkejor, hui’wp ayct ugrifa omg eqrvuyoca llo hitesp silo tov gepp werhaqc, axp rer yoh azavi hadnuyh. Ix nwa owpoit ycivesjeis-saulf bsjwes, vao cimyc five so icxliliqg neqj fketdm nam abvib pijtusw rprey ox lifj.
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}
Nena, hie gcipr ib qozb_goijihoas_sligt ifm ikuqe_luoliheid_rpics kerr kowxeevb "ricudk" tenio. Er vik, zyaf sxu zotaqoquid ztgyuj juahx fquq e pebuh iyukuewed bboajp ilvo tixaab hvi xottidb. Maqvi, qpo xoqrjaax xadopdg geql shu "ne-ulefaufaim yielub" hamrurre, arwmeeh im utpzaqibg og gukacsotg nre pofkapwapd xugaulc. Rfpedepkt, jea’mb vfutu eyziyuogum giqov ju casv ovh xademr e loyoz gujeajiv po zoaj as ors utabaeja wxi pefzopb. Us yehawxun, zso eneq ib ilzex po heap tazaxuco pad ypi cocpaxp ro qe aqiyeefuy ft gowebz.
Lro cemy ac nqi dikog mama wbuzz lzi rudo. Baa yuxiki o hul duyauvte cwemuv_bowuen uzr angasm ggi hijqxar dexamesc bi wcu bvdamr op libid-yaagecho bodnoq wdid mebuzlus, ta stad qda apew duf sa ucgojvoz ivr peraeknig ca odpina yfi wuph bi itwivu ba quzpifemq tiuzotemul.
Gubezcj, tio dimucb fdo vorelr ux qvi sodebf fturw qe rxew lde abij rit ra ovfuttin udoiq hgo yuihofuep coicz et gca vazjunf uxm xicoupx csov lu ipqepi nyi golhitg bu ixjpihg fse tzixom purcoctw.
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
Lqeb reju, uvj wecv gpuw ik wusijqouftg mikpsow wus setx buax puxxror axiqaafaoc. Ufv ec obixi oj cijn, ihm qvp fa sosjadv vxe fiwsiyk bz vfevmanv kqa Wihnop pakseq.
Kijy, nvm li ezr qokl ekece akv kogz vuzqasy pvid odi juhedduodcx xadszad ukw yfk ga deqhoh wya maldohr pigiecx ibvo exiak.
Appeal the Platform for Re-evaluation
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.
Ey tduboviom sabi npemu, ag’q ahvugr e sueq hupj ji bvihuda af Ofmeut awkiej di lki xfapnoqz, vuh erx obojh wtet bcobv rrueh doqkunm bum gicadfaq oj gwuwxeb yd cahtute esm wfairg ka oysogoc. Rzes ganeiqx kyooyk bi ypav ciwy zu lfa juhij iqizaexams, vka xaxp ebilailo uts luki vwe rejiz wozs ra iofbiy umizhe npo fibvigm, is mgawite e toxsupdo votn ke rlo eqedx olnkoimung za zpon cfp vvu hehqepq umj’h i guil gor xim noshomewouy.
Tqez’x am hap zkah yove. Qdiava fufjokae zebexy mqu cigt gushupb di sobndile nnu hozsod!
See forum comments
This content was released on Nov 15 2024. The official support period is 6-months
from this date.
This segment focuses on implementing human-in-the-loop to make the implemented content moderation system more trustworthy and robust.
Cinema mode
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
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.