コード例 #1
0
    def __init__(self, args):
        self.tpu = False
        if args.device == 'cpu':
            self.device = 'cpu'
        elif args.device == 'gpu':
            self.device = 'cuda:0'
        elif args.device == 'tpu':
            self.device = xm.xla_device()
            self.tpu = True
        else:
            exit(0)

        #torch.manual_seed(777)

        self.save_dir = args.save_dir
        self.start_epoch = 0
        self.summary_write = args.summary_write
        self.save_model = args.save_model
        self.end_epoch = args.end_epoch

        folder([
            self.save_dir, self.save_dir + '/models', self.save_dir + '/runs'
        ])

        self.summary = SummaryWriter(
            self.save_dir + '/runs/' +
            datetime.now(timezone).strftime("%Y-%m-%d-%H%M"))

        self.dataset_train = DiabetesDataset_CNN(train=True)
        self.dataset_test = DiabetesDataset_CNN(train=False)
        self.train_loader = DataLoader(dataset=self.dataset_train,
                                       batch_size=32,
                                       shuffle=True,
                                       num_workers=0)
        self.evaluate_loader = DataLoader(dataset=self.dataset_test,
                                          batch_size=32,
                                          shuffle=False,
                                          num_workers=0)

        self.model = CNN()

        self.model = self.model.to(self.device)

        if args.resume is not None:
            self.load_checkpoint()

        self.criterion = nn.CrossEntropyLoss().to(self.device)
        self.optimizer = torch.optim.Adam(self.model.parameters(), lr=0.001)
コード例 #2
0
    def __init__(self, fileName, addon):

        folderPath = utils.folder()

	self.addon = addon
	self.filePath = os.path.join(self.basePath, fileName)

	if fileName == utils.get_setting(addon_id,'xmltv.url'):		
		self.fileUrl = fileName
		self.fileName = fileName.split('/')[-1]
		self.filePath = os.path.join(self.basePath, 'custom.xml')
		
	elif fileName == utils.get_setting(addon_id,'xmltv.url') and fileName.endswith(".zip"):		
		self.fileUrl = fileName
		self.fileName = fileName.split('/')[-1]
		self.filePath = os.path.join(self.basePath, 'custom.xml')
		
	elif fileName == utils.get_setting(addon_id,'sub.xmltv.url'):		
		self.fileUrl = fileName
		self.fileName = fileName.split('/')[-1]
		self.filePath = os.path.join(self.basePath, utils.get_setting(addon_id,'sub.xmltv')+'.xml')
		
	else:
		self.fileUrl = folderPath + fileName.replace('.xml', '.zip')
        # make sure the folder is actually there already!
        if not os.path.exists(self.basePath):
            os.makedirs(self.basePath)
コード例 #3
0
def main(args):
    matrices_path = glob.glob(utils.folder(args.matrices_folder) + "*.txt")
    output_file = args.output_file
    ids_path = None
    if args.ids_path:
        ids_path = utils.folder(args.ids_path)

    c = Corpus(matrices_path, args.target, ids_path)

    if args.output_folder:
        output_folder = utils.folder(args.output_folder)
        c.write_invidual_files(output_folder)

    #c.write_summary(output_file + ".summary")
    #c.write_buckets(output_file + ".classes")
    #c.write_buckets(output_file + ".classes.verbose", verbose=True)
    if ids_path:
        c.write_zrc_buckets(utils.folder(args.segmentation_path),
                            utils.folder(args.labs_path), output_file, BUCKETS)
コード例 #4
0
ファイル: config.py プロジェクト: helloman37/repo
import shutil
import utils
import xbmcvfs

addon_id = 'script.ivueguide'
addon_name = xbmcaddon.Addon(addon_id)
HOME = addon_name.getAddonInfo('path')
ICON = os.path.join(HOME, 'icon.png')
PACKAGES = xbmc.translatePath(
    os.path.join('special://home', 'addons', 'packages'))
TEMP = addon_name.getSetting('tempskin')
USER_AGENT = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3'

#Karls changes

ivue = utils.folder()
d = xbmcgui.Dialog()
dp = xbmcgui.DialogProgress()
skin = addon_name.getSetting('skin')
path = xbmc.translatePath(
    os.path.join('special://profile', 'addon_data', 'script.ivueguide',
                 'resources', 'skins'))
Skinxml = xbmc.translatePath(
    os.path.join(path, skin, '720p', 'script-tvguide-main.xml'))
xmlData = xbmc.translatePath(
    'special://profile/addon_data/script.ivueguide/resources/config/Data.txt')
logoData = xbmc.translatePath(
    'special://profile/addon_data/script.ivueguide/resources/config/Logo.txt')
catData = xbmc.translatePath(
    'special://profile/addon_data/script.ivueguide/resources/categories/')
ivue = utils.folder()