text
stringlengths
1
93.6k
while (torch.cat(logits, 0).shape[0] if len(logits) else 0) < img_num:
with torch.no_grad():
images = self.generate_data()
pool_val, logits_val = self.net(images)
pool += [pool_val]
logits += [F.softmax(logits_val, 1)]
return torch.cat(pool, 0), torch.cat(logits, 0)
def get_fid_score(self):
pool, logits = self.accumulate_activations()
print('Calculating FID...')
mu, sigma = torch.mean(pool, 0), torch_cov(pool, rowvar=False)
# fid_score = torch_calculate_frechet_distance(mu, sigma, self.mu_real, self.sigma_real)
# return fid_score.cpu().numpy()
fid_score = numpy_calculate_frechet_distance(mu.cpu().numpy(), sigma.cpu().numpy(),
self.mu_real.cpu().numpy(),
self.sigma_real.cpu().numpy())
return fid_score
if __name__ == '__main__':
parser = eval_parser()
config = vars(parser.parse_args())
print(config)
print('numpy calculation')
device = torch.device('cuda:0')
model = config['model']
z_dim = config['z_dim']
if model == 'dc':
G = GoodGenerator()
elif model == 'ResGAN':
G = ResNet32Generator(z_dim=z_dim, num_filters=128, batchnorm=True)
elif model == 'DCGAN':
G = DC_generator(z_dim=z_dim)
elif model == 'mnist':
G = dc_G(z_dim=z_dim)
elif model == 'dc32':
G =dcG32(z_dim=z_dim)
else:
raise ValueError('No matching generator for %s' % model)
G.to(device)
G.eval()
evalor = evalor(G=G, z_dim=z_dim,
model_dir=config['model_dir'],
device=device,
log_path=config['logdir'],
dim=config['dim'])
evalor.eval_metrics(begin=config['begin'], end=config['end'], step=config['step'],
is_flag=config['eval_is'], fid_flag=config['eval_fid'],
dataname=config['dataset'])
# <FILESEP>
#!/usr/bin/env python3
# TODO: Ad-blocking. How, you may ask? I suggest letting the user set a list of
# "banned" track titles which usally appear when ads are playing, and replacing
# them either with another radio stream or some pleasant elevator music (file/folder).
# As soon as we detect the track title changing again, we can switch back to the radio stream.
# Also, the same technique could be used to block unwanted "trending" songs!
# Progress: Done!
# TODO: Downloading of streams, splitting of the file in seperate music files per
# title and storing them in an seperate folder. Command line setting to disable
# file splitting.
# Progress: Beta, still kinda unhappy with this.
# TODO: Direct streaming: Let the user pass an URL and add it to the database,
# then play it.
# Progress: Done!
# TODO: Clean this mess!
# Progress: None
import argparse
import json
import requests
import signal
import sys
import time
import colorama
import vlc
import download
import tunein
# Heh, ripped from the Blender build scripts
class colors:
GREEN = '\033[92m'
RED = '\033[91m'
YELLOW = '\033[93m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
ENDC = '\033[0m'
# Load the config file, config.json
def load_config():
try:
with open("config.json", "r") as f: