예제 #1
0
 def save_model_bundle(self):
     model_bundle_dir = join(self.tmp_dir, 'model-bundle')
     make_dir(model_bundle_dir)
     shutil.copyfile(self.last_model_path,
                     join(model_bundle_dir, 'model.pth'))
     shutil.copyfile(self.config_path, join(model_bundle_dir,
                                            'config.json'))
     zipdir(model_bundle_dir, self.model_bundle_path)
예제 #2
0
파일: zip.py 프로젝트: carderne/opencities
 def run(self):
     experiment_id = self.command_config.get("experiment_id")
     root_uri = self.command_config.get("root_uri")
     tmp_dir = "/opt/data/tmp/"
     os.makedirs(tmp_dir)
     print("made tmp_dir")
     s3_command = (
         f"aws s3 sync s3://carderne-rv/postprocess/{experiment_id}/ {tmp_dir}"
     )
     call(s3_command, shell=True)
     print("downloaded files")
     zip_file = f"/opt/data/zipped.zip"
     zipdir(tmp_dir, zip_file)
     print("zipped")
     upload_or_copy(zip_file, join(root_uri, "final",
                                   f"{experiment_id}.zip"))
     print("uploaded")
예제 #3
0
    def _make_debug_chips(split):
        debug_chips_dir = join(tmp_dir, '{}-debug-chips'.format(split))
        zip_path = join(tmp_dir, '{}-debug-chips.zip'.format(split))
        zip_uri = join(train_uri, '{}-debug-chips.zip'.format(split))
        make_dir(debug_chips_dir)
        ds = databunch.train_ds if split == 'train' else databunch.valid_ds
        for i, (x, y) in enumerate(ds):
            if i >= max_count:
                break

            fig, ax = plt.subplots(1)
            plot_xy(ax, x, class_map, y=y)
            plt.savefig(join(debug_chips_dir, '{}.png'.format(i)),
                        figsize=(6, 6))
            plt.close()

        zipdir(debug_chips_dir, zip_path)
        upload_or_copy(zip_path, zip_uri)