Spaces:
Runtime error
Runtime error
Bill Ton Hoang Nguyen
commited on
Commit
•
a804bc5
1
Parent(s):
bd15cb5
OK
Browse files- .DS_Store +0 -0
- config.py +72 -0
- models/.DS_Store +0 -0
- models/stylegan2/.DS_Store +0 -0
- models/stylegan2/stylegan2-pytorch +0 -1
.DS_Store
CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
|
|
config.py
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright 2020 Erik Härkönen. All rights reserved.
|
2 |
+
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
3 |
+
# you may not use this file except in compliance with the License. You may obtain a copy
|
4 |
+
# of the License at http://www.apache.org/licenses/LICENSE-2.0
|
5 |
+
|
6 |
+
# Unless required by applicable law or agreed to in writing, software distributed under
|
7 |
+
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
8 |
+
# OF ANY KIND, either express or implied. See the License for the specific language
|
9 |
+
# governing permissions and limitations under the License.
|
10 |
+
|
11 |
+
import sys
|
12 |
+
import argparse
|
13 |
+
import json
|
14 |
+
from copy import deepcopy
|
15 |
+
|
16 |
+
class Config:
|
17 |
+
def __init__(self, **kwargs):
|
18 |
+
self.from_args([]) # set all defaults
|
19 |
+
self.default_args = deepcopy(self.__dict__)
|
20 |
+
self.from_dict(kwargs) # override
|
21 |
+
|
22 |
+
def __str__(self):
|
23 |
+
custom = {}
|
24 |
+
default = {}
|
25 |
+
|
26 |
+
# Find non-default arguments
|
27 |
+
for k, v in self.__dict__.items():
|
28 |
+
if k == 'default_args':
|
29 |
+
continue
|
30 |
+
|
31 |
+
in_default = k in self.default_args
|
32 |
+
same_value = self.default_args.get(k) == v
|
33 |
+
|
34 |
+
if in_default and same_value:
|
35 |
+
default[k] = v
|
36 |
+
else:
|
37 |
+
custom[k] = v
|
38 |
+
|
39 |
+
config = {
|
40 |
+
'custom': custom,
|
41 |
+
'default': default
|
42 |
+
}
|
43 |
+
|
44 |
+
return json.dumps(config, indent=4)
|
45 |
+
|
46 |
+
def __repr__(self):
|
47 |
+
return self.__str__()
|
48 |
+
|
49 |
+
def from_dict(self, dictionary):
|
50 |
+
for k, v in dictionary.items():
|
51 |
+
setattr(self, k, v)
|
52 |
+
return self
|
53 |
+
|
54 |
+
def from_args(self, args=sys.argv[1:]):
|
55 |
+
parser = argparse.ArgumentParser(description='GAN component analysis config')
|
56 |
+
parser.add_argument('--model', dest='model', type=str, default='StyleGAN', help='The network to analyze') # StyleGAN, DCGAN, ProGAN, BigGAN-XYZ
|
57 |
+
parser.add_argument('--layer', dest='layer', type=str, default='g_mapping', help='The layer to analyze')
|
58 |
+
parser.add_argument('--class', dest='output_class', type=str, default=None, help='Output class to generate (BigGAN: Imagenet, ProGAN: LSUN)')
|
59 |
+
parser.add_argument('--est', dest='estimator', type=str, default='ipca', help='The algorithm to use [pca, fbpca, cupca, spca, ica]')
|
60 |
+
parser.add_argument('--sparsity', type=float, default=1.0, help='Sparsity parameter of SPCA')
|
61 |
+
parser.add_argument('--video', dest='make_video', action='store_true', help='Generate output videos (MP4s)')
|
62 |
+
parser.add_argument('--batch', dest='batch_mode', action='store_true', help="Don't open windows, instead save results to file")
|
63 |
+
parser.add_argument('-b', dest='batch_size', type=int, default=None, help='Minibatch size, leave empty for automatic detection')
|
64 |
+
parser.add_argument('-c', dest='components', type=int, default=80, help='Number of components to keep')
|
65 |
+
parser.add_argument('-n', type=int, default=300_000, help='Number of examples to use in decomposition')
|
66 |
+
parser.add_argument('--use_w', action='store_true', help='Use W latent space (StyleGAN(2))')
|
67 |
+
parser.add_argument('--sigma', type=float, default=2.0, help='Number of stdevs to walk in visualize.py')
|
68 |
+
parser.add_argument('--inputs', type=str, default=None, help='Path to directory with named components')
|
69 |
+
parser.add_argument('--seed', type=int, default=None, help='Seed used in decomposition')
|
70 |
+
args = parser.parse_args(args)
|
71 |
+
|
72 |
+
return self.from_dict(args.__dict__)
|
models/.DS_Store
CHANGED
Binary files a/models/.DS_Store and b/models/.DS_Store differ
|
|
models/stylegan2/.DS_Store
CHANGED
Binary files a/models/stylegan2/.DS_Store and b/models/stylegan2/.DS_Store differ
|
|
models/stylegan2/stylegan2-pytorch
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
Subproject commit 91ea2a7a4320701535466cce942c9e099d65670e
|
|
|
|