This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tweepy | |
from bots.twitter_api import get_twitter_api | |
import bots.utils as _utils | |
import datetime | |
import logging | |
import random | |
import time | |
logger = logging.getLogger() | |
logger.setLevel(logging.INFO) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from keras_tqdm import TQDMNotebookCallback | |
batch_size = 32 | |
history = model.fit_generator( | |
generator=training, | |
steps_per_epoch=training.samples // batch_size, | |
epochs=10, | |
callbacks=[TQDMNotebookCallback(leave_inner=True, leave_outer=True)], | |
validation_data=validation, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tf.keras.applications import mobilenet as _mobilenet | |
datagen = tf.keras.preprocessing.image.ImageDataGenerator( | |
preprocessing_function=_mobilenet.preprocess_input, | |
shear_range=0.2, | |
zoom_range=0.2, | |
horizontal_flip=True, | |
validation_split=0.1 | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def load_image(img_file, target_size=(224,224)): | |
X = np.zeros((1, *target_size, 3)) | |
X[0, ] = np.asarray(tf.keras.preprocessing.image.load_img( | |
img_file, | |
target_size=target_size) | |
) | |
X = tf.keras.applications.mobilenet.preprocess_input(X) | |
return X |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Copyright 2022 Fabian Bosler | |
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation | |
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, | |
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom | |
# the Software is furnished to do so, subject to the following conditions: | |
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the | |
# Software. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Copyright 2022 Fabian Bosler | |
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation | |
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, | |
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom | |
# the Software is furnished to do so, subject to the following conditions: | |
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the | |
# Software. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Copyright 2022 Fabian Bosler | |
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation | |
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, | |
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom | |
# the Software is furnished to do so, subject to the following conditions: | |
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the | |
# Software. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Copyright 2022 Fabian Bosler | |
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation | |
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, | |
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom | |
# the Software is furnished to do so, subject to the following conditions: | |
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the | |
# Software. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Student(Base): | |
_table = 'students' | |
def __init__(self, **kwargs): | |
self.name = kwargs['name'] | |
self.age = kwargs['age'] | |
super(Student, self).__init__(**kwargs) | |
class ClassRoom(Base): | |
_table = 'class_rooms' | |
def __init__(self, **kwargs): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import uuid | |
import json | |
class Base(object): | |
def __init__(self,**kwargs): | |
self._id = kwargs.get('_id') or uuid.uuid4().hex[:5] | |
@classmethod | |
def _instanciate_from_db(cls,_id): | |
res = mock_fetch_from_db(table=cls._table,_id=_id) |