-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:7eu7d7/HCP-Diffusion into main
- Loading branch information
Showing
11 changed files
with
104 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
_base_: [cfgs/train/train_base.yaml] | ||
|
||
logger: | ||
- | ||
_target_: hcpdiff.loggers.CLILogger | ||
_partial_: True | ||
out_path: 'train.log' | ||
log_step: 20 | ||
- _target_: hcpdiff.loggers.TBLogger | ||
_partial_: True | ||
out_path: 'tblog/' | ||
log_step: 5 | ||
- _target_: hcpdiff.loggers.WanDBLogger | ||
_partial_: True | ||
log_step: 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import json | ||
import os | ||
import glob | ||
import yaml | ||
|
||
class BaseCaptionLoader: | ||
def __init__(self, path): | ||
self.path = path | ||
|
||
def load(self): | ||
raise NotImplementedError() | ||
|
||
class JsonCaptionLoader(BaseCaptionLoader): | ||
def load(self): | ||
with open(self.path, 'r', encoding='utf-8') as f: | ||
return json.loads(f.read()) | ||
|
||
class YamlCaptionLoader(BaseCaptionLoader): | ||
def load(self): | ||
with open(self.path, 'r', encoding='utf-8') as f: | ||
return yaml.load(f.read(), Loader=yaml.FullLoader) | ||
|
||
class TXTCaptionLoader(BaseCaptionLoader): | ||
def load(self): | ||
txt_files = os.listdir(self.path) | ||
captions = {} | ||
for file in txt_files: | ||
with open(os.path.join(self.path, file), 'r', encoding='utf-8') as f: | ||
captions[file] = f.read().strip() | ||
return captions | ||
|
||
def auto_caption_loader(path): | ||
if len(glob.glob('*.json'))>0: | ||
return JsonCaptionLoader(path) | ||
elif len(glob.glob('*.yaml'))>0: | ||
return YamlCaptionLoader(path) | ||
elif len(glob.glob('*.txt'))>0: | ||
return TXTCaptionLoader(path) | ||
else: | ||
raise FileNotFoundError('Caption file not found') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters