val = 0.5 - val / 2 l.append(val) Features['FacesNumber3'] = len(l) if Features['FacesNumber3'] > 0: Features['AverageSex2'] = np.mean(l) # print len(l), l except Exception, e: print('error SKYBIOMETRY ' + str(e), file=sys.stderr) ############################# LUKASZ.FLOWERS, BIRDS ################################# try: file = cStringIO.StringIO(urllib.urlopen(ImURL).read()) image = Image.open(file) Features['Classifier_Flowers_Score'] = predict_adopted.predict( "FLOWERS", image) Features['Classifier_Birds_Score'] = -1 except Exception, e: print('error CLASSIFIER ' + str(e), file=sys.stderr) ############################# SAVE [ TO FILE + STDOUT ] ################################# data['content']['height'] = data4['height'] data['content']['width'] = data4['width'] data['content']['features'] = Features output = open('data.json', 'wb') output.write(json.dumps(data, indent=2)) output.close() #output = open('data.json', 'rb') #data = json.load(output)
log('error SKYBIOMETRY' + str(e)) ############################# LUKASZ.FLOWERS, BIRDS ################################# data['softwareAgent_id'] = 'fr_classifier' data['documentType'] = data['softwareAgent_id'] data['softwareAgent_label'] = 'classifier: set of classes' data['softwareAgent_configuration'] = "flowers" data['documentType'] = data['softwareAgent_id'] + "-" + data['softwareAgent_configuration'] data['content'] = {} data['parents'] = [parentID] data['content']['URL'] = ImURL Features = {} Features["classifier"] = [] try: file = cStringIO.StringIO(urllib.urlopen(ImURL).read()) image = Image.open(file) val = predict_adopted.predict("FLOWERS", image) / 100.0 Features["classifier"].append({'label' : 'flowers', 'score' : val }) data['content']['features'] = Features th = 0.55 data['threshold'] = th data['relevantFeatures'] = [] if val > th: data['relevantFeatures'].append("flowers") r = requests.post(url, data=json.dumps(data), headers=headers) print (r) log(r) if WRITE_FILE==1: output.write(json.dumps(data, indent = 2)) except Exception, e: print('error CLASSIFIER' + str(e), file=sys.stderr)
log("error SKYBIOMETRY" + str(e)) ############################# LUKASZ.FLOWERS, BIRDS ################################# data["softwareAgent_id"] = "fr_classifier" data["documentType"] = data["softwareAgent_id"] data["softwareAgent_label"] = "classifier: set of classes" data["softwareAgent_configuration"] = "flowers" data["documentType"] = data["softwareAgent_id"] + "-" + data["softwareAgent_configuration"] data["content"] = {} data["parents"] = [parentID] data["content"]["URL"] = ImURL Features = {} Features["classifier"] = [] try: file = cStringIO.StringIO(urllib.urlopen(ImURL).read()) image = Image.open(file) val = predict_adopted.predict("FLOWERS", image) / 100.0 Features["classifier"].append({"label": "flowers", "score": val}) data["content"]["features"] = Features th = 0.55 data["threshold"] = th data["relevantFeatures"] = [] if val > th: data["relevantFeatures"].append("flowers") r = requests.post(url, data=json.dumps(data), headers=headers) print(r) log(r) if WRITE_FILE == 1: output.write(json.dumps(data, indent=2)) except Exception, e: print("error CLASSIFIER" + str(e), file=sys.stderr)
l.append(val) Features['FacesNumber3'] = len(l) if Features['FacesNumber3'] > 0: Features['AverageSex2'] = np.mean(l) # print len(l), l except Exception , e: print('error SKYBIOMETRY '+ str(e), file=sys.stderr) ############################# LUKASZ.FLOWERS, BIRDS ################################# try: file = cStringIO.StringIO(urllib.urlopen(ImURL).read()) image = Image.open(file) Features['Classifier_Flowers_Score'] = predict_adopted.predict("FLOWERS", image) Features['Classifier_Birds_Score'] = -1 except Exception , e: print('error CLASSIFIER ' + str(e), file=sys.stderr) ############################# SAVE [ TO FILE + STDOUT ] ################################# data['content']['height'] = data4['height'] data['content']['width'] = data4['width'] data['content']['features'] = Features output = open('data.json', 'wb') output.write(json.dumps(data, indent = 2)) output.close()