def run(self): """ Algorithm execution """ # Run the algorithm stdout = open(self.work_dir + 'stdout.txt', 'w') try: run_time = time.time() self.run_algo(stdout=stdout) self.cfg['info']['run_time'] = time.time() - run_time except TimeoutError: return self.error(errcode='timeout') except RuntimeError: print "Run time error" return self.error(errcode='runtime') stdout.close() http.redir_303(self.base_url + 'result?key=%s' % self.key) # Archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("input_0_sel.png", info="selected subimage") ar.add_file("mosaiced.png", info="mosaiced image") ar.add_file("dmzhangwu.png", info="Zhang-Wu demosaiced image") ar.add_file("diffdmzhangwu.png", info="difference image for Zhang-Wu") ar.add_file("bilinear.png", info="bilinear demosaiced image") ar.add_file("diffbilinear.png", info="difference image for bilinear") ar.add_info({"pattern": self.cfg['param']['pattern']}) ar.save() return self.tmpl_out("run.html")
def run(self): """ algo execution """ self.list_commands = "" try: self.run_algo(self) except TimeoutError: return self.error(errcode='timeout') except RuntimeError: return self.error(errcode='runtime', errmsg="Something went wrong with the program.") except ValueError: return self.error(errcode='badparams', errmsg="The parameters given produce no contours,\ please change them.") http.redir_303(self.base_url + 'result?key=%s' % self.key) # archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("input_0.png", "original.png", info="uploaded") ar.add_file("algoLog.txt", info="algoLog.txt") ar.add_file("commands.txt", info="commands.txt") ar.add_file("outputATC.png", "outputATC.png", info="outputATC.png") ar.add_file("outputPolygon.png", "outputPolygon.png", info="outputPolygon.png") ar.add_info({"version": self.cfg['param']["version"]}) ar.save() return self.tmpl_out("run.html")
def run(self): """ Algorithm execution """ # Run the algorithm stdout = open(self.work_dir + "stdout.txt", "w") try: run_time = time.time() self.run_algo(stdout=stdout) self.cfg["info"]["run_time"] = time.time() - run_time except TimeoutError: return self.error(errcode="timeout") except RuntimeError: print "Run time error" return self.error(errcode="runtime") stdout.close() http.redir_303(self.base_url + "result?key=%s" % self.key) # Archive if self.cfg["meta"]["original"]: ar = self.make_archive() ar.add_file("input_0_sel.png", info="selected subimage") ar.add_file("mosaiced.png", info="mosaiced image") ar.add_file("dmzhangwu.png", info="Zhang-Wu demosaiced image") ar.add_file("diffdmzhangwu.png", info="difference image for Zhang-Wu") ar.add_file("bilinear.png", info="bilinear demosaiced image") ar.add_file("diffbilinear.png", info="difference image for bilinear") ar.add_info({"pattern": self.cfg["param"]["pattern"]}) ar.save() return self.tmpl_out("run.html")
def run(self): """ Algorithm execution """ # Run the algorithm stdout = open(self.work_dir + "stdout.txt", "w") try: run_time = time.time() self.run_algo(stdout=stdout) self.cfg["info"]["run_time"] = time.time() - run_time except TimeoutError: return self.error(errcode="timeout") except RuntimeError: print "Run time error" return self.error(errcode="runtime") stdout.close() http.redir_303(self.base_url + "result?key=%s" % self.key) # Archive if self.cfg["meta"]["original"]: ar = self.make_archive() ar.add_info({"sfactor": self.cfg["param"]["sfactor"]}) ar.add_file("input_0_sel.png", info="input image") ar.add_file("pan.png", info="pan image") ar.add_file("pansharpened.png", info="pansharpened image") ar.add_file("lowspectral.png", info="lowspectral image") ar.add_file("ihs.png", info="IHS image") ar.add_file("diffInputIHS.png", info="difference input-IHS") ar.add_file("diffInputPanS.png", info="difference input-pansharpened") ar.save() return self.tmpl_out("run.html")
def run(self): """ algorithm execution """ # read the parameters pattern = self.cfg['param']['pattern'] # run the algorithm stdout = open(self.work_dir + 'stdout.txt', 'w') try: run_time = time.time() self.run_algo(pattern, stdout=stdout) self.cfg['info']['run_time'] = time.time() - run_time except TimeoutError: return self.error(errcode='timeout') except RuntimeError: return self.error(errcode='runtime') stdout.close() http.redir_303(self.base_url + 'result?key=%s' % self.key) # archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("input_0.orig.png", info="uploaded image") ar.add_file("input_0.sel.png", info="selected subimage") ar.add_file("input_1.png", info="mosaicked image") ar.add_file("output_1.png", info="demosaicked image") ar.add_file("output_2.png", info="difference image") ar.add_info({"pattern": pattern}) ar.save() return self.tmpl_out("run.html")
def run(self): """ algorithm execution """ try: run_time = time.time() self.run_algo() self.cfg['info']['run_time'] = time.time() - run_time except TimeoutError: return self.error(errcode='timeout') except RuntimeError: return self.error(errcode='runtime') http.redir_303(self.base_url + 'result?key=%s' % self.key) # archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("input.png", info="input image") ar.add_file("input_cropped.png", info="input cropped (actual input)") ar.add_file("output.png", info="output image") try: fh = open(self.work_dir + 'input_selection.png') fh.close() ar.add_file("input_selection.png", info="input selected") ar.add_file("input_0.orig.png", info="uploaded image") except IOError: pass ar.add_info({"ratio": self.cfg['param']['ratio']}) ar.add_info({"npyr": self.cfg['param']['npyr']}) ar.save() return self.tmpl_out("run.html")
def run(self, **kwargs): """ algo execution """ print("ENTER run") print("kwargs = " + str(kwargs)) ## run the algorithm try: self.run_algo() except TimeoutError: return self.error(errcode='timeout') except RuntimeError: return self.error(errcode='runtime') http.redir_303(self.base_url + 'result?key=%s' % self.key) ## archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("a.png", "a.png", info="") ar.add_file("b.png", "b.png", info="") ar.add_file("stuff_phs.tiff", info="") ar.add_file("stuff_phs.png", info="") if (self.cfg['meta']['hastruth']): ar.add_file("t.tiff", info="") alist = {} for k in app.parconfig: if app.parconfig[k]['archived']: alist[k] = self.cfg['param'][k] #ar.add_file(".png", info="output") ar.add_info(alist) ar.save() return self.tmpl_out("run.html")
def run(self, **kwargs): """ algo execution """ print("ENTER run") print("kwargs = " + str(kwargs)) ## run the algorithm try: self.run_algo() except TimeoutError: return self.error(errcode='timeout') except RuntimeError: return self.error(errcode='runtime') http.redir_303(self.base_url + 'result?key=%s' % self.key) ## archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("a.png", "a.png", info="") ar.add_file("b.png", "b.png", info="") ar.add_file("stuff_tvl1.tiff", info="") ar.add_file("stuff_tvl1.png", info="") if (self.cfg['meta']['hastruth']): ar.add_file("t.tiff", info="") #ar.add_file(".png", info="output") ar.add_info({"lambda": self.cfg['param']['lambda'], "nscales": self.cfg['param']['nscales']}) ar.save() return self.tmpl_out("run.html")
def run(self): """ Run the algorithm. """ try: run_time = time.time() self.run_algo() self.cfg['info']['run_time'] = time.time() - run_time self.cfg.save() except cherrypy.TimeoutError: return self.error(errcode='timeout') except RuntimeError: return self.error(errcode='runtime') # archive ar = self.make_archive() ar.add_file('params.json', info='input parameters and point coordinates') ar.add_file('gcp.txt', info='list of (row, col, alt, lon, lat)' ' correspondences actually used (ie after' ' noise addition) to estimate the attitudes') ar.add_file('stdout.txt', info='algo output') ar.add_file('points.png', info='input points') ar.add_file('attitude_residuals.png', info='attitude errors') ar.add_file('attitude_estimated_vs_measured_vs_truth.png', info='attitudes (estimated, measured and true)') ar.add_info({"nb points" : int(self.cfg['param']['npts'])}) ar.add_info({"sigma" : [self.cfg['param']['sigma_pixels'], self.cfg['param']['sigma_meters']]}) ar.save() http.redir_303(self.base_url + 'result?key=%s' % self.key) return self.tmpl_out("run.html")
def run(self): """ algorithm execution """ # read the parameters sigma = self.cfg['param']['sigma'] # run the algorithm stdout = open(self.work_dir + 'stdout.txt', 'w') try: run_time = time.time() self.run_algo(sigma, stdout=stdout, timeout=self.timeout) self.cfg['info']['run_time'] = time.time() - run_time except TimeoutError: return self.error(errcode='timeout') except RuntimeError: print "Run time error" return self.error(errcode='runtime') stdout.close() http.redir_303(self.base_url + 'result?key=%s' % self.key) # archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("input_0.orig.png", info="uploaded image") ar.add_file("input_0.sel.png", info="selected subimage") ar.add_file("input_1.png", info="noisy image") ar.add_file("output_1.png", info="denoised image") ar.add_file("output_2.png", info="difference image") ar.add_info({"sigma": sigma}) ar.save() return self.tmpl_out("run.html")
def run(self): """ algorithm execution """ stdout = open(self.work_dir + "stdout.txt", "w") try: run_time = time.time() self.run_algo(timeout=self.timeout, stdout=stdout) self.cfg["info"]["run_time"] = time.time() - run_time except TimeoutError: return self.error(errcode="timeout", errmsg="Try again with simpler images.") except RuntimeError: return self.error(errcode="runtime") http.redir_303(self.base_url + "result?key=%s" % self.key) # archive if self.cfg["meta"]["original"]: ar = self.make_archive() ar.add_file("input_0.orig.png", info="first uploaded image") ar.add_file("input_1.orig.png", info="second uploaded image") ar.add_file("input_0.png", info="first uploaded image") ar.add_file("input_1.png", info="second uploaded image") ar.add_file("output_orsa_line_surf.png", info="SURF matches(orsa)") ar.add_file("output_line_surf.png", info="SURF matches") ar.add_file("output_descriptor_surf.png", info="SURF descriptors") ar.add_file("output_orsa_line_sift.png", info="SIFT matches(orsa)") ar.add_file("output_line_sift.png", info="SIFT matches") ar.add_file("output_descriptor_sift.png", info="SIFT descriptors") ar.add_file("match_SURF.txt", compress=True) ar.save() return self.tmpl_out("run.html")
def run(self): """ Algorithm execution """ try: run_time = time.time() self.run_algo(stdout=open(self.work_dir + 'stdout.txt', 'w')) self.cfg['info']['run_time'] = time.time() - run_time self.cfg.save() except TimeoutError: return self.error(errcode='timeout') except RuntimeError: return self.error(errcode='runtime') http.redir_303(self.base_url + 'result?key=%s' % self.key) # Archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file('input_0.png', info='Input Image') ar.add_file('output_0.png', info='Output Image') ar.add_file('line_primitives.dat', info='Selected lines') ar.add_file('output_0.dat', info='Output data') ar.add_info({'x_center': self.cfg['param']['x_center']}) ar.add_info({'y_center': self.cfg['param']['y_center']}) ar.add_info({'center_optimization': \ self.cfg['param']['optimized']}) ar.save() return self.tmpl_out("run.html")
def run(self, **kwargs): """ algo execution """ print("ENTER run") print("kwargs = " + str(kwargs)) alpha = self.cfg['param']['alpha'] rho = self.cfg['param']['rho'] sigma = self.cfg['param']['sigma'] numit = self.cfg['param']['numit'] ## run the algorithm try: self.run_algo(alpha,rho,sigma,numit) except TimeoutError: return self.error(errcode='timeout') except RuntimeError: return self.error(errcode='runtime') http.redir_303(self.base_url + 'result?key=%s' % self.key) ## archive ##if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("a.png", info="input 1") ar.add_file("b.png", info="input 2") ar.add_file("t.png", info="true flow") ar.add_file("stuff_clg.png", info="CLG calculated flow") ar.add_info({"alpha": alpha}) ar.add_info({"rho": rho}) ar.add_info({"sigma": sigma}) ar.add_info({"numit": numit}) ar.save() return self.tmpl_out("run.html")
def run(self): """ algo execution """ # read the parameters a = self.cfg['param']['a'] b = self.cfg['param']['b'] # run the algorithm try: self.run_algo(a, b) except TimeoutError: return self.error(errcode='timeout') except RuntimeError: return self.error(errcode='runtime') http.redir_303(self.base_url + 'result?key=%s' % self.key) # archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("input_0.orig.png", "original.png", info="uploaded") ar.add_file("input_0.png", "input.png", info="input") ar.add_file("output.png", info="output") ar.add_info({"a": a, "b": b}) ar.save() return self.tmpl_out("run.html")
def run(self): """ algorithm execution """ stdout = open(self.work_dir + 'stdout.txt', 'w') try: run_time = time.time() self.run_algo(timeout=self.timeout, stdout=stdout) self.cfg['info']['run_time'] = time.time() - run_time except TimeoutError: return self.error(errcode='timeout', errmsg="Try again with simpler images.") except RuntimeError: return self.error(errcode='runtime') http.redir_303(self.base_url + 'result?key=%s' % self.key) # archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_info({'orsa' : str(self.cfg['param']['orsa'])}) ar.add_file("input_0.png", info="first uploaded image") ar.add_file("input_1.png", info="second uploaded image") ar.add_file("matches.png", info="SURF matches") ar.add_file("descriptor.png", info="SURF descriptors") ar.add_file("matches.txt", compress=True) ar.add_file("k1.txt", compress=True) ar.add_file("k2.txt", compress=True) ar.save() return self.tmpl_out("run.html")
def run(self): """ Algorithm execution """ # Run the algorithm stdout = open(self.work_dir + 'stdout.txt', 'w') try: run_time = time.time() self.run_algo(stdout=stdout) self.cfg['info']['run_time'] = time.time() - run_time self.cfg.save() except TimeoutError: return self.error(errcode='timeout') except RuntimeError: print "Run time error" return self.error(errcode='runtime') stdout.close() http.redir_303(self.base_url + 'result?key=%s' % self.key) # Archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("input_0_sel.png", info="selected subimage") for algo in self.cfg['param']['algo'].split(): ar.add_file('output-' + algo + '.png', info='output ' + algo) ar.add_info({'sigma': self.cfg['param']['sigma']}) ar.add_info({'algorithm': self.cfg['param']['algo']}) ar.save() return self.tmpl_out("run.html")
def run(self, **kwargs): """ algo execution """ print("ENTER run") print("kwargs = " + str(kwargs)) ## run the algorithm try: self.run_algo() except TimeoutError: return self.error(errcode='timeout') except RuntimeError: return self.error(errcode='runtime') http.redir_303(self.base_url + 'result?key=%s' % self.key) ## archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("i0000.png", "i0000.png", info="first frame") ar.add_file("o_iavg.png", "o_iavg.png", info="input average") ar.add_file("o_cmed.png", "o_cmed.png", info="output result") ar.add_file("vidfile", "vidfile", info="uploaded video") nframes = self.cfg['param']['nframes'] nseeds = self.cfg['param']['nseeds'] ar.add_info({"nframes": nframes, "nseeds": nseeds}) ar.save() return self.tmpl_out("run.html")
def run(self): """ Algorithm execution """ # Run the algorithm stdout = open(self.work_dir + 'stdout.txt', 'w') try: run_time = time.time() self.run_algo(stdout=stdout) self.cfg['info']['run_time'] = time.time() - run_time except TimeoutError: return self.error(errcode='timeout') except RuntimeError: print "Run time error" return self.error(errcode='runtime') stdout.close() http.redir_303(self.base_url + 'result?key=%s' % self.key) # Archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_info({'action': self.cfg['param']['action']}) ar.add_file('input_0_sel.png', info='exact image') ar.add_file('detectedraw.png', info='raw detection') ar.add_file('ppSkin.png', info='skin color detection') ar.add_file('ppRobust.png', info='robustness detection') ar.add_file('ppBoth.png', info='most refined detection') ar.save() return self.tmpl_out('run.html')
def run(self): """ Algorithm execution """ try: self.run_algo(stdout=open(self.work_dir + 'stdout.txt', 'w')) except TimeoutError: return self.error(errcode='timeout') except RuntimeError: return self.error(errcode='runtime') http.redir_303(self.base_url + 'result?key=%s' % self.key) # Archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file('input_0.png', 'input.png') ar.add_file('input_0_sel.png', info='Selected subimage') ar.add_file('interpolated.png', info='Interpolation') ar.add_file('contour.png', info='Estimated contours') ar.add_info({'action': self.cfg['param']['action'], 'scalefactor': self.cfg['param']['scalefactor'], 'psfsigma': self.cfg['param']['psfsigma']}) if self.cfg['param']['action'] != self.default_param['action']: ar.add_file('coarsened.png', info='Coarsened image') ar.add_file('coarsened_zoom.png') ar.add_file('difference.png', info='Difference image') else: ar.add_file('input_0_zoom.png') ar.save() return self.tmpl_out('run.html')
def run(self): """ algo execution """ self.list_commands = "" try: self.run_algo(self) except TimeoutError: return self.error(errcode='timeout') except RuntimeError: return self.error(errcode='runtime', errmsg="Something went wrong with the program.") except ValueError: return self.error(errcode='badparams', errmsg="The parameters given produce no contours,\ please change them.") http.redir_303(self.base_url + 'result?key=%s' % self.key) # archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("input_0.png", "input_0.png", info="Input image") ar.add_file("algoLog.txt", info="algoLog.txt") ar.add_file("commands.txt", info="commands.txt") ar.add_file("Result.png", "Result.png", info="Pith detection result") #ar.add_info({"version": self.cfg['param']["version"]}) ar.save() return self.tmpl_out("run.html")
def run(self): """ algo execution """ # read the parameters th = self.cfg["param"]["th"] # run the algorithm try: self.run_algo(th) except TimeoutError: return self.error(errcode="timeout") except RuntimeError: return self.error(errcode="runtime") http.redir_303(self.base_url + "result?key=%s" % self.key) # archive if self.cfg["meta"]["original"]: ar = self.make_archive() ar.add_file("input_0.orig.png", "original.png", info="uploaded") ar.add_file("input_0.png", info="input") ar.add_file("output.png", info="output") ar.add_info({"th": th}) ar.save() return self.tmpl_out("run.html")
def run(self): """ Algorithm execution """ # Run the algorithm stdout = open(self.work_dir + 'stdout.txt', 'w') try: run_time = time.time() self.run_algo(stdout=stdout) self.cfg['info']['run_time'] = time.time() - run_time except TimeoutError: return self.error(errcode='timeout') except RuntimeError: print "Run time error" return self.error(errcode='runtime') stdout.close() http.redir_303(self.base_url + 'result?key=%s' % self.key) # Archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("input_0.png", info="original image") ar.add_file("composite.png", info="input") ar.add_file("inpainted.png", info="inpainting result") ar.add_info({"lambda": '%.1e' % float(self.cfg['param']['lambda'])}) ar.save() return self.tmpl_out("run.html")
def run(self): """ algorithm execution """ # read the parameters pattern = self.cfg['param']['pattern'] s1 = self.cfg['param']['s1'] s2 = self.cfg['param']['s2'] # run the algorithm stdout = open(self.work_dir + 'stdout.txt', 'w') try: run_time = time.time() self.run_algo(s1, s2, pattern, stdout=stdout, timeout=self.timeout) self.cfg['info']['run_time'] = time.time() - run_time self.cfg.save() except TimeoutError: return self.error(errcode='timeout') except RuntimeError: return self.error(errcode='runtime') stdout.close() http.redir_303(self.base_url + 'result?key=%s' % self.key) # archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("input_0.orig.png", info="uploaded image") ar.add_file("input_0.sel.png", info="selected subimage") ar.add_file("input_0.sel_normalized.png", info="selected \ subimage after normalization (simplest color balance)") ar.add_file("output.png", info="processed image") ar.save() return self.tmpl_out("run.html")
def run(self): """ algorithm execution """ stdout = open(self.work_dir + 'stdout.txt', 'w') try: run_time = time.time() self.run_algo(timeout=self.timeout, stdout=stdout) self.cfg['info']['run_time'] = time.time() - run_time except TimeoutError: return self.error(errcode='timeout', errmsg="Try again with simpler images.") except RuntimeError: return self.error(errcode='runtime') http.redir_303(self.base_url + 'result?key=%s' % self.key) # archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("input_0.orig.png", info="first uploaded image") ar.add_file("input_1.orig.png", info="second uploaded image") ar.add_file("input_0.png", info="first input image") ar.add_file("input_1.png", info="second input image") ar.add_file("output_SIFT_V.png", info="SIFT matches") ar.add_file("output_ASIFT_V.png", info="ASIFT matches") ar.add_file("match_ASIFT.txt", compress=True) ar.save() return self.tmpl_out("run.html")
def run(self): """ Algorithm execution """ # Run the algorithm stdout = open(self.work_dir + 'stdout.txt', 'w') try: run_time = time.time() self.run_algo(stdout=stdout) self.cfg['info']['run_time'] = time.time() - run_time except TimeoutError: return self.error(errcode='timeout') except RuntimeError: print "Run time error" return self.error(errcode='runtime') stdout.close() http.redir_303(self.base_url + 'result?key=%s' % self.key) # Archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("input_0_sel.png", info="selected subimage") ar.add_file("evolution.gif", info="evolution") ar.add_file("segmentation.png", info="final segmentation") ar.add_info({"mu": self.cfg['param']['mu']}) ar.save() return self.tmpl_out("run.html")
def params(self, action=None, newrun=False, msg=None, \ motion_model="Gaussian (truncated at 4*std-dev)", s1="0.25", s2="1", \ s3="52", s4="2"): """ configure the algo execution """ if newrun: self.clone_input() if action == 'run': try: self.cfg['param'] = {'motion_model' : motion_model, 's1' : float(s1), 's2' : float(s2), 's3' : float(s3), 's4' : float(s4) } self.cfg.save() http.redir_303(self.base_url + "wait?key=%s" % self.key) except ValueError: return self.error(errcode='badparams', errmsg="Bad parameters!") if motion_model == 'Trimodal: \ rho(v)= rho_0*delta_0(v)+(1/2)*(1-rho_0)*delta_s(v)+(1/2)*(1-rho_0)*\ delta_{-s}(v)': return self.tmpl_out("params_h.html", msg=msg , motion_model=motion_model, s1=s1, s2=s2, s3=s3, s4=s4) if motion_model == 'Uniform over [-s,s]': return self.tmpl_out("params_u.html", msg=msg , motion_model=motion_model, s1=s1, s2=s2, s3=s3, s4=s4) return self.tmpl_out("params_g.html", msg=msg , motion_model=motion_model, s1=s1, s2=s2, s3=s3, s4=s4)
def run(self): """ Algorithm execution """ # Run the algorithm stdout = open(self.work_dir + 'stdout.txt', 'w') self.list_commands = "" try: run_time = time.time() self.run_algo(stdout=stdout) self.cfg['info']['run_time'] = time.time() - run_time except TimeoutError: return self.error(errcode='timeout') except RuntimeError: print "Run time error" return self.error(errcode='runtime') stdout.close() http.redir_303(self.base_url + 'result?key=%s' % self.key) # Archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("input_0.png", info="original image") ar.add_file("mask.png", info="mask image") ar.add_file("composite.png", info="input") ar.add_file("result.png", info="result result") ar.add_file("commands.txt", info="commands") ar.add_info({"alpha": float(self.cfg['param']['lambda'])}) ar.add_info({"negate image": self.cfg['param']['negate']}) ar.save() return self.tmpl_out("run.html")
def run(self, **kwargs): """ algo execution """ ## run the algorithm try: self.run_algo() except TimeoutError: return self.error(errcode='timeout') except RuntimeError: return self.error(errcode='runtime') http.redir_303(self.base_url + 'result?key=%s' % self.key) ## archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("a.png", "a.png", info="") ar.add_file("b.png", "b.png", info="") ar.add_file("stuff_tvl1.tiff", info="") ar.add_file("stuff_tvl1.png", info="") if (self.cfg['meta']['hastruth']): ar.add_file("t.tiff", info="") #ar.add_file(".png", info="output") ar.add_info({ "lambda": self.cfg['param']['lambda'], "nscales": self.cfg['param']['nscales'] }) ar.save() return self.tmpl_out("run.html")
def run(self): """ algorithm execution """ # read the parameters t = self.cfg['param']['t'] # run the algorithm stdout = open(self.work_dir + 'stdout.txt', 'w') try: run_time = time.time() self.run_algo(t, stdout=stdout, timeout=self.timeout) self.cfg['info']['run_time'] = time.time() - run_time except TimeoutError: return self.error(errcode='timeout') except RuntimeError: return self.error(errcode='runtime') http.redir_303(self.base_url + 'result?key=%s' % self.key) # archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("input_0.orig.png", info="uploaded image") ar.add_file("input_1.png", info="rescaled image") ar.add_file("output_1.png", info="result image") ar.add_info({"t": t}) ar.save() return self.tmpl_out("run.html")
def run(self): """ algorithm execution """ # read the parameters r = self.cfg['param']['r'] rmax = self.cfg['param']['rmax'] # run the algorithm stdout = open(self.work_dir + 'stdout.txt', 'w') try: run_time = time.time() self.run_algo(r, stdout=stdout, timeout=self.timeout) self.cfg['info']['run_time'] = time.time() - run_time except TimeoutError: return self.error(errcode='timeout') except RuntimeError: print "Run time error" return self.error(errcode='runtime') http.redir_303(self.base_url + 'result?key=%s' % self.key) # archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("input_0.orig.png", info="uploaded image") if (os.path.isfile(self.work_dir + 'input_0s.png') == True) : ar.add_file("input_0s.png", info="sub-image selection") ar.add_file("input_0.sel.png", info="processed image") ar.add_file("output_1.png", info="result image 1 (RGB)") ar.add_file("output_2.png", info="result image 2 (I)") ar.add_info({"r": r}) ar.add_info({"rmax": rmax}) ar.save() return self.tmpl_out("run.html")
def run(self, **kwargs): """ algo execution """ print("ENTER run") print("kwargs = " + str(kwargs)) ## run the algorithm try: self.run_algo() except TimeoutError: return self.error(errcode='timeout') except RuntimeError: return self.error(errcode='runtime') http.redir_303(self.base_url + 'result?key=%s' % self.key) ## archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("a.png", "a.png", info="") ar.add_file("b.png", "b.png", info="") ar.add_file("stuff_rof.tiff", info="") ar.add_file("stuff_rof.png", info="") if (self.cfg['meta']['hastruth']): ar.add_file("t.tiff", info="") ar.add_info({ "alpha": self.cfg['param']['alpha'], "gamma": self.cfg['param']['gamma'] }) ar.save() return self.tmpl_out("run.html")
def run(self): """ algorithm execution """ stdout = open(self.work_dir + 'stdout.txt', 'w') try: run_time = time.time() self.run_algo(stdout=stdout) self.cfg['info']['run_time'] = time.time() - run_time except TimeoutError: return self.error(errcode='timeout') except RuntimeError: return self.error(errcode='runtime') stdout.close(); http.redir_303(self.base_url + 'result?key=%s' % self.key) # archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("input_0.orig.png", info="uploaded image") ar.add_file("input_0.png", info="full-size") if (os.path.isfile(self.work_dir + 'input_0s.png') == True) : ar.add_file("input_0s.png", info="sub-image selection") ar.add_file("input.png", info="input image") ar.add_file("output_2.png", info="output image") ar.save() return self.tmpl_out("run.html")
def run(self): """ Algorithm execution """ # Run the algorithm stdout = open(self.work_dir + 'stdout.txt', 'w') self.list_commands = "" self.sizeSeeds = self.getSeedsSize() try: run_time = time.time() self.run_algo(stdout=stdout) self.cfg['info']['run_time'] = time.time() - run_time except TimeoutError: return self.error(errcode='timeout') except RuntimeError: print "Run time error" return self.error(errcode='runtime') stdout.close() http.redir_303(self.base_url + 'result?key=%s' % self.key) # Archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("input_0.png", info="original image") ar.add_file("resultLines.png", info="result lines") # ar.add_file("commands.txt", info="commands") ar.add_info({"width": int(self.cfg['param']['width'])}) ar.add_info({"min size": int(self.cfg['param']['minsize'])}) ar.add_info({"version": self.cfg['param']["version"]}) ar.save() return self.tmpl_out("run.html")
def run(self): """ algorithm execution """ # read the parameters sigma = self.cfg['param']['sigma'] # run the algorithm try: run_time = time.time() self.run_algo(sigma) self.cfg['info']['run_time'] = time.time() - run_time self.cfg.save() except TimeoutError: return self.error(errcode='timeout') except RuntimeError: print "Run time error" return self.error(errcode='runtime') http.redir_303(self.base_url + 'result?key=%s' % self.key) # archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("input_0.orig.png", info="uploaded image") ar.add_file("input_0.sel.png", info="selected subimage") ar.add_file("noisy.png", info="noisy image") ar.add_file("denoised.png", info="denoised image") ar.add_file("diff.png", info="difference image") ar.add_info({"sigma": sigma}) ar.save() return self.tmpl_out("run.html")
def run(self): """ algorithm execution """ # run the algorithm stdout = open(self.work_dir + 'stdout.txt', 'w') try: run_time = time.time() self.run_algo(stdout=stdout, timeout=self.timeout) self.cfg['info']['run_time'] = time.time() - run_time except TimeoutError: return self.error(errcode='timeout') except RuntimeError: return self.error(errcode='runtime') http.redir_303(self.base_url + 'result?key=%s' % self.key) # archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_info({"low_scale": self.cfg['param']['low_scale'], "medium_scale": self.cfg['param']['medium_scale'], "high_scale": self.cfg['param']['high_scale'], "prc_left": self.cfg['param']['prc_left'], "prc_right": self.cfg['param']['prc_right']}) ar.add_file("input_0.orig.png", info="uploaded image") ar.add_file("input_0.png", info="original image") ar.add_file("input_0_sel.png", info="selected subimage") ar.add_file("output_I.png", info="multiscale retinex on I channel") if not self.cfg['param']['isgray']: ar.add_file("output_RGB.png", \ info="multiscale retinex on R, G and B channels") ar.save() return self.tmpl_out("run.html")
def run(self, **kwargs): """ algo execution """ #print("ENTER run") #print("kwargs = " + str(kwargs)) ## run the algorithm try: self.run_algo() except TimeoutError: return self.error(errcode='timeout') except RuntimeError: return self.error(errcode='runtime') http.redir_303(self.base_url + 'result?key=%s' % self.key) ## archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("i0000.png", "i0000.png", info="first frame") ar.add_file("o_iavg.png", "o_iavg.png", info="input average") ar.add_file("o_cmed.png", "o_cmed.png", info="output result") ar.add_file("vidfile", "vidfile", info="uploaded video") nframes = self.cfg['param']['nframes'] nseeds = self.cfg['param']['nseeds'] ar.add_info({"nframes": nframes, "nseeds": nseeds}) ar.save() return self.tmpl_out("run.html")
def run(self): """ algo execution """ # read the parameters # MISC inv = self.cfg['param']['inv'] # FDED th_fded = self.cfg['param']['th_fded'] # HARALICK rho = self.cfg['param']['rho'] # MARR-HILDRETH GAUSSIAN sigma = self.cfg['param']['sigma'] n = self.cfg['param']['n'] tzc = self.cfg['param']['tzc'] # MARR-HILDRETH LOG sigma2 = self.cfg['param']['sigma2'] n2 = self.cfg['param']['n2'] tzc2 = self.cfg['param']['tzc2'] # run the algorithm try: run_time = time.time() self.run_algo(th_fded, rho, sigma, n, tzc, sigma2, n2, tzc2, inv) self.cfg['info']['run_time'] = time.time() - run_time self.cfg.save() except TimeoutError: return self.error(errcode='timeout') except RuntimeError: return self.error(errcode='runtime') http.redir_303(self.base_url + 'result?key=%s' % self.key) # archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("input_0.png", info="input image") ar.add_file("input_0_selection.png", info="cropped input image") ar.add_file("out_roberts.png", info="output image of Roberts algorithm") ar.add_file("out_prewitt.png", info="output image of Prewitt algorithm") ar.add_file("out_sobel.png", info="output image of Sobel algorithm") ar.add_file("out_mh.png", info="output image of Marr-Hildreth algorithm (Gaussian kernel)") ar.add_file("out_mhl.png", info="output image of Marr-Hildreth algorithm (LoG kernel)") ar.add_file("out_haralick.png", info="output image of Haralick algorithm") ar.add_info({"th_fded": th_fded}) ar.add_info({"rho": rho}) ar.add_info({"sigma": sigma}) ar.add_info({"n": n}) ar.add_info({"tzc": tzc}) ar.add_info({"sigma2": sigma2}) ar.add_info({"n2": n2}) ar.add_info({"tzc2": tzc2}) ar.save() return self.tmpl_out("run.html")
def run(self): """ algo execution """ self.list_commands = "" # read the parameters t = self.cfg['param']['tmax'] m = self.cfg['param']['m'] autothreshold = self.cfg['param']['autothreshold'] # run the algorithm try: self.run_algo({'t':t, 'm':m, 'autothreshold':autothreshold}) except TimeoutError: return self.error(errcode='timeout') except RuntimeError: return self.error(errcode='runtime') except ValueError: return self.error(errcode='badparams', errmsg="The parameters given produce no contours,\ please change them.") http.redir_303(self.base_url + 'result?key=%s' % self.key) # archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("input_0.png", "original.png", info="uploaded") ar.add_file("input_0_selection.png","selection.png") ar.add_file("resuWhiteBG.png", info="output") ar.add_file("resuBG.png", info="output with source image") ar.add_file("noiseLevels.txt", info="noise levels") ar.add_file("inputContourFC.txt", info="polygon input") ar.add_file("commands.txt", info="commands") ar.add_file("resuWhiteBG.eps", info="result in eps format with \ white background") ar.add_file("resuBG.eps", info="result in eps format with source\ image") ar.add_info({"threshold auto": autothreshold}) ar.add_info({"threshold tmax": self.cfg['param']['tmax']}) ar.add_info({"contour min size m": m}) try: version_file = open(self.work_dir + "version.txt", "w") p = self.run_proc(["meaningfulScaleEstim", "-version"], \ stdout=version_file, \ env={'LD_LIBRARY_PATH' : self.bin_dir}) self.wait_proc(p) version_file.close() version_file = open(self.work_dir + "version.txt", "r") version_info = version_file.readline() version_file.close() except RuntimeError: version_info = "unknown" ar.add_info({"meaningfulScaleEstim version " : version_info}) ar.add_info({"#contours" : self.cfg['info']['num_contours']}) ar.add_info({"run time (s)" : self.cfg['info']['run_time']}) ar.save() return self.tmpl_out("run.html")
def run(self): """ algorithm execution """ # read the parameters sigma = self.cfg['param']['sigma'] computebias = self.cfg['param']['computebias'] tau2dhard = self.cfg['param']['tau2dhard'] tau2dwien = self.cfg['param']['tau2dwien'] usesdhard = self.cfg['param']['usesdhard'] usesdwien = self.cfg['param']['usesdwien'] colorspace = self.cfg['param']['colorspace'] # run the algorithm try: run_time = time.time() self.run_algo(sigma, computebias, \ tau2dhard, tau2dwien, \ usesdhard, usesdwien, \ colorspace) self.cfg['info']['run_time'] = time.time() - run_time self.cfg.save() except TimeoutError: return self.error(errcode='timeout') except RuntimeError: print "Run time error" return self.error(errcode='runtime') http.redir_303(self.base_url + 'result?key=%s' % self.key) # archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("input_0.orig.png", info="uploaded image") ar.add_file("input_0.sel.png", info="selected subimage") ar.add_file("noisy.png", info="noisy image") ar.add_file("denoised.png", info="denoised image") ar.add_file("diff.png", info="difference image") try: test = str(computebias) computebiasParam = 1 if test != 'None' else 0 except StandardError: computebiasParam = 0 # if computebiasParam == 1: ar.add_file("bias.png", info="bias image") ar.add_file("diff_bias.png", info="difference bias image") ar.add_info({"sigma": sigma}) ar.add_info({"computebias": computebias}) ar.add_info({"tau2dhard": tau2dhard}) ar.add_info({"tau2dwien": tau2dwien}) ar.add_info({"usesdhard": usesdhard}) ar.add_info({"usesdwien": usesdwien}) ar.add_info({"colorspace": colorspace}) ar.save() return self.tmpl_out("run.html")
def run(self): ##, **kwargs): """ algorithm execution """ stdout = open(self.work_dir + 'stdout.txt', 'w') try: run_time = time.time() self.run_algo(stdout=stdout, timeout=self.timeout) self.cfg['info']['run_time'] = time.time() - run_time self.cfg.save() except TimeoutError: return self.error(errcode='timeout', errmsg="Try again with simpler images.") except NoMatchError: http.redir_303(self.base_url + 'result?key=%s&error_nomatch=1' % \ self.key) except RuntimeError: return self.error(errcode='runtime') stdout.close() http.redir_303(self.base_url + 'result?key=%s' % self.key) # archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_info({ 'high_threshold_canny': self.cfg['param']['high_threshold_canny'] }) ar.add_info({ 'initial_distortion_parameter': self.cfg['param']['initial_distortion_parameter'] }) ar.add_info({ 'final_distortion_parameter': self.cfg['param']['final_distortion_parameter'] }) ar.add_info({ 'distance_point_line_max_hough': self.cfg['param']['distance_point_line_max_hough'] }) ar.add_info({ 'angle_point_orientation_max_difference': self.cfg['param']['angle_point_orientation_max_difference'] }) ar.add_file("input_0.png", "input_0.png", info="Input") ar.add_file("output_canny.png", "output_canny.png", info="Canny") ar.add_file("output_hough.png", "output_hough.png", info="Hough") ar.add_file("output_corrected_image.png", "output_corrected_image.png", info="Output corrected") ar.add_file("primitives.txt", "primitives.txt", info="Primitives") ar.add_info({"run time": self.cfg['info']['run_time']}) ar.save() return self.tmpl_out("run.html")
def run(self): """ algo execution """ self.list_commands = "" # read the parameters t = self.cfg['param']['tmax'] m = self.cfg['param']['m'] autothreshold = self.cfg['param']['autothreshold'] # run the algorithm try: self.run_algo({'t': t, 'm': m, 'autothreshold': autothreshold}) except TimeoutError: return self.error(errcode='timeout') except RuntimeError: return self.error(errcode='runtime') except ValueError: return self.error( errcode='badparams', errmsg="The parameters given produce no contours,\ please change them.") http.redir_303(self.base_url + 'result?key=%s' % self.key) # archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("input_0.png", "original.png", info="uploaded") ar.add_file("input_0_selection.png", "selection.png") ar.add_file("resu.png", info="output") ar.add_file("noiseLevels.txt", info="noise levels") ar.add_file("inputContourFC.txt", info="polygon input") ar.add_file("commands.txt", info="commands") ar.add_file("resu.eps", info="result in eps format") ar.add_info({"threshold auto": autothreshold}) ar.add_info({"threshold tmax": self.cfg['param']['tmax']}) ar.add_info({"contour min size m": m}) try: version_file = open(self.work_dir + "version.txt", "w") p = self.run_proc(["meaningfulScaleEstim", "-version"], \ stdout=version_file, \ env={'LD_LIBRARY_PATH' : self.bin_dir}) self.wait_proc(p) version_file.close() version_file = open(self.work_dir + "version.txt", "r") version_info = version_file.readline() version_file.close() except Exception: version_info = "unknown" ar.add_info({"meaningfulScaleEstim version ": version_info}) ar.add_info({"#contours": self.cfg['info']['num_contours']}) ar.add_info({"run time (s)": self.cfg['info']['run_time']}) ar.save() return self.tmpl_out("run.html")
def run(self): """ algo execution """ # read the parameters s = self.cfg['param']['s'] k = self.cfg['param']['k'] t = self.cfg['param']['t'] # save standard output stdout = open(self.work_dir + 'stdout.txt', 'w') # run the algorithm try: run_time = time.time() self.run_algo(s, k, t, stdout=stdout) self.cfg['info']['run_time'] = time.time() - run_time self.cfg.save() except TimeoutError: return self.error(errcode='timeout') except RuntimeError: stdout_text = open(self.work_dir + 'stdout.txt', 'r').read() if stdout_text.find("No pattern was detected.") != -1: return self.error( "returncode", "Pattern Not Found. " + "Are you sure that there's a pattern " + "in the image? " + "It may have not been detected if " + "pattern covers only a small part " + "of the image. Crop " + "the image so that the pattern covers at " + "least half of the image and re-run. " + "Otherwise, upload" + " an image containing a pattern.") if stdout_text.find("More than one pattern was detected.") != -1: return self.error( 'returncode', 'More than one pattern was ' + 'detected. Crop the image surounding the ' + 'desired pattern and re-run.') return self.error('returncode', 'Unknown Run Time Error') http.redir_303(self.base_url + 'result?key=%s' % self.key) #http.redir_303(self.outside_url + 'result?key=%s' % self.key) #http.refresh(self.outside_url + 'result?key=%s' % self.key) # archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("input_0.png") ar.add_file("psf.txt", compress=True) ar.add_file("stdout.txt", compress=True) ar.add_file("det_out.png") ar.add_file("psf.png") ar.add_info({"s": s, "k": k, "t": t}) ar.add_info({"run time": self.cfg['info']['run_time']}) ar.save() return self.tmpl_out("run.html")
def run(self): """ algorithm execution """ # read the parameters percentile = self.cfg['param']['percentile'] operator = self.cfg['param']['operator'] block = self.cfg['param']['block'] curvefilter = self.cfg['param']['curvefilter'] removeequals = self.cfg['param']['removeequals'] bins = self.cfg['param']['bins'] correction = self.cfg['param']['correction'] removeoutliers = self.cfg['param']['removeoutliers'] scales = self.cfg['param']['scales'] anoise = self.cfg['param']['anoise'] bnoise = self.cfg['param']['bnoise'] # run the algorithm try: run_time = time.time() self.run_algo(percentile, operator, \ block, curvefilter, bins, removeequals, \ correction, removeoutliers, anoise, bnoise) self.cfg['info']['run_time'] = time.time() - run_time self.cfg.save() except TimeoutError: return self.error(errcode='timeout') except RuntimeError: return self.error(errcode='runtime') http.redir_303(self.base_url + 'result?key=%s' % self.key) # archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("input_0.orig.png", info="uploaded image") ar.add_file("input_0.sel.png", info="selected subimage") # ar.add_info({"percentile": percentile}) ar.add_info({"operator": operator}) ar.add_info({"block": block}) ar.add_info({"curvefilter": curvefilter}) ar.add_info({"bins": bins}) ar.add_info({"removeequals": removeequals}) ar.add_info({"correction": correction}) ar.add_info({"removeoutliers": removeoutliers}) ar.add_info({"scales": scales}) ar.add_info({"anoise": anoise}) ar.add_info({"bnoise": bnoise}) # ar.save() return self.tmpl_out("run.html")
def zip_results(self): """ zip the tif images in a single downloadable archive: left_image.tif right_image.tif disp_sgm.tif """ # Put the files in a zip pr = self.run_proc(['/bin/bash', 'zip_results.sh']) self.wait_proc(pr, timeout=self.timeout) # Go back on the result page http.redir_303(self.base_url + 'result?key=%s' % self.key)
def run(self): """ algo execution """ self.commands = "" # read the parameters distance_def = self.cfg['param']['distance_def'] sequence = self.cfg['param']['sequence'] ratio = sequence = self.cfg['param']['ratio'] # run the algorithm try: self.run_algo() except TimeoutError: return self.error(errcode='timeout') except RuntimeError: return self.error(errcode='runtime') except ValueError as e: return self.error(errcode='returncode', errmsg='\n\n' + str(e)) http.redir_303(self.base_url + 'result?key=%s' % self.key) # archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("input_0.png", "original.png", info="uploaded") ar.add_file("resu_r.png", info="output (png format)") ar.add_file("resu_n.jpg", info="output (normalized, jpg format)") if distance_def == 'd4': ar.add_info({"distance": " city block"}) elif distance_def == 'd8': ar.add_info({"distance": " chessboard"}) elif distance_def == 'ratio': ar.add_info({ "distance": " neighborhood ratio distance with\ %s ratio" % ratio }) elif distance_def == 'sequence': ar.add_info({ "distance": ' neighborhood sequence distance with \ "%s" sequence' % sequence }) ar.add_info({"centered: ": self.cfg['param']['centered']}) ar.add_file("commands.txt", info="commands") ar.save() return self.tmpl_out("run.html")
def run(self, **kwargs): """ algorithm execution """ success = False try: run_time = time.time() self.run_algo(timeout=self.timeout) self.cfg['info']['run_time'] = time.time() - run_time except TimeoutError: return self.error(errcode='timeout') except NoMatchError: self.cfg['info']['run_time'] = time.time() - run_time http.redir_303(self.base_url + 'result?key=%s&error_nomatch=1' % self.key) except RuntimeError: return self.error(errcode='runtime') else: http.redir_303(self.base_url + 'result?key=%s' % self.key) success = True # archive if self.cfg['meta']['original']: ar = self.make_archive() ar.add_file("input_0.orig.png", info="uploaded #1") ar.add_file("input_1.orig.png", info="uploaded #2") ar.add_file("input_0.png", info="input #1") ar.add_file("input_1.png", info="input #2") if 'x0' in self.cfg['param']: ar.add_info({"crop": {'x0': self.cfg['param']['x0'], 'y0': self.cfg['param']['y0'], 'x1': self.cfg['param']['x1'], 'y1': self.cfg['param']['y1']} }) if 'precision' in self.cfg['param']: ar.add_info({"precision": self.cfg['param']['precision']}) if 'siftratio' in self.cfg['param']: ar.add_info({"SiftRatio": self.cfg['param']['siftratio']}) ar.add_file("match.txt", compress=True) ar.add_file("matchOrsa.txt", compress=True) ar.add_file("outliers.png", info="outliers image") if success: ar.add_file("inliers.png", info="inliers image") ar.add_file("panorama.png", info="panorama") ar.add_file("registered_0.png", info="registered image #1") ar.add_file("registered_1.png", info="registered image #2") ar.add_file("stdout.txt", compress=True) ar.save() return self.tmpl_out("run.html")
def grid(self, stepG, scaleR, action=None, x=0, y=0): """ handle the grid drawing and selection """ if action == 'run': # use the whole image img = image(self.work_dir + 'input_0.png') img.save(self.work_dir + 'input' + self.input_ext) img.save(self.work_dir + 'input.png') # go to the wait page, with the key and scale stepG = 0 http.redir_303(self.base_url + "wait?key=%s&scaleR=%s&step=%s" % (self.key, scaleR, stepG)) return elif action == 'redraw': # draw the grid step = int(stepG) if 0 < step: img = image(self.work_dir + 'input_0.png') img.draw_grid(step) img.save(self.work_dir + 'input_grid.png') grid = True else: grid = False return self.tmpl_out("params.html", step=stepG, grid=grid, scale_r=float(scaleR)) else: # use a part of the image x = int(x) y = int(y) # get the step used to draw the grid step = int(stepG) assert step > 0 # cut the image section img = image(self.work_dir + 'input_0.png') x0 = (x / step) * step y0 = (y / step) * step x1 = min(img.size[0], x0 + step) y1 = min(img.size[1], y0 + step) img.crop((x0, y0, x1, y1)) # zoom and save image img.resize((400, 400), method="nearest") img.save(self.work_dir + 'input' + self.input_ext) img.save(self.work_dir + 'input.png') # go to the wait page, with the key and scale http.redir_303(self.base_url + "wait?key=%s&scaleR=%s&step=%s" % (self.key, scaleR, stepG)) return