def classify_submit(request): global results global saved_url if request.method=="POST": saved_url=request.POST['saved_url'] results=classify(saved_url) return HttpResponseRedirect('/deeplearning/image_text/')
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/')
def classify_add_picture_by_url(request): global saved_url global results if request.method=="POST": saved_url=request.POST['original_image_url'] saved_path=download_img(saved_url) saved_path=quote(saved_path) img=Picture(original_image=saved_path) img.save() img=Picture.objects.order_by('-id')[0] saved_url=unquote(unquote(img.original_image.url)) print saved_url results=classify(saved_url) return HttpResponseRedirect('/deeplearning/image_text/')
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)