Exemplo n.º 1
0
def load_dataset(root_dir):
    try:
        return pickle.load(open(images_root_dir + "img_dataset.p", "rb"))
    except:
        data = np.empty((0, IMG_SIZE**2 * levels + 4), dtype=np.uint8)

        total = 0
        for _ in glob.iglob(root_dir + '**/*.jpeg', recursive=True):
            total += 1

        with tqdm(total=total) as pbar:
            for img_file in glob.iglob(images_root_dir + '**/*.jpeg',
                                       recursive=True):
                image = Image.open(img_file, 'r')
                X = np.asarray(image).reshape(-1)[
                    int((2640**2 * levels - IMG_SIZE**2 * levels) /
                        2):int((2640**2 * levels - IMG_SIZE**2 * levels) / 2 +
                               IMG_SIZE**2 *
                               levels)]  # immagine ridotta per performace
                Y = get_target(img_file)
                data = np.append(data, np.array([np.append(X, Y)]), axis=0)
                pbar.update(1)

        pickle.dump(data, open(images_root_dir + "img_dataset.p", "wb"))
        return data
Exemplo n.º 2
0
 def write_riri_me(self, msg_text, channel_id):
     target = get_target(RIRI_FLAG, msg_text).upper()
     if target != "":
         txt = ' '.join(target for num in range(5))
     else:
         txt = "WHY WOULD YOU JUST TYPE RIRI?\n"
     self.write_slow(txt, channel_id)
Exemplo n.º 3
0
 def write_riri_me(self, msg_text, channel_id):
     target = get_target(RIRI_FLAG, msg_text).upper()
     if target != "":
         txt = ' '.join(target for num in range(5))
     else:
         txt = "WHY WOULD YOU JUST TYPE RIRI?\n"
     self.write_slow(txt, channel_id)
 def write_encouragement(self, msg_text, channel_id):
     encouragements = [
         "Get your shit together", "You can do it", "I'm here for you",
         "Do you just think about yourself", "You're the best",
     ]
     target = get_target(ENCOURAGE_FLAG, msg_text)
     txt = '{} {}'.format(random.choice(encouragements), target)
     self.write_slow(txt, channel_id)
Exemplo n.º 5
0
 def write_encouragement(self, msg_text, channel_id):
     encouragements = [
         "Get your shit together",
         "You can do it",
         "I'm here for you",
         "Do you just think about yourself",
         "You're the best",
     ]
     target = get_target(ENCOURAGE_FLAG, msg_text)
     txt = '{} {}'.format(random.choice(encouragements), target)
     self.write_slow(txt, channel_id)
Exemplo n.º 6
0
 def get_house(self, msg_text):
     options = []
     target = get_target(SORT_FLAG, msg_text).lower()
     if 'not' in target:
         for house in HOUSES:
             if house.lower() not in target:
                 options.append(house)
         if len(options) == 0:
             return ""
         return random.choice(options)
     else:
         for house in HOUSES:
             if house.lower() in target:
                 options.append(house)
         if len(options) == 0:
             options = list(HOUSES)
         return random.choice(options)
def create_dataset_androguard_SE(root_dir, new_dataset):

    total = 0
    for _ in glob.iglob(root_dir + '**/*.apk', recursive=True):
        total += 1

    data = np.empty((0,len(features_SE) + 4 + 1))

    with tqdm(total=total) as pbar:
        for apk_file in glob.iglob(root_dir + '**/*.apk', recursive=True):
            try:
                properties = get_properties_SE(apk_file)
                data = np.append(data, [np.append([apk_file], np.append(properties, get_target(apk_file)))], axis=0)
                #data = np.append(data, [np.append([apk_file], np.append(properties, [0,1,0,0]))], axis=0)  #fixed target
                pbar.update(1)
            except Exception as e:
                logging.error('Failed: ' + apk_file + "\t" + str(e))

    targets = ['trivial', 'string', 'reflection', 'class']
    df = pd.DataFrame(data=data, columns=['filename']+features_SE+targets)
    df.to_csv(new_dataset)
Exemplo n.º 8
0
 def write_sweetpotato_me(self, msg_text, channel_id):
     target = get_target(SWEETPOTATO_FLAG, msg_text)
     txt = 'Here, {}! :sweet_potato:'.format(target)
     self.write_slow(txt, channel_id)
Exemplo n.º 9
0
 def write_sass(self, msg_txt, channel_id):
     target = get_target(SASS_FLAG, msg_txt)
     sass = 'Hey, {}! {}'.format(target, self.sass_manager.get_response())
     self.write_slow(sass, channel_id)
Exemplo n.º 10
0
 def write_french(self, msg_text, channel_id):
     target = get_target(FRENCH_FLAG, msg_text).replace('_', '')
     self.write_slow('_le {}_'.format(target), channel_id)
Exemplo n.º 11
0
 def write_sweetpotato_me(self, msg_text, channel_id):
     target = get_target(SWEETPOTATO_FLAG, msg_text)
     txt = 'Here, {}! :sweet_potato:'.format(target)
     self.write_slow(txt, channel_id)
Exemplo n.º 12
0
 def write_sass(self, msg_txt, channel_id):
     target = get_target(SASS_FLAG, msg_txt)
     sass = 'Hey, {}! {}'.format(target, self.sass_manager.get_response())
     self.write_slow(sass, channel_id)
Exemplo n.º 13
0
 def write_french(self, msg_text, channel_id):
     target = get_target(FRENCH_FLAG, msg_text).replace('_', '')
     self.write_slow('_le {}_'.format(target), channel_id)