Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
iperov
GitHub Repository: iperov/deepfacelab
Path: blob/master/samplelib/SampleGeneratorBase.py
628 views
1
from pathlib import Path
2
3
'''
4
You can implement your own SampleGenerator
5
'''
6
class SampleGeneratorBase(object):
7
8
9
def __init__ (self, debug=False, batch_size=1):
10
self.debug = debug
11
self.batch_size = 1 if self.debug else batch_size
12
self.last_generation = None
13
self.active = True
14
15
def set_active(self, is_active):
16
self.active = is_active
17
18
def generate_next(self):
19
if not self.active and self.last_generation is not None:
20
return self.last_generation
21
self.last_generation = next(self)
22
return self.last_generation
23
24
#overridable
25
def __iter__(self):
26
#implement your own iterator
27
return self
28
29
def __next__(self):
30
#implement your own iterator
31
return None
32
33
#overridable
34
def is_initialized(self):
35
return True
36