Ejemplo n.º 1
0
def classify_add_picture(request):
	global saved_url
	global results
	if request.method=="POST":
		form=ModelFormWithFileField(request.POST,request.FILES)
		if form.is_valid():
			form.save()
			img=Picture.objects.order_by('-id')[0]
			saved_url=img.original_image.url
			results=classify(saved_url)
			return HttpResponseRedirect('/deeplearning/image_text/')
Ejemplo n.º 2
0
def add_picture_android(request):
	global saved_url
	global results
	if request.method=="POST":
		form=ModelFormWithFileField(request.POST,request.FILES)
		if form.is_valid():
			form.save()
			img=Picture.objects.order_by('-id')[0]
			saved_url=img.original_image.url
			tmp=classify(saved_url)
			results=""
			for i in tmp:
			   results+=i
			   results+='\n'
			return HttpResponse(results)
Ejemplo n.º 3
0
def upload_file(request):
    documents = ModelFormWithFileField.objects.all()
    if request.method == 'POST':
        form = UploadFileForm(request.POST, request.FILES)
        if form.is_valid():
            newDoc = ModelFormWithFileField(upload = request.FILES['file1'])
            newDoc.save()
            # form.save()
            # template = loader.get_template('geServer2/list.html')
            # return HttpResponse(template.render(request))
    else:
        form = UploadFileForm()
    # Load documents for the list page

    # return render(request, 'geServer2/contact.html', {'form': form })
    return render(request,'geServer2/list.html', {'form': form ,'documents': documents})
Ejemplo n.º 4
0
def image_image_android(request):
	global saved_url
	global results
	if request.method=="POST":
		form=ModelFormWithFileField(request.POST,request.FILES)
		print 'upload:...'
		print request.FILES
		if form.is_valid():
			form.save()
			img=Picture.objects.order_by('-id')[0]
			print img
			saved_url=img.original_image.url
			print 'save: '+saved_url

			text = "image_image"
			results2 = text_image_f2(text)
			print results2
			image_data = open(results2,"rb").read()
			print type(image_data)
    			return HttpResponse(image_data,content_type="image/jpg")