コード例 #1
0
def normalizeTraining(request):
    '''normalizes the images inside the training folders by the following:
	 resizing them to a size of 100x100, converting them to grayscale, and 
	 then applying an edge detection filter to make it easier for the
	 svm to pick out useable pixel featuers'''

    size = (100, 100)
    base_dir = './scikitbox/static/images/training/'
    pos_converts = tt.prepare_directory(base_dir + 'pos/', size)
    neg_converts = tt.prepare_directory(base_dir + 'neg/', size)
    return HttpResponse("successfully normalized %d pos, %d negs" %
                        (pos_converts, neg_converts))
コード例 #2
0
ファイル: views.py プロジェクト: mr-6/django-scikit-heroku
def normalizeTraining(request):
	'''normalizes the images inside the training folders by the following:
	 resizing them to a size of 100x100, converting them to grayscale, and 
	 then applying an edge detection filter to make it easier for the
	 svm to pick out useable pixel featuers'''

	size = (100,100)
	base_dir = './scikitbox/static/images/training/'
	pos_converts = tt.prepare_directory(base_dir + 'pos/',size)
	neg_converts = tt.prepare_directory(base_dir + 'neg/',size)
	return HttpResponse("successfully normalized %d pos, %d negs" % 
					(pos_converts,neg_converts))
コード例 #3
0
def uploadSingle(request):
    '''receives an uploaded image from user and save it to the
	test folder, aswell as normalizing it to a test_normalized folder'''
    if request.method == "POST":
        uploaded_image = request.FILES['upload']
        name = uploaded_image.name

        test_path = os.path.join(TEST_DIR, name)
        fil = open(test_path, "wb")
        data = uploaded_image.read()
        fil.write(data)
        fil.close()

        ntest_path = os.path.join(NTEST_DIR, name)
        norm_fil = open(ntest_path, "wb")
        norm_fil.write(data)
        norm_fil.close()
        tt.prepare_directory(NTEST_DIR, (100, 100))

        response = HttpResponse("file uploaded successfully")
        response.__setitem__("content-type", "text/text")
        return response
コード例 #4
0
ファイル: views.py プロジェクト: mr-6/django-scikit-heroku
def uploadSingle(request):
	'''receives an uploaded image from user and save it to the
	test folder, aswell as normalizing it to a test_normalized folder'''
	if request.method == "POST":
		uploaded_image = request.FILES['upload']
		name = uploaded_image.name
		
		test_path = os.path.join(TEST_DIR,name)
		fil = open(test_path,"wb")
		data = uploaded_image.read()
		fil.write(data)
		fil.close()

		ntest_path = os.path.join(NTEST_DIR,name)
		norm_fil = open(ntest_path,"wb")
		norm_fil.write(data)
		norm_fil.close()
		tt.prepare_directory(NTEST_DIR,(100,100))

		response = HttpResponse("file uploaded successfully")
		response.__setitem__("content-type","text/text")
		return response