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/ChrisWu1997/2D-Motion-Retargeting
14 May 2026, 11:01:37 UTC
  • Code
  • Branches (3)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/dependabot/pip/numpy-1.22.0
    • refs/heads/dependabot/pip/opencv-python-4.2.0.32
    • refs/heads/master
    No releases to show
  • 637d1ac
  • /
  • dataset
  • /
  • datasets.py
Raw File Download Save again
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:66c76fd0247f019177b18d02ab9ef5af9d1fdfb7
origin badgedirectory badge
swh:1:dir:bf85e6096e7aacbdac133accbe3b16d9b8cc89e9
origin badgerevision badge
swh:1:rev:f3454a1972a98b3a572f83c1c9ea0b0e5d9e7d00
origin badgesnapshot badge
swh:1:snp:731706168a0a29b22cb97c2f8a1809d2c7d69079

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
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
Tip revision: f3454a1972a98b3a572f83c1c9ea0b0e5d9e7d00 authored by Rundi Wu on 28 December 2020, 02:08:07 UTC
Update README.md
Tip revision: f3454a1
datasets.py
from dataset.base_dataset import _MixamoDatasetBase
import numpy as np
from copy import copy
import torch


class MixamoDatasetForSkeleton(_MixamoDatasetBase):
    def __init__(self, phase, config):
        super(MixamoDatasetForSkeleton, self).__init__(phase, config)

    def __getitem__(self, index):
        # select two motions
        idx1, idx2 = np.random.choice(len(self.motion_names), size=2, replace=False)
        mot1, mot2 = self.motion_names[idx1], self.motion_names[idx2]
        # select two characters
        idx1, idx2 = np.random.choice(len(self.character_names), size=2, replace=False)
        char1, char2 = self.character_names[idx1], self.character_names[idx2]

        if self.aug:
            param1 = self.gen_aug_param(rotate=True)
            param2 = self.gen_aug_param(rotate=True)
            param12 = copy(param1)
            param21 = copy(param2)
            param12['ratio'] = param2['ratio']
            param21['ratio'] = param1['ratio']
        else:
            param1 = param2 = param12 = param21 = None

        item1 = self.build_item(mot1, char1)
        item2 = self.build_item(mot2, char2)
        item12 = self.build_item(mot1, char2)
        item21 = self.build_item(mot2, char1)

        input1 = self.preprocessing(item1, param=param1)
        input2 = self.preprocessing(item2, param=param2)
        target1 = input1.detach().clone()
        target2 = input2.detach().clone()

        input12 = self.preprocessing(item12, param=param12)
        input21 = self.preprocessing(item21, param=param21)
        target12 = input12.detach().clone()
        target21 = input21.detach().clone()

        return {"input1": input1, "target1": target1,
                "input2": input2, "target2": target2,
                "input12": input12, "target12": target12,
                "input21": input21, "target21": target21,
                "mot1": mot1, "mot2": mot2,
                "char1": char1, "char2": char2}


class MixamoDatasetForView(_MixamoDatasetBase):
    def __init__(self, phase, config):
        super(MixamoDatasetForView, self).__init__(phase, config)

    def __getitem__(self, index):
        # select two motions
        idx1, idx2 = np.random.choice(len(self.motion_names), size=2, replace=False)
        mot1, mot2 = self.motion_names[idx1], self.motion_names[idx2]
        # select two characters
        idx1, idx2 = np.random.choice(len(self.character_names), size=2)
        char1, char2 = self.character_names[idx1], self.character_names[idx2]
        # select two views
        idx1, idx2 = np.random.choice(len(self.view_angles), size=2, replace=False)
        view1, view2 = self.view_angles[idx1], self.view_angles[idx2]

        item1 = self.build_item(mot1, char1)
        item2 = self.build_item(mot2, char2)
        item12= self.build_item(mot1, char2)
        item21 = self.build_item(mot2, char1)

        if self.aug:
            param1 = self.gen_aug_param(rotate=False)   # FIXME: [np.random.uniform(0.5, 1.5)]
            param2 = self.gen_aug_param(rotate=False)
            param12 = param2
            param21 = param1
        else:
            param1 = param2 = param12 = param21 = None

        input1 = self.preprocessing(item1, view1, param1)
        input2 = self.preprocessing(item2, view2, param2)
        target1 = input1.detach().clone()
        target2 = input2.detach().clone()

        input12 = self.preprocessing(item12, view2, param12)
        input21 = self.preprocessing(item21, view1, param21)
        target12 = input12.detach().clone()
        target21 = input21.detach().clone()

        return {"input1": input1, "target1": target1,
                "input2": input2, "target2": target2,
                "input12": input12, "target12": target12,
                "input21": input21, "target21": target21,
                "mot1": mot1, "mot2": mot2,
                "view1": view1, "view2": view2,
                "char1": char1, "char2": char2}


class MixamoDatasetForFull(_MixamoDatasetBase):
    def __init__(self, phase, config):
        super(MixamoDatasetForFull, self).__init__(phase, config)

    def get_cluster_data(self, nr_motions=50):
        """
        get a certain subset data for clustering visualization and scoring
        :param nr_anims:
        :return: pre-processed data of shape (nr_views, nr_anims, 30, 64)
        """
        motion_items = self.motion_names
        if nr_motions < len(self.motion_names):
            idxes = np.linspace(0, len(self.motion_names) - 1, nr_motions, dtype=int)
            motion_items = [self.motion_names[i] for i in idxes]
        motion_names = np.array([item[0] for item in motion_items])

        all_data = []
        for mot in motion_items:
            char_data = []
            for char in self.character_names:
                item = self.build_item(mot, char)
                view_data = []
                for view in self.view_angles:
                    data = self.preprocessing(item, view, None)
                    view_data.append(data)
                char_data.append(torch.stack(view_data, dim=0))
            all_data.append(torch.stack(char_data, dim=0))
        all_data = torch.stack(all_data, dim=0)

        ret = (all_data, motion_names, self.character_names, np.rad2deg(self.view_angles))
        return ret

    def __getitem__(self, index):
        # select two motions
        idx1, idx2 = np.random.choice(len(self.motion_names), size=2, replace=False)
        mot1, mot2 = self.motion_names[idx1], self.motion_names[idx2]
        # select two characters
        idx1, idx2 = np.random.choice(len(self.character_names), size=2, replace=False)
        char1, char2 = self.character_names[idx1], self.character_names[idx2]
        # select two views
        idx1, idx2 = np.random.choice(len(self.view_angles), size=2, replace=False)
        view1, view2 = self.view_angles[idx1], self.view_angles[idx2]

        item1 = self.build_item(mot1, char1)
        item2 = self.build_item(mot2, char2)
        item12= self.build_item(mot1, char2)
        item21 = self.build_item(mot2, char1)

        if self.aug:
            param1 = self.gen_aug_param(rotate=False)
            param2 = self.gen_aug_param(rotate=False)
        else:
            param1 = param2 = None

        input1 = self.preprocessing(item1, view1, param1)
        input2 = self.preprocessing(item2, view2, param2)
        target1 = input1.detach().clone()
        target2 = input2.detach().clone()

        input112 = self.preprocessing(item1, view2, param1)
        input121 = self.preprocessing(item12, view1, param2)
        input122 = self.preprocessing(item12, view2, param2)
        input221 = self.preprocessing(item2, view1, param2)
        input212 = self.preprocessing(item21, view2, param1)
        input211 = self.preprocessing(item21, view1, param1)
        target112 = input112.detach().clone()
        target121 = input121.detach().clone()
        target122 = input122.detach().clone()
        target221 = input221.detach().clone()
        target212 = input212.detach().clone()
        target211 = input211.detach().clone()

        return {"input1": input1, "target111": target1,
                "input2": input2, "target222": target2,
                "input112": input112, "target112": target112,
                "input121": input121, "target121": target121,
                "input122": input122, "target122": target122,
                "input221": input221, "target221": target221,
                "input212": input212, "target212": target212,
                "input211": input211, "target211": target211,
                "mot1": mot1, "mot2": mot2,
                "view1": view1, "view2": view2,
                "char1": char1, "char2": char2}

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