diff --git a/README.md b/README.md index 380804f..e155304 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ This project has a web interface to label training data for machine learning task. As of now it can allow you to easily label images with one or many labels +Support both python 2 and python 3 # Requires @@ -25,12 +26,16 @@ Install them using pip { "type": "image-labeling", "task": { - "labels":[ - "class1", - "class2", - "class3", - "class4" - ] + "labels":[[ + "D1", + "D2", + "D3", + "D4", + "D5", + "D6" + ], ["Front", + "Side", + "Back"]] } } ``` @@ -66,7 +71,7 @@ Visit http://localhost:8080 on web browser ## Screenshots - + ## WARNING: diff --git a/app.py b/app.py index 0445c00..b9d5bed 100644 --- a/app.py +++ b/app.py @@ -24,6 +24,10 @@ import logging from datetime import datetime import urllib +try: + from urllib import quote # Python 2.X +except ImportError: + from urllib.parse import quote # Python 3+ from flask import Flask, render_template, request, abort, send_file, redirect, Response app = Flask(__name__) @@ -54,7 +58,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" % (quote(next_rec['url']))) else: featured_content = "No Unlabelled Record Found." else: @@ -84,7 +88,7 @@ def update(): next_rec = service.get_next_unlabelled() target = "/" if next_rec: - target += "?url=%s" % (urllib.quote(next_rec['url'])) + target += "?url=%s" % (quote(next_rec['url'])) return redirect(location=target) else: return abort(400, "Failed... No records updated") @@ -104,7 +108,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" % quote(next_rec['url']) data = { 'data_url' : data_url, 'url': url, diff --git a/screenshots/multilabel.jpg b/screenshots/multilabel.jpg new file mode 100644 index 0000000..5269afb Binary files /dev/null and b/screenshots/multilabel.jpg differ diff --git a/templates/image-labeling.html b/templates/image-labeling.html index 5954a80..8568e09 100644 --- a/templates/image-labeling.html +++ b/templates/image-labeling.html @@ -4,8 +4,11 @@