From 02fae8a3532ea8592f2371d622e3e4890553297b Mon Sep 17 00:00:00 2001 From: Billy Zhao Date: Thu, 26 Sep 2019 01:02:09 +0100 Subject: [PATCH] add text-labelling function --- .DS_Store | Bin 0 -> 8196 bytes app.py | 7 +++--- rawdata/test.txt | 1 + templates/text-labeling.html | 45 +++++++++++++++++++++++++++++++++++ workdir/.DS_Store | Bin 0 -> 6148 bytes workdir/db.sqlite | Bin 0 -> 12288 bytes workdir/input.txt | 1 + workdir/settings.json | 6 ++--- 8 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 .DS_Store create mode 100644 rawdata/test.txt create mode 100644 templates/text-labeling.html create mode 100644 workdir/.DS_Store create mode 100644 workdir/db.sqlite create mode 100644 workdir/input.txt diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..6c76527ccc6b35757e169d5d8267f5d928c8ddcf GIT binary patch literal 8196 zcmeHM!EVz)5S?v9;-o_4fRr44012U}N)$+t5K@{Zhe&`BMsNVsI&sukb-X5V2qgsh z0RI3;a7BCuN4|g$;R9f1cNNuk3q2sziXCZZ*1PYm?dOTN;{pI{&zu@S82}7y6pI_^ zjxd_1ma;W9QpCuR4-mjX&*Ou>$NMR?9?%MC1+)TM0j+>m;4~1?~qu5e0l2N=m(1{WNV+MzXVV}wY;+QJ7RE%WA88jxT7$udd5`#%Pj++YC zQZbTI(t)YsgQ+t!RiQ9(c3j^Sa9}MNwbu%01=0%8&m{{sR_+08ChB*ZyNT_}PhoIBz)@!o;wYz)$eR= zJ##LbGmL^!IA3^bjriOO?Qk}2+mpw1bk7b)ebs-!xwq=u{fF*wzEixo&Hd1J{ozEA zU1x}pCy!j;;qx}1`OZ|VW624_$Q${cVtKKsHyahRextFhn2Tn!S~0KH8_Q+hC|$1I z>g|pXUM^lOU%wY30aI@&xFC;L{sZ=M5W7upuVxMSI9Op)h%xVUln}<%HO?;30dw2%Ai#*)NhrI2LZH-u*}16TCM zc;w^bpCUVi7Z4`+Zxj3tL=FU#cvBbwCw7AMBf-ieW{6i8fG3h|m}H1leiuu(Ij%f` zeN0ch()ju!m4Aaib;)_1lC$|2k~1bsEEy;rB5W9`OHS|qB!o7tz!_9vU0!pU>i_QX z-~Z3xo#{)~3TOpRssPJ$tWF!zVpl(cMZ3I-Z5JCE;UXCY1zqe90X$y)!w~x>LW$E- UF_IBS(Da7@A%k{Wfq$yNF8~H5k^lez literal 0 HcmV?d00001 diff --git a/app.py b/app.py index 0445c00..689d0bd 100644 --- a/app.py +++ b/app.py @@ -54,7 +54,7 @@ def webpage(): # redirect with url query param so that user can navigate back later next_rec = service.get_next_unlabelled() if next_rec: - return redirect("/?url=%s" % (urllib.quote(next_rec['url']))) + return redirect("/?url=%s" % (urllib.parse.quote(next_rec['url']))) else: featured_content = "No Unlabelled Record Found." else: @@ -84,7 +84,7 @@ def update(): next_rec = service.get_next_unlabelled() target = "/" if next_rec: - target += "?url=%s" % (urllib.quote(next_rec['url'])) + target += "?url=%s" % (urllib.parse.quote(next_rec['url'])) return redirect(location=target) else: return abort(400, "Failed... No records updated") @@ -104,7 +104,7 @@ def get_next(url=None): next_rec = service.get_record(url) url = next_rec['url'] template_name = '%s.html' % service.settings['type'] - data_url = url if url.startswith('http') else "/proxy?url=%s" % urllib.quote(next_rec['url']) + data_url = url if url.startswith('http') else "/proxy?url=%s" % urllib.parse.quote(next_rec['url']) data = { 'data_url' : data_url, 'url': url, @@ -215,4 +215,5 @@ def __del__(self): host = '0.0.0.0' service = DbService(args['work_dir'], args['input']) print("Starting on %s %s/" % (host, args['port'])) + app.debug = True app.run(host=host, port=args['port']) diff --git a/rawdata/test.txt b/rawdata/test.txt new file mode 100644 index 0000000..339e02d --- /dev/null +++ b/rawdata/test.txt @@ -0,0 +1 @@ +test for labelling \ No newline at end of file diff --git a/templates/text-labeling.html b/templates/text-labeling.html new file mode 100644 index 0000000..90798ce --- /dev/null +++ b/templates/text-labeling.html @@ -0,0 +1,45 @@ + diff --git a/workdir/.DS_Store b/workdir/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..e077950eb1fa63929624fcc4bc9e355f992a3a5d GIT binary patch literal 6148 zcmeHKJx{|>3_L@JN(iYV;~SZfm|3E#9hmt8sDKctYKE3Q8$X+#KR~Sl0}BH>SN6T< z`0|5$_(x=GWavc2XH5(s_>;Z19XNuJAgl{yyQ{b26T=R^ZwfH+|~jO&;sh|Lqku5d_XhGt16Ce>=hu%t8Js;(;>5|a*#lX;&y*=jg{mq`+S&um`l491#Ej literal 0 HcmV?d00001 diff --git a/workdir/db.sqlite b/workdir/db.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..77fc725483436f1b2f61a4a4dba9128c1cd73276 GIT binary patch literal 12288 zcmeI%O;6h}7zc2>us0->T_Uv0_S`n4wn<=`1iLINfkkvJbnSstS2^CUcA0h{>!;H0q_tqh$H=P3rfk)9>wf)6S66gI<4- z(B|95(~XZlXKI?ux&B$$vwbFNQ!eM3`?4%@tvlO4cb@CEa_@%Of`9-7AOHafKmY;| zfB*y_009U<;1LAI{K>+9wH=JKtaLC|MR9p`F3QXEU{C5Frkn+FYA@~&$}$ghJ(JZh zrPcI%t5!iJF5EFcFgA72Hgj`olMOoB3ZtD?xYOGDKw-EWM!V7bHTz%O`^{`YKmY;| ffB*y_009U<00Izz00bcLe+hh9UHC5^A~Em}$WMsM literal 0 HcmV?d00001 diff --git a/workdir/input.txt b/workdir/input.txt new file mode 100644 index 0000000..0b3aeba --- /dev/null +++ b/workdir/input.txt @@ -0,0 +1 @@ +/Users/billyzhaoyh/Desktop/AIforGood/supervising-ui/rawdata/test.txt \ No newline at end of file diff --git a/workdir/settings.json b/workdir/settings.json index 33b4bb4..0a0365d 100644 --- a/workdir/settings.json +++ b/workdir/settings.json @@ -1,11 +1,9 @@ { - "type": "image-labeling", + "type": "text-labeling", "task": { "labels":[ "class1", - "class2", - "class3", - "class4" + "class2" ] } }