def testCounts(self): msg = sidewalk r, t = main.decode(msg, dictfile) l = [("there", 4), ("sidewalk", 1), ("and", 5), ("wind", 1), ("the", 6)] for w, c in l: self.assertEqual(t.count(w), c)
def testRand_DurationHMM(): ''' test with audio features from real recording, but some random models_makam, not trained models_makam TODO: this might not work. rewrite ''' durGMMhmm, d = makeTestDurationHMM() durGMMhmm.setALPHA(0.97) listDurations = [70, 30, 20, 10, 20] durGMMhmm.setDurForStates(listDurations) observationFeatures = numpy.array((0.6 * numpy.random.random_sample( (2, d)) - 0.3), dtype=numpy.double) # observationFeatures = loadMFCCs(URIrecordingNoExt) decode(lyricsWithModels, observationFeatures, 'testRecording')
def for_decode(): errors = [] if 'image' not in request.files: errors.append('no image') if 'key' not in request.form: errors.append('no key') if len(errors) > 0: return jsonify({'status': 400, 'errors': errors}), 400 img_data = np.array(Image.open(request.files['image']).convert('RGBA')) return jsonify({ 'status': 200, 'data': decode(img_data, request.form['key']) })
def api(): print('in') postData = request.json imgData = postData['imgData'] #print(imgData) dbs = {} label, lblname = predict(decode(imgData)) print(lblname) df = pd.read_csv('final.csv', index_col=0) indexValues = df.columns.values data = df.loc[label] dbNames = list(set(indexValues) - set(['label', 'name'])) for dbName in dbNames: db = {} ref = pd.read_csv('database-new/' + dbName + '.csv') reqId = data[dbName] reqData = ref.loc[ref['id'] == reqId] #print(reqData) for column in reqData: if not column == 'image': value = reqData[column].tolist() if not value == []: value = value[0] #print(type(value)) if isinstance(value, long): value = str(value).strip('L') #print(column, value) db[column] = value if not db == {}: dbs[dbName] = db print(dbs) return Response(response=json.dumps(dbs), status=200, mimetype="application/json")
def testLongSingleShift(self): msg = hamlet_encoded res = hamlet r, t = main.decode(msg, dictfile) self.assertEqual(r, res)
def testShortMultiShift(self): msg = cat_encoded res = cat r, t = main.decode(msg, dictfile) self.assertEqual(r, res)
def testShortSingleShift(self): msg = sidewalk_encoded res = sidewalk r, t = main.decode(msg, dictfile) self.assertEqual(r, res)
def testLongMultiShift(self): msg = v_entries_encoded res = v_entries r, t = main.decode(msg, dictfile) self.assertEqual(r, res)
def test(self): self.assertEqual(decode([20, 12, 18, 30, 21], 1939), "scout") self.assertEqual( decode([14, 10, 22, 29, 6, 27, 19, 18, 6, 12, 8], 1939), "masterpiece")
def test_decoding(self): assert "WeebLinux" == main.decode("JrroYvahk")
def OnButtonClick(self): self.labelVariable.set(main.decode(self.entryVariable.get()))
import main r = main.encode('some hello') print(r) print(main.decode(r)) r = main.encode('我数据库好地方') print(r) print(main.decode(r)) r = main.encode('142857') print(r) print(main.decode(r)) r = main.encode(r) print(r) print(main.decode(r)) code = main.encode('你好啊,123') print(code) imdata = main.to_imdata_pixels(code) print(imdata) print(main.decode(main.origin_imdata_pixels(imdata)))
def test_decode(self): self.assertEqual(decode(sourcecode), ["oeko", "tek", "hel", "hum", "laer", "kun"])
def testCounts(self): msg = sidewalk r, t = main.decode(msg, dictfile) l = [("there",4),("sidewalk",1),("and",5),("wind",1),("the",6)] for w,c in l: self.assertEqual(t.count(w), c)
def test(self): self.assertEqual(main.decode([[4, 1], 2, [2, 3], [2, 1], 4, [4, 5]]), [1, 1, 1, 1, 2, 3, 3, 1, 1, 4, 5, 5, 5, 5])