def load_data(self): self.dir = os.path.dirname(__file__) #model silence_tensorflow() self.CNN = load_model('models/' + MODEL_VER) #image self.img_dir = os.path.join(self.dir, 'images') self.bg_img = pg.image.load(os.path.join(self.img_dir, 'main.png')) self.team_img1 = pg.image.load(os.path.join(self.img_dir, 'team1.jpg')) self.team_img2 = pg.image.load(os.path.join(self.img_dir, 'team2.jpg')) self.end_img = pg.image.load(os.path.join(self.img_dir, 'ending.png')) self.menu_select = pg.image.load( os.path.join(self.img_dir, 'menu_select.png')) self.font_name = pg.font.match_font(FONT_NAME) #FONT_NMAE과 맞는 폰트를 검색 self.fnt_dir = os.path.join(self.dir, 'font') self.gg_font = os.path.join(self.fnt_dir, GG) #sound(효과음) self.snd_dir = os.path.join(self.dir, 'sound') self.key_sound = pg.mixer.Sound(os.path.join(self.snd_dir, KEY)) self.decision_sound = pg.mixer.Sound( os.path.join(self.snd_dir, DECISION)) self.fail_sound = pg.mixer.Sound(os.path.join(self.snd_dir, FAIL)) self.good_sound = pg.mixer.Sound(os.path.join(self.snd_dir, APPLAUSE)) self.success_sound = pg.mixer.Sound(os.path.join( self.snd_dir, SUCCESS)) self.exit_sound = pg.mixer.Sound(os.path.join(self.snd_dir, EXIT)) self.blink_sound = pg.mixer.Sound(os.path.join(self.snd_dir, BLINK)) self.count_sound = pg.mixer.Sound(os.path.join(self.snd_dir, COUNT)) self.ready_sound = pg.mixer.Sound(os.path.join(self.snd_dir, READY))
def __init__(self, language, model: str = "bleurt-base-128"): super().__init__(language) # HACK TO SILENCE tensorflow and errors related to tf.FLAGS from silence_tensorflow import silence_tensorflow silence_tensorflow() import tensorflow.compat.v1 as tf flags = tf.flags flags.DEFINE_string("source", "", help="Source segments", required=False) flags.DEFINE_string("s", "", help="Source segments", required=False) flags.DEFINE_string("hypothesis", "", help="MT segments", required=False) flags.DEFINE_string("h", "", help="MT segments", required=False) flags.DEFINE_string("reference", "", help="Reference segments", required=False) flags.DEFINE_string("r", "", help="Reference segments", required=False) flags.DEFINE_string("language", "", help="Language", required=False) flags.DEFINE_string("l", "", help="Language", required=False) flags.DEFINE_string("metric", "", help="Metric to run.", required=False) flags.DEFINE_string("m", "", help="Metric to run.", required=False) self.model = model if not os.path.isdir(telescope_cache_folder() + model): download_file_maybe_extract( url=f"https://storage.googleapis.com/bleurt-oss/{model}.zip", directory=telescope_cache_folder(), ) self.scorer = score.BleurtScorer(telescope_cache_folder() + model) self.system_only = False
def cli_main(_state, log): levels = { "critical": logging.CRITICAL, "error": logging.ERROR, "warning": logging.WARNING, "info": logging.INFO, "debug": logging.DEBUG, } coloredlogs.install( level=levels[log], fmt="%(asctime)s %(hostname)s %(name)s %(levelname)s %(message)s", ) # TODO: Add option to disable this from silence_tensorflow import silence_tensorflow silence_tensorflow()
from silence_tensorflow import silence_tensorflow silence_tensorflow() from gui import * from nn_class import * import os,sys import easygui import tensorflow as tf # deep learning library. Tensors are just multi-dimensional arrays print(tf.config.experimental.list_physical_devices('GPU')) test_data = [[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]] test_answer = [1] model = tf.keras.models.Sequential() # a basic feed-forward model # mnist = tf.keras.datasets.mnist # mnist is a dataset of 28x28 images of handwritten digits and their labels # (x_train, y_train),(x_test, y_test) = mnist.load_data() # unpacks images to x_train/x_test and labels to y_train/y_test box_num=20 boxes = [] windowsize = (300,350) window1 = python_GUI("test1",windowsize) box_size = windowsize[0] / box_num test_number = 0 test_count = 0 # training_itterations = 10000 ai_datafile = "ai_data20-20-2.txt" AI_TRAIN = True def keras_train(x_train,y_train):
def test_silence_tensorflow(): """Check that everything runs.""" silence_tensorflow()
import warnings import silence_tensorflow as stf warnings.simplefilter(action='ignore', category=FutureWarning) stf.silence_tensorflow() import matplotlib.pyplot as plt import numpy as np from cvae import cvae # Initialise the tool, assuming we already have an array X containing the data from sklearn.datasets import fetch_openml mnist = fetch_openml('mnist_784', version=1, cache=True) X = mnist.data y = np.array(list(map(int, mnist.target))) embedder = cvae.CompressionVAE(X) # Train the model embedder.train() X_embedding = embedder.embed(X) print(X_embedding.shape) # embedder.visualize(z, labels=[int(label) for label in mnist.target]) for i in range(10): Xe = X_embedding[y == i] plt.scatter(Xe[:, 0], Xe[:, 1], s=1) plt.title("CVAE") plt.show()
# To exectute this script you will need to install the following modules: # pip install tensorflow pillow silence_tensorflow --user # Nota: Tensorflow is a big A.I. library, it can take a while to install from silence_tensorflow import silence_tensorflow silence_tensorflow( ) #This library is to prevent Tensorflow from showing alerts or debug information import tensorflow as tf #AI Processing Library import tensorflow.keras as kr #AI Processing Library with examples import numpy as np #Numbers and arrays processing library from tensorflow.keras.preprocessing import image #For image managing from tensorflow.keras.applications.inception_v3 import InceptionV3, decode_predictions #Neural network model trained to recognize images #initialization of a variable with the neural network iv3 = InceptionV3() def reconocerImagen(imageFromUser): #changing dimension of image to 299x299 pixels imageRedim = image.load_img(imageFromUser, target_size=(299, 299)) #Creation of array, where each element is a pixel #each pixel is represented as an arrau of 3 numbers that range from 0 to 255 #each element of the three numbers that represent each pixel indicate the RGB color x = image.img_to_array(imageRedim) #Converting each value of 0 to 255 using the rule of 3 so that they are converted to a range of -1 to 1 #where -1 = 0 and 1 = 255 x /= 255 x -= 0.5