Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/brownvc/deep-synth
31 March 2020, 06:46:23 UTC
  • Code
  • Branches (1)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/master
    No releases to show
  • 291f7df
  • /
  • deep-synth
  • /
  • continue_dataset.py
Raw File Download
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
origin badgecontent badge
swh:1:cnt:f4861f2c74fb12672dadca529b9f792277a8e65d
origin badgedirectory badge
swh:1:dir:87b9fce6556ee1dd9155a27d000889cbaac88195
origin badgerevision badge
swh:1:rev:b800e11290b763b58e7d3b30329769a7b77cd12a
origin badgesnapshot badge
swh:1:snp:0f10b5007a9962ed82323ed2242cf08ba5544645

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: b800e11290b763b58e7d3b30329769a7b77cd12a authored by kwang-ether on 14 June 2019, 23:53:57 UTC
remove csv
Tip revision: b800e11
continue_dataset.py
from torch.utils import data
from data import ObjectCategories, RenderedScene, RenderedComposite
import random
import math
import torch

import _pickle as pickle

class ShouldContinueDataset():
    """
    Dataset for training/testing the "should continue" network
    """
    def __init__(self, data_root_dir, data_dir, scene_indices=(0,4000), num_per_epoch=1, complete_prob=0.5, seed=None, ablation=None):
        """
        Parameters
        ----------
        data_root_dir (String): root dir where all data lives
        data_dir (String): directory where this dataset lives (relative to data_root_dir)
        scene_indices (tuple[int, int]): list of indices of scenes (in data_dir) that are considered part of this set
        num_per_epoch (int): number of random variants of each scene that will be used per training epoch
        complete_prob (float): probability of sampling the complete scene, as opposed to some incomplete variant of it
        """
        self.data_root_dir = data_root_dir
        #self.data_dir = data_root_dir + '/' + data_dir
        self.data_dir = data_dir
        self.scene_indices = scene_indices
        self.num_per_epoch = num_per_epoch
        self.complete_prob = complete_prob

        # Load up the map between SUNCG model IDs and category names
        #self.category_map = ObjectCategories(data_root_dir + '/suncg_data/ModelCategoryMapping.csv')
        # Also load up the list of coarse categories used in this particular dataset
        #self.categories = self.get_coarse_categories()
        # Build a reverse map from category to index
        #self.cat_to_index = {self.categories[i]:i for i in range(len(self.categories))}
        self.seed = seed
        self.ablation = ablation

    def __len__(self):
        return (self.scene_indices[1]-self.scene_indices[0]) * self.num_per_epoch

    def __getitem__(self, index):
        if self.seed:
            random.seed(self.seed)

        i = int(index+self.scene_indices[0] / self.num_per_epoch)
        scene = RenderedScene(i, self.data_dir, self.data_root_dir)
        composite = scene.create_composite()

        num_categories = len(scene.categories)
        existing_categories = torch.zeros(num_categories)
        # Flip a coin for whether we're going remove objects or treat this as a complete scene
        is_complete = random.random() < self.complete_prob
        if not is_complete:
            # If we decide to remove objects, then remove a random number of them
            num_objects = random.randint(0, len(scene.object_nodes) - 1)
        else:
            num_objects = len(scene.object_nodes)

        for i in range(num_objects):
            node = scene.object_nodes[i]
            composite.add_node(node)
            existing_categories[node["category"]] += 1

        inputs = composite.get_composite(num_extra_channels=0, ablation=self.ablation)
        # Output is a boolean for "should we continue adding objects?"
        output = not is_complete
        return inputs, output, existing_categories

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API