Example #1
0
def process(file_list):
    if not classify.CLASSIFIER:
        init()
    pred_list = classify.run(file_list, classify.CLASSIFIER, classify.LABEL_FILE)
    pred_dict = {}
    pred_dict["predictions"] = pred_list
    return pred_dict
Example #2
0
def process(file_list):
    if not classify.CLASSIFIER:
        init()
    pred_list = classify.run(file_list, classify.CLASSIFIER,
                             classify.LABEL_FILE)
    pred_dict = {}
    pred_dict['predictions'] = pred_list
    return pred_dict
Example #3
0
 def post(self):
     args = self.reqparse.parse_args()
     url = args['url']
     # Read the image and save it
     path = read_image_from_url(url)
     print "Image Downloaded to: " + path
     # Run the classifier on the image
     results = classify.run(path)
     # Remove the image after analyzing
     remove_image(path)
     return results
Example #4
0
def profile():
    if request.method == "POST":
        file = request.files['file']
        if file and allowed_file(file.filename):
            filename = secure_filename(file.filename)
            image_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
            file.save(image_path)
            data = run(image_path, cfg)
            os.remove(image_path)
            return render_template("display.html", data=data)
        return "did not work"
    return render_template("upload.html")
Example #5
0
def upload_file():
    if request.method == 'POST':

        file = request.files['image']

        if file.filename == '':
            print('No selected file')
            return redirect(request.url)

        if file and allowed_file(file.filename):
            filename = secure_filename(file.filename)
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
            return classify.run(
                os.path.join(app.config['UPLOAD_FOLDER'] + "/" + filename))
Example #6
0
def test_post():
    if request.method == 'POST':
        # print(request.get_json())
        rev = request.get_json()['Img']
        # print(rev)
        img_data = base64.b64decode(rev)
        with open('001.jpg', 'wb') as f:
            f.write(img_data)
        # result=   classify.run(image)
        # print(request.get_data())
        res = classify.run(image)
        return jsonify({'data': res})
    else:
        return 'error'
def run(inimage):
#resize image 
	basewidth = 1080
	img = PIL.Image.open(inimage)
	wpercent = (basewidth / float(img.size[0]))
	hsize = int((float(img.size[1]) * float(wpercent)))
	img = img.resize((basewidth, hsize), PIL.Image.ANTIALIAS)
	img.save('resized_image.jpg')

	#split image
	tiles = image_slicer.slice('resized_image.jpg',9)
	score=[0,0,0,0,0,0,0,0,0]

	#get least quality tile
	for tile in tiles:
		tile.image.save('tile.jpg')
		score[tile.number-1] = float(subprocess.check_output(['./brisque_cpp/brisquequality','-im','tile.jpg']))
	index=score.index(max(score))

	#get label of image
	classlabel=classify.run(inimage).split(' ', 1)[1]
	print classlabel

	#get classid of label
	searchfile = open("labelidmap.txt", "r")
	for line in searchfile:
		if classlabel in line: classid=int(line.split(':',1)[0])
	searchfile.close()
	print classid

	#perform deepdraw
	#tiles[index].image=deepdraw.run(tiles[index].image, classid)
	image=deepdraw.run(tiles[index].image,classid)
	tiles[index].image=PIL.Image.fromarray(image.astype('uint8'))
	#im.save('new.png')
	im=image_slicer.join(tiles)
	im.save('final.png')
	return True
	'''
	for tile in tiles:
		tile.image.show()
	'''
	''''
Example #8
0
#Does something, probably.    
                        
if cfg.plot == True:
    import plot as p
    if cfg.quick == True:
        p.run(cfg.name + "quick", quick = True)
    else:
        p.run(cfg.name)
        
#Classifies the data into a varying number of categories

if cfg.classify == True:
    import classify as c
    if cfg.quick == True:
        c.run(cfg.name + "quick", cfg.fit, quick = True)
    else:
        c.run(cfg.name, cfg.fit)

#Creates Histograms for each category identied by learning algorithm

if cfg.onedhistogram == True:
    import histogram as h
    if cfg.quick == True:
        h.run(cfg.name + "quick", int(cfg.groups), str(cfg.fit), quick = True)
    else:
        h.run(cfg.name, int(cfg.groups), str(cfg.fit))

end = time.time()
print time.asctime(time.localtime()), "Code Ended"