Git Product home page Git Product logo

Comments (2)

PrashanthaTP avatar PrashanthaTP commented on May 27, 2024

To avoid memory overflow without removing batching support, we can try to feed part of batch instead of whole batch , to generator and id disc models.

from wav2mov.

PrashanthaTP avatar PrashanthaTP commented on May 27, 2024

Fix 92e8d0d <== 4aad11f

  • Also making generator forward passes with chunks of frames rather than whole batch (iterating over batch and taking fraction of frames from each video)

wav2mov/models/wav2mov.py

Lines 158 to 163 in 92e8d0d

for sub_batch in self.__get_sub_batch(fraction=2):
self.model.set_input(sub_batch)
loss_id = self.model.optimize_id()
for name,(loss,n) in loss_id.items():
prev_loss,prev_n = losses.get(name,(0.0,0))
loss_id[name] = (prev_loss+loss,prev_n+n)

  • Regenerating fake frames for adversarial training with sync discriminator rather than retaining the computational graph after adversarial pass with identity discriminator

wav2mov/models/wav2mov.py

Lines 123 to 150 in 92e8d0d

def __get_sub_batch(self,fraction=2):
"""creates and yields subbatches of (1/fraction) of num_frames
Args:
fraction (int, optional): the denominator of the fraction of frames per subbatch. Defaults to 2.
Yields:
sub_batch
"""
num_frames = self.video.shape[1]
start_fraction = 0
for i in range(fraction):
end_fraction = int((1/fraction)*(i+1)*num_frames) if i!=fraction-1 else num_frames
batch = {}
# self.logger.debug(f'inside sub batching with fraction {fraction} of {num_frames} frames| {start_fraction} : {end_fraction}')
real_video_frames = self.video[:,start_fraction:end_fraction,:,:,:]
batch['real_video_frames'] = self.squeeze_frames(real_video_frames)
ref_video_frames = self.get_ref_frames(real_video_frames)
batch['ref_video_frames'] = self.squeeze_frames(ref_video_frames)
audio_frames = self.audio_frames[:,start_fraction:end_fraction,:]
audio_frames = self.squeeze_frames(audio_frames)
batch['fake_video_frames'] = self(audio_frames,batch['ref_video_frames'])
self.add_fake_frames(batch['fake_video_frames'],target_shape=batch['real_video_frames'].shape)
start_fraction = end_fraction
yield batch

from wav2mov.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.