def generateCode(self, p): declaredIterator = VariableDeclaration(self.pidentifier, islocal=True) declaredIterator.register() iteratorIdentifier = Identifier(self.pidentifier) instructions.FOR_DOWNTO(p, self.fromValue, self.toValue, iteratorIdentifier, self.commands) declaredIterator.delete()
def main(args): detector = MTCNN() embedder = ArcFace(args.model) identifier = Identifier(args.data_path) vc = cv2.VideoCapture(0) while vc.isOpened(): isSuccess, frame = vc.read() bbox, face = detector.align(frame) if face is not None: rgb = np.array(face)[..., ::-1] feature = embedder.get_feature(rgb) name, value = identifier.process(feature) print(name, value) x0, y0, x1, y1, _ = bbox cv2.rectangle(frame, tuple((int(x0), int(y0))), tuple((int(x1), int(y1))), (0, 255, 0), 2) cv2.putText(frame, name, (int(x0), int(y0)), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 0, 0), 2) cv2.imshow("Frame", frame) print('===========') key = cv2.waitKey(1) & 0xFF if key == ord('q'): break vc.release() cv2.destroyAllWindows()
def main(): symbol_table = SymbolTable() v1 = Identifier('a', 5) v2 = Identifier('b', 7) v3 = Identifier('c', 12) v4 = Identifier('a', 14) c1 = Constant('d', 7) symbol_table.add(v1) symbol_table.add(v2) symbol_table.add(v3) symbol_table.add(c1) symbol_table.add(v4) v2.set_value(42) symbol_table.add(v2) c2 = Constant('c', 17) symbol_table.add(c2) symbol_table.print_symbol_table()
def parse(self, string): tags = string.split(params.INFO_SEPARATOR) tag_types = {} if len(tags) == 1: self.infos[ERROR_TAG] = self.tag_type(tags[0]) return # Identify info class for each tag: for tag in tags: identifier = Identifier() tag_types[tag] = identifier.identify_tag_type(tag) # for tag in tags: # tag_types[tag] = self.tag_type(tag) for tag, types in tag_types.items(): if len(types) == 1: self.infos[types[0]] = tag.strip() # Parse info into nicer, more readable shape: try: self._parse_course_details() self._parse_event_type() self._parse_classroom() self._parse_timestamp() self._parse_building() self._parse_location() self._parse_summary() except: ## For tesing: print("ERROR PARSING:") print(tags) e = sys.exc_info()[0] for k, v in self.infos.items(): print(k, ':', v) a = input("Press enter to continue - " + "write input to raise error\n") if len(a): raise e print() for k, v in self.infos.items(): print(k, ':', v) a = input("Press enter to continue\n")
def save(self, *args, **kwargs): if not hasattr(self, 'identifier'): try: topic_map = self.topic_map except AttributeError: # This is a TopicMap instance being saved for the # first time, so it is not possible to set the # database ID yet. topic_map = None identifier = Identifier(containing_topic_map=topic_map) identifier.save() self.identifier = identifier super(BaseConstructFields, self).save(*args, **kwargs) if self.identifier.containing_topic_map is None: # In the case of a TopicMap instance being saved for the # first time, the containing_topic_map will not have been # set (see above), so set it once the TopicMap is saved. self.identifier.containing_topic_map = self self.identifier.save()
import string import random from pathlib import Path import base64 from io import BytesIO import asyncio from sanic import Sanic import sanic.response as sanic_response from functions import * from identifier import Identifier loop = asyncio.get_event_loop() app = Sanic(__name__) identifier = Identifier() @app.route('/') async def index(request): return await sanic_response.file('index/index.html') @app.route('/image/<uid>') async def getImage(request, uid): img_loc = identifier.getImageLocation(uid) if not img_loc: return sanic_response.text('not valid') return await sanic_response.file(img_loc)
def visit_identifier(self, node, visited_children): literal = Identifier(node.text) return Queue([literal])
import asyncio from functions import videoProcessing from identifier import Identifier i = Identifier() asyncio.ensure_future(videoProcessing(i, True))
import json from identifier import Identifier from os.path import abspath app = Flask(__name__) host = "0.0.0.0" port = 6000 suicidePath = abspath("../resources/articles/suicide") generalPath = abspath("../resources/articles/general") preprocessorEndpoint = 'http://*****:*****@app.route('/api/identifier', methods=['GET', 'POST']) def identifier(): if request.method == 'GET': pass elif request.method == 'POST': pass @app.route('/api/identifier/suicide', methods=['POST']) def suicide_identify(): content = "" if (request.form):
def p_identifier(p): '''identifier : pidentifier''' p[0] = Identifier(p[1])
def __init__(self, meta_info): self.meta_info = meta_info self.identifier = Identifier(self.meta_info) self.modifier = Modifier(self.identifier)
def get(self): """ Se creara un identifier con un atributo y despues se revisara que el get de ese mismo atributo""" test = Identifier("test") self.assert_("test" == test.get_imgdir())
def set_get(self): """ Este metodo creará un identifier y usara su set para cambiarlo una variable cualquiera, despues verificara que su atributo no sea el del inicio """ test = Identifier("test") test.set_imgdir("cambio") self.assert_("test" != test.get_imgdir())
import gsp_support as gsp import gsp_visualize as gsp_v if len(sys.argv) < 2: print('Usage: python visualizer.py [house_num]') print( 'This program is for visualizing full datasets to create refined ones') sys.exit() house_num = int(sys.argv[1]) csvfileaggr = 'dataset/house_{}/output_aggr.csv'.format(house_num) csvfiledisaggr = 'dataset/house_{}/output_disaggr.csv'.format(house_num) csvfileresponse = 'dataset/house_{}/output_response.csv'.format(house_num) identifier = Identifier(20, csvfileresponse) demo_file = pd.read_csv(csvfileaggr, index_col="Time") demo_file.index = pd.to_datetime(demo_file.index) demo_file_truth = pd.read_csv(csvfiledisaggr, index_col="Time") demo_file_truth.index = pd.to_datetime(demo_file_truth.index) # Load settings disag_settings = get_disagg_settings(house_num) data_settings = get_dataset_settings(house_num) # Aggregate similar channels demo_file_truth = gsp.aggregate_channels(demo_file_truth, data_settings) mask = (demo_file.index > disag_settings.start_time) & ( demo_file.index < disag_settings.end_time)