Ejemplo n.º 1
0
def build_collection_message(collection):
    games = []
    for game in collection.games.all():
        games.append({
            'screenshot_path_1': game.screenshot_path_1.path,
            'name': game.name,
            'icon': game.icon.path,
            'rating': game.rating,
            'size': game.size,
            'category': game.category.name,
            'brief_comment': game.brief_comment,
            'recommended_reason': game.recommended_reason
        })
    content = str(
        render_to_string(
            'collection_weibo.tpl', {
                'template_path': TEMPLATE_ROOT,
                'games': games,
                'cover': collection.cover.path,
                'title': collection.title
            }))
    entity = Entity.objects.get(id=collection.id)
    if entity.status3 == 2:
        message_link = u'【下载】' + 'http://cow.bestgames7.com/d/%s/' % collection.id
    else:
        message_link = ''
    return WeiboMessage(
        u'#游戏合集# ' + _shorten_text(collection.recommended_reason, 110) +
        message_link, make_image(collection.id, content), collection.id)
Ejemplo n.º 2
0
    def on_add(self, widget):
        mod = self.view.get_model()
        it = mod.get_iter_first()
        id = 0

        while it != None:
            tmp = int(self.store.get_value(it, 0))

            if tmp > id:
                id = tmp

            it = mod.iter_next(it)

        id += 1
        it = self.store.append()

        # Settiamo il campo ID e gli altri campi
        self.store.set_value(it, 0, id)
        x = 0

        for tmp in self.vars:
            if self.store.get_column_type(self.vars.index(tmp) + 1).pytype == gtk.gdk.Pixbuf:

                # print "col n %d => %s" % (self.last + x, tmp)

                self.store.set_value(it, self.last + x, tmp.get_text())

                self.store.set_value(it, self.vars.index(tmp) + 1, utils.make_image(tmp.get_text()))

                x += 1
            else:
                self.store.set_value(it, self.vars.index(tmp) + 1, tmp.get_text())

        self.add_entry(it)
Ejemplo n.º 3
0
	def _on_refresh (self, widget):
		self.lock ()
		
		# Prendiamo l'iter e il modello dalla selezione
		mod, it = self.view.get_selection ().get_selected ()

		it = self.filter.convert_iter_to_child_iter (it)
		
		# Se esiste una selezione aggiorniamo la row
		# in base al contenuto delle entry
		
		if it != None:
			#id = int (self.store.get_value (it, 0))
			x = 0

			for tmp in self.vars:
				if self.store.get_column_type (self.vars.index (tmp) + 1).pytype == gtk.gdk.Pixbuf:
					
					self.store.set_value (it, x + self.last, tmp.get_text ())
					
					self.store.set_value (it, self.vars.index (tmp) + 1, utils.make_image (tmp.get_text ()))
					
					x += 1
				else:
					self.store.set_value (it, self.vars.index (tmp) + 1, tmp.get_text ())
			
			self.after_refresh (it)
		
		self.unlock ()
Ejemplo n.º 4
0
def _build_game_image(game):
    content = str(render_to_string('screenshots_weixin.tpl', {
        'screenshot_path_1' : game.screenshot_path_1.path,
        'screenshot_path_2' : game.screenshot_path_2.path,
        'screenshot_path_3' : game.screenshot_path_3.path,
        'screenshot_path_4' : game.screenshot_path_4.path
        }))
    return make_image(game.id, content)
Ejemplo n.º 5
0
 def mosaic_fast(self, image):
     print('Running "fast" mosaic ...')
     tiles = slice_image(image, 32)
     num_tiles = tiles.shape[0] * tiles.shape[1]
     flat_tiles = np.stack(tiles).reshape(num_tiles, -1)
     patches = self.get_patches(flat_tiles)
     new_tiles = np.stack(patches).reshape(tiles.shape)
     new_image = make_image(new_tiles)
     return new_image
Ejemplo n.º 6
0
	def __init__(self):
		# Per immagini prima le pixbuf e le stringhe alla fine
		lst = gtk.ListStore(int, str, str, gtk.gdk.Pixbuf, str)
		
		lst.append([1, "Francesco", "stringa",
				utils.make_image("prova.png"), "prova.png"])

		DBWindow.__init__(self, 2, 2, ["ID", "Nome", "Stringa", "Immagine"],
				[gtk.Entry(), gtk.Entry(), utils.ImgEntry()], lst)
Ejemplo n.º 7
0
def _build_game_image(game):
    content = str(
        render_to_string(
            'screenshots_weixin.tpl', {
                'screenshot_path_1': game.screenshot_path_1.path,
                'screenshot_path_2': game.screenshot_path_2.path,
                'screenshot_path_3': game.screenshot_path_3.path,
                'screenshot_path_4': game.screenshot_path_4.path
            }))
    return make_image(game.id, content)
Ejemplo n.º 8
0
def build_redier_message(redier):
    content = str(render_to_string('redier_weibo.tpl', {
        'template_path' : TEMPLATE_ROOT,
        'image' : redier.image_url.path
        }))
    if redier.video_url is not None and redier.video_url != '':
        weibo_status = _shorten_text(redier.recommended_reason, 112) + redier.video_url
    else:
        weibo_status = _shorten_text(redier.recommended_reason, 132)
    return WeiboMessage(u'#小兵变大咖# ' + weibo_status, make_image(redier.id, content), redier.id)
Ejemplo n.º 9
0
def build_problem_message(problem):
    content = str(render_to_string('problem_weibo.tpl', {
        'template_path' : TEMPLATE_ROOT,
        'image' : problem.image_url.path
        }))
    if problem.video_url is not None and problem.video_url != '':
        weibo_status = _shorten_text(problem.recommended_reason, 111) + problem.video_url
    else:
        weibo_status = _shorten_text(problem.recommended_reason, 131)
    return WeiboMessage(u'#宅,必有一技# ' + weibo_status, make_image(problem.id, content), problem.id)
Ejemplo n.º 10
0
	def __init__ (self): 

		# id integer, vasca TEXT, date DATE, nome TEXT, litri TEXT, tipo TEXT, filtro TEXT, co TEXT, illuminazione TEXT, reattore TEXT, schiumatoio TEXT, riscaldamento TEXT, img TEXT
		lst = gtk.ListStore (int, str, str, str, float, str, str, str, str, str, str, str, gtk.gdk.Pixbuf, str)

		tmp = utils.Combo ([_("Dolce"), _("Dolce Tropicale"), _("Marino"), _("Marino Mediterraneo"), _("Paludario"), _("Salmastro")])
		tmp.connect ('changed', self.aggiorna)

		self.col_lst = [_('Id'), _('Vasca'), _('Data'), _('Nome'), _('Litri'),
			_('Tipo Acquario'), _('Tipo Filtro'),
			_('Impianto Co2'), _('Illuminazione'), 
			_('Reattore di calcio'), _('Schiumatoio'), _('Riscaldamento Refrigerazione'), _("Immagine")]
		
		dbwindow.DBWindow.__init__ (self, 2, 5, self.col_lst,
				[tmp, utils.DataButton (), gtk.Entry (), utils.FloatEntry (),
				 gtk.Entry (), gtk.Entry (), gtk.Entry (), gtk.Entry (), gtk.Entry (),
				 gtk.Entry (), gtk.Entry (), utils.ImgEntry ()], lst)


		for y in utils.get ('select * from vasca'):
			lst.append([y[0], y[1], y[2], y[3], y[4],
					y[5], y[6], y[7], y[8], y[9], y[10], y[11], utils.make_image(y[12]), y[12]])
		
		self.set_title (_("Vasche"))
		self.set_size_request (700, 500)
		self.set_icon_from_file ("pixmaps/logopyacqua.jpg")

		self.menu = gtk.Menu ()

		it = gtk.RadioMenuItem (None, label=_("Dolce"))
		it.connect ('activate', self.show_dolce)
		self.menu.append (it)
		
		it = gtk.RadioMenuItem (it, label=_("Dolce Tropicale"))
		it.connect ('activate', self.show_dolce)
		self.menu.append (it)

		it = gtk.RadioMenuItem (it, label=_("Marino"))
		it.connect ('activate', self.reset)
		self.menu.append (it)

		it = gtk.RadioMenuItem (it, label=_("Marino Mediterraneo"))
		it.connect ('activate', self.reset)
		self.menu.append (it)

		it = gtk.RadioMenuItem (it, label=_("Paludario"))
		it.connect ('activate', self.show_dolce)
		self.menu.append (it)

		it = gtk.RadioMenuItem (it, label=_("Salmastro"))
		it.connect ('activate', self.show_dolce)
		self.menu.append (it)
		
		self.menu.show_all ()
		self.view.connect ('button-press-event', self.on_btn)
Ejemplo n.º 11
0
	def refresh_data (self, islocked):
		if islocked: return
		
		self.main_db.store.clear ()
		self.main_db.vars[1].clear_all ()
		
		for y in app.App.p_backend.select ("*", "invertebrati"):
			self.main_db.store.append([y[0], y[1], y[2], y[3], y[4], y[5], utils.make_image(y[6]), y[6]])
		for y in app.App.p_backend.select ("*", "vasca"):
			self.main_db.vars[1].append_text (y[3])
			self.main_db.filter_menu.append (gtk.CheckMenuItem (y[3]))
Ejemplo n.º 12
0
	def refresh_data (self, islocked):
		if islocked: return
		
		self.main_db.store.clear ()
		self.main_db.vars[1].clear_all ()
		
		for y in app.App.p_backend.select ("*", "piante"):
			self.main_db.store.append([y[0], y[1], y[2], y[3], y[4], y[5], utils.make_image(y[6]), y[6]])
		
		for y in app.App.p_backend.select ("*", "vasca"):
			self.main_db.vars[1].append_text (y[3])
Ejemplo n.º 13
0
def build_puzzle_message(puzzle):
    content = str(render_to_string('puzzle_weibo.tpl', {
        'puzzle_id' : puzzle.id,
        'template_path' : TEMPLATE_ROOT,
        'puzzle_pic' : puzzle.image_url.path,
        'puzzle_content' : puzzle.description,
        'optiona' : puzzle.option1,
        'optionb' : puzzle.option2,
        'optionc' : puzzle.option3,
        'optiond' : puzzle.option4,
    }))

    return WeiboMessage(u'#趣味答题# ' + _shorten_text(puzzle.title, 133), make_image(puzzle.id, content), puzzle.id)
Ejemplo n.º 14
0
def build_problem_message(problem):
    content = str(
        render_to_string('problem_weibo.tpl', {
            'template_path': TEMPLATE_ROOT,
            'image': problem.image_url.path
        }))
    if problem.video_url is not None and problem.video_url != '':
        weibo_status = _shorten_text(problem.recommended_reason,
                                     111) + problem.video_url
    else:
        weibo_status = _shorten_text(problem.recommended_reason, 131)
    return WeiboMessage(u'#宅,必有一技# ' + weibo_status,
                        make_image(problem.id, content), problem.id)
Ejemplo n.º 15
0
def build_redier_message(redier):
    content = str(
        render_to_string('redier_weibo.tpl', {
            'template_path': TEMPLATE_ROOT,
            'image': redier.image_url.path
        }))
    if redier.video_url is not None and redier.video_url != '':
        weibo_status = _shorten_text(redier.recommended_reason,
                                     112) + redier.video_url
    else:
        weibo_status = _shorten_text(redier.recommended_reason, 132)
    return WeiboMessage(u'#小兵变大咖# ' + weibo_status,
                        make_image(redier.id, content), redier.id)
Ejemplo n.º 16
0
def build_game_message(game):
    content = str(render_to_string('game_weibo.tpl', {
        'template_path' : TEMPLATE_ROOT,
        }))
    entity = Entity.objects.get(id=game.id)
    if entity.status3 == 2:
        message_link = u'【下载】' + 'http://cow.bestgames7.com/d/%s/' % game.id
    else:
        message_link = ''
    if game.video_url is not None and game.video_url != '':
        weibo_status = _shorten_text(game.recommended_reason, 85) + message_link +' '+ u'【视频】' + game.video_url
    else:
        weibo_status = _shorten_text(game.recommended_reason, 110) + message_link
    return WeiboMessage(u'#游戏推荐# ' + weibo_status, make_image(game.id, content), game.id)
Ejemplo n.º 17
0
def main(args):
    dataset = Dataset(args.data_path, args.offset_x, args.offset_y,
                      args.batch_size, args.batch_per_video)
    optimizer = keras.optimizers.Adam(lr=1e-4)
    model = ConvLSTM(optimizer, args.init_channel, args.block_num)

    if args.train == 'train':
        dataloader = dataset.train_loader()
        train(dataloader, model, args.epochs, args.steps_per_epoch,
              args.save_path)
        utils.save_model(model, args.save_path)
        x, y = next(dataloader)
        pred = model.predict(x)
        utils.make_image(pred, y)

    elif args.train == 'test':
        video_idx = int(input('예측할 동영상 인덱스를 입력하세요.'))
        x, y = dataset.test_loader(video_idx)
        model = utils.load_model(model, args.save_path)
        pred = test(model, x, y, args.batch_size)
        abnormal, score = anomaly_score(pred, y)
        plt.plot(score)
        plt.savefig('anomaly score.png')
        utils.make_video(pred, abnormal)
Ejemplo n.º 18
0
    def mosaic(self, image):
        tiles = slice_image(image, 32)
        num_tiles = tiles.shape[0] * tiles.shape[1]
        flat_tiles = np.stack(tiles).reshape(num_tiles, -1)
        new_tiles = []
        # print(flat_tiles[0])
        for i, tile in enumerate(flat_tiles):
            print(f'tile {i:d} / {num_tiles:d}')
            patch = self.get_patch(tile)
            new_tiles.append(patch.reshape(32, 32, 3))

        # print(new_tiles[0])
        new_tiles = np.stack(new_tiles).reshape(tiles.shape)
        new_image = make_image(new_tiles)
        return new_image
Ejemplo n.º 19
0
def build_puzzle_message(puzzle):
    content = str(
        render_to_string(
            'puzzle_weibo.tpl', {
                'puzzle_id': puzzle.id,
                'template_path': TEMPLATE_ROOT,
                'puzzle_pic': puzzle.image_url.path,
                'puzzle_content': puzzle.description,
                'optiona': puzzle.option1,
                'optionb': puzzle.option2,
                'optionc': puzzle.option3,
                'optiond': puzzle.option4,
            }))

    return WeiboMessage(u'#趣味答题# ' + _shorten_text(puzzle.title, 133),
                        make_image(puzzle.id, content), puzzle.id)
Ejemplo n.º 20
0
def build_news_message(news):
    content_items = {'template_path' : TEMPLATE_ROOT}
    if news.screenshot_path_1:
        content_items['screenshot_path_1'] = news.screenshot_path_1.path
    if news.screenshot_path_2:
        content_items['screenshot_path_2'] = news.screenshot_path_2.path
    if news.screenshot_path_3:
        content_items['screenshot_path_3'] = news.screenshot_path_3.path
    if news.screenshot_path_4:
        content_items['screenshot_path_4'] = news.screenshot_path_4.path
    content = str(render_to_string('news_weibo.tpl', content_items))
    if news.video_url is not None and news.video_url != '':
        weibo_status = _shorten_text(news.recommended_reason, 112) + news.video_url
    else:
        weibo_status = _shorten_text(news.recommended_reason, 132)
    return WeiboMessage(u'#游戏情报站# ' + weibo_status, make_image(news.id, content), news.id)
Ejemplo n.º 21
0
	def __init__ (self):
		
		lst = gtk.ListStore (int, str, str, int, str, gtk.gdk.Pixbuf, str)
		self.col_lst = [_('Id'), _('Data'), _('Vasca'), _('Quantita'), _('Nome'), _("Immagine")]
		
		dbwindow.DBWindow.__init__ (self, 2, 2, self.col_lst,
			[utils.DataButton (), utils.Combo (), utils.IntEntry (), gtk.Entry (), utils.ImgEntry ()], lst)
		
		for y in utils.get ("select * from invertebrati"):
			lst.append([y[0], y[1], y[2], y[3], y[4], utils.make_image(y[5]), y[5]])
		for y in utils.get ("select * from vasca"):
			self.vars[1].append_text (y[3])
		
		self.set_title (_("Invertebrati"))
		self.set_size_request (600, 400)
		self.set_icon_from_file ("pixmaps/logopyacqua.jpg")
Ejemplo n.º 22
0
def build_news_message(news):
    content_items = {'template_path': TEMPLATE_ROOT}
    if news.screenshot_path_1:
        content_items['screenshot_path_1'] = news.screenshot_path_1.path
    if news.screenshot_path_2:
        content_items['screenshot_path_2'] = news.screenshot_path_2.path
    if news.screenshot_path_3:
        content_items['screenshot_path_3'] = news.screenshot_path_3.path
    if news.screenshot_path_4:
        content_items['screenshot_path_4'] = news.screenshot_path_4.path
    content = str(render_to_string('news_weibo.tpl', content_items))
    if news.video_url is not None and news.video_url != '':
        weibo_status = _shorten_text(news.recommended_reason,
                                     112) + news.video_url
    else:
        weibo_status = _shorten_text(news.recommended_reason, 132)
    return WeiboMessage(u'#游戏情报站# ' + weibo_status,
                        make_image(news.id, content), news.id)
Ejemplo n.º 23
0
	def refresh_data (self, islocked):
		if islocked: return
		
		self.store.clear ()
		
		for y in app.App.p_backend.select ("*", "vasca"):
			self.store.append([y[0], y[1], y[2], y[3], y[4],
				y[5], y[6], y[7], y[8], y[9], y[10], y[11], y[12], utils.make_image(y[13]), y[13]])
		
		def unz (txt):
			self.filter_menu.append (gtk.CheckMenuItem (txt))
		
		unz (_("Dolce"))
		unz (_("Dolce Tropicale"))
		unz (_("Marino"))
		unz (_("Marino Mediterraneo"))
		unz (_("Paludario"))
		unz (_("Salmastro"))
Ejemplo n.º 24
0
def main():

    # if no command line argument is give, use 10,000 shots
    if (len(sys.argv) == 1):
        num_shots = 10000
    else:
        num_shots = int(sys.argv[1])

    image = utils.get_image()
    size = len(image)

    angles = []
    # convert all rgb pixel values into angles in [0, pi/2]
    for i in range(size):
        for j in range(size):
            angles.append((utils.rgb_to_theta(image[i][j])))

    new_angles = frqi_cirq.run(angles, num_shots)

    im = []
    i = 0
    # converting all the recovered angles, back into rgb values
    for ang in new_angles:

        rgb = utils.theta_to_rgb(ang)
        if (i % 2 == 0):
            row = []

        row.append(rgb)

        if (i % 2 != 0):
            im.append(row)

        i += 1

    # make an image using the recovered RGB values
    new_image = utils.make_image(im)

    # double the size of the image 7 times, so that it is larger enough to actually see what the colors are
    for i in range(7):
        new_image = utils.double_size(new_image)

    utils.show_image(new_image)
Ejemplo n.º 25
0
def build_evaluation_message(evaluation):
    content = str(render_to_string('evaluation_weibo.tpl', {
        'template_path': TEMPLATE_ROOT,
        'title': evaluation.title,
        'icon': evaluation.icon.path,
        'rating': evaluation.rating,
        'comment': evaluation.brief_comment,
        'content': evaluation.content,
        'android': evaluation.android_download_url,
        'ios': evaluation.iOS_download_url,
        }))
    entity = Entity.objects.get(id=evaluation.id)   
    if entity.status3 == 2:
        message_link = u'【下载】' + 'http://cow.bestgames7.com/d/%s/' % evaluation.id
    else:
        message_link = ''  
    weibo_status = _shorten_text(evaluation.recommended_reason, 110) + message_link

    return WeiboMessage(u'#游戏测评# '+weibo_status, make_image(evaluation.id, content), evaluation.id)
Ejemplo n.º 26
0
	def refresh_data (self, islocked):
		if islocked: return
		
		self.main_db.store.clear ()
		self.main_db.vars[0].clear_all ()
		
		if self.main_db.filter_menu:
			tmp = self.main_db.filter_menu
			self.main_db.filter_menu = gtk.Menu ()
			del tmp
		else:
			self.main_db.filter_menu = gtk.Menu ()
		
		for y in app.App.p_backend.select ("*", "vasca"):
			self.main_db.vars[0].append_text (y[3])
			self.main_db.filter_menu.append (gtk.CheckMenuItem (y[3]))
			
		for y in app.App.p_backend.select ("*", "spesa"):
			self.main_db.store.append ([y[0], y[1], y[2], y[3], y[4], y[5], y[6], y[7], utils.make_image(y[8]), y[8]])
Ejemplo n.º 27
0
	def __init__ (self):
		
		lst = gtk.ListStore (int, str, str, str, str, str, str, gtk.gdk.Pixbuf, str)
		self.col_lst = [_('Id'), _('Data'), _('Vasca'), _('Tipologia'), _('Quantita'), _('Nome'), _('Soldi'), _("Immagine")]
		
		dbwindow.DBWindow.__init__ (self, 2, 4, self.col_lst,
			[utils.DataButton (), utils.Combo (), utils.Combo (),
			 utils.IntEntry (), gtk.Entry (), gtk.Entry (), utils.ImgEntry ()], lst)
		
		for y in utils.get ("select * from spese"):
			lst.append([y[0], y[1], y[2], y[3], y[4], y[5], y[6], utils.make_image(y[7]), y[7]])
		for y in utils.get ("select * from vasca"):
			self.vars[1].append_text (y[3])
		for y in [_("Vasca"), _("Pesce"), _("Pianta"), _("Invertebrato"), _("Fertilizzante"), _("Filtro"), _("Varie")]:
			self.vars[2].append_text (y)
		
		self.set_title (_("Spese"))
		self.set_size_request (600, 400)
		self.set_icon_from_file ("pixmaps/logopyacqua.jpg")
Ejemplo n.º 28
0
def build_game_message(game):
    content = str(
        render_to_string('game_weibo.tpl', {
            'template_path': TEMPLATE_ROOT,
        }))
    entity = Entity.objects.get(id=game.id)
    if entity.status3 == 2:
        message_link = u'【下载】' + 'http://cow.bestgames7.com/d/%s/' % game.id
    else:
        message_link = ''
    if game.video_url is not None and game.video_url != '':
        weibo_status = _shorten_text(
            game.recommended_reason,
            85) + message_link + ' ' + u'【视频】' + game.video_url
    else:
        weibo_status = _shorten_text(game.recommended_reason,
                                     110) + message_link
    return WeiboMessage(u'#游戏推荐# ' + weibo_status,
                        make_image(game.id, content), game.id)
Ejemplo n.º 29
0
def build_evaluation_message(evaluation):
    content = str(
        render_to_string(
            'evaluation_weibo.tpl', {
                'template_path': TEMPLATE_ROOT,
                'title': evaluation.title,
                'icon': evaluation.icon.path,
                'rating': evaluation.rating,
                'comment': evaluation.brief_comment,
                'content': evaluation.content,
                'android': evaluation.android_download_url,
                'ios': evaluation.iOS_download_url,
            }))
    entity = Entity.objects.get(id=evaluation.id)
    if entity.status3 == 2:
        message_link = u'【下载】' + 'http://cow.bestgames7.com/d/%s/' % evaluation.id
    else:
        message_link = ''
    weibo_status = _shorten_text(evaluation.recommended_reason,
                                 110) + message_link

    return WeiboMessage(u'#游戏测评# ' + weibo_status,
                        make_image(evaluation.id, content), evaluation.id)
def training_detached(hp: HParams):
    model = SketchAAE(hp)

    writer = SummaryWriter() if hp.tensorboard else None
    inner_lf = 1
    epoch = 0
    while epoch < 10000 and not hp.fast_debug:
        inner_loss, inner_lf, inner_lc, inner_ls = model.train_inner(train=True)
        print("epoch",epoch,"inner_lf",inner_lf,"inner_lc",inner_lc,"inner_ls",inner_ls,"inner_loss",inner_loss)
        model.lr_decay(inner=True)
        if epoch%1000==0:
            vis_inner(hp, model, writer, epoch)
        # if epoch%5==0:
        #     writer.add_scalar("inner/inner_loss", inner_loss, epoch)
        #     writer.add_scalar("inner/inner_hist", inner_hist, epoch)
        if (inner_lc > 30) and inner_lf < 0.1:
            print("resetting")
            model = SketchAAE(hp)
        epoch += 1

    ds = ComboDataset(hp, model.device)
    ds.CacheToSharedMemory()
    model.Nmax = ds.Nmax


    epoch = 0
    loop_active = True
    old_buckets = None
    while loop_active:
        dl = DataLoader(ds, hp.batch_size, shuffle=True)
        for	_, batch_sample in enumerate(dl):
            epoch += 1

            batch, lengths, _,  = batch_sample
            batch = batch.transpose(0,1)

            r_loss, r_ls, r_lp, r_map = model.train_reconstruction(batch, lengths)
            model.lr_decay(outer=True)

            print("epoch",epoch,"r_loss",r_loss,"r_ls",r_ls,"r_lp",r_lp,"r_map",r_map)

            if hp.tensorboard and epoch%10==0:
                writer.add_scalar("l/r_loss", r_loss, epoch)
                writer.add_scalar("recon/r_ls", r_ls, epoch)
                writer.add_scalar("recon/r_lp", r_lp, epoch)
                writer.add_scalar("recon/r_lp", r_map, epoch)
            
            if hp.tensorboard and epoch%250==0 or hp.fast_debug:
                sketch, length = batch.transpose(0,1)[0].detach(), lengths[0].detach()
                writer.add_figure(tag='Original', figure=make_image(sketch.cpu().numpy()), global_step=epoch)
                writer.add_figure(tag='Generated', figure=make_image3(model.conditional_generation(sketch, length, ds.Nmax)), global_step=epoch)

            if hp.tensorboard and ((epoch%1000==0 and epoch < 10000) or epoch%2000==0 or hp.fast_debug):
                old_buckets = visualize_movement(hp, ds, writer, model, epoch, old_buckets)
                for cat in range(model.hp.cat_dims):
                    tag_name = "CatGen/"+str(cat)+"cat"
                    seqs = writer.add_figure(tag=tag_name, figure=make_image3(model.generation_for_category(cat)), global_step=epoch)

            if epoch >= hp.max_epochs:
                loop_active = False
                break

        gc.collect()
Ejemplo n.º 31
0
def build_collection_message(collection):
    games = []
    for game in collection.games.all():
        games.append({
            'screenshot_path_1' : game.screenshot_path_1.path,
            'name' : game.name,
            'icon' : game.icon.path,
            'rating' : game.rating,
            'size' : game.size,
            'category' : game.category.name,
            'brief_comment' : game.brief_comment,
            'recommended_reason' : game.recommended_reason
            })
    content = str(render_to_string('collection_weibo.tpl', {
        'template_path' : TEMPLATE_ROOT,
        'games' : games,
        'cover' : collection.cover.path,
        'title' : collection.title
        }))
    entity = Entity.objects.get(id=collection.id)
    if entity.status3 == 2:
        message_link = u'【下载】' + 'http://cow.bestgames7.com/d/%s/' % collection.id
    else:
        message_link = ''
    return WeiboMessage(u'#游戏合集# ' + _shorten_text(collection.recommended_reason, 110) + message_link, make_image(collection.id, content), collection.id)
Ejemplo n.º 32
0
from ImageSetViewField import ImageSetViewField

from utils import make_image

VIBE_IMAGES = {
    "hf": make_image("vibe_hfsine"),
    "sawtooth": make_image("vibe_saw"),
    "sine": make_image("vibe_sine"),
    "square": make_image("vibe_square"),
}


class VibeTypeViewField(ImageSetViewField):
    def __init__(self, parent):
        ImageSetViewField.__init__(self, parent, lambda instr: instr.vibrato.type, VIBE_IMAGES)
Ejemplo n.º 33
0
from ImageSetViewField import ImageSetViewField

from viewutils import instr_attr

from utils import make_image

WAVE_IMAGES = {
    "12.5%": make_image("wave12"),
    "25%": make_image("wave25"),
    "50%": make_image("wave50"),
    "75%": make_image("wave75")
}


class WaveViewField(ImageSetViewField):

    def __init__(self, parent):
        ImageSetViewField.__init__(
            self, parent, instr_attr("wave"), WAVE_IMAGES)
Ejemplo n.º 34
0
import wx

import channels

from utils import make_image

from ImageSetViewField import ImageSetViewField
from ReadOnlyTextViewField import ReadOnlyTextViewField
from viewutils import instr_attr, one_digit_hex_format, two_digit_hex_format, \
    within

WAVE_IMAGES = {
    "sawtooth": make_image("synth_saw"),
    "square": make_image("synth_square"),
    "sine": make_image("synth_sine")
}


def add_field(parent, label_text, control, sizer):
    label = wx.StaticText(parent, label=label_text)

    sizer.Add(label, 0, wx.ALL)

    control.subscribe(parent.synth_change_channel)

    control.add_to_sizer(sizer, 0, wx.ALL)


class RangeFieldsSubPanel(wx.Panel):

    def __init__(self, parent, range_param):