ljh838 mamta commited on
Commit
c67a743
·
0 Parent(s):

Duplicate from Gradio-Blocks/DualStyleGAN

Browse files

Co-authored-by: Mamta Narang <[email protected]>

.gitattributes ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.jpg filter=lfs diff=lfs merge=lfs -text
2
+ *.7z filter=lfs diff=lfs merge=lfs -text
3
+ *.arrow filter=lfs diff=lfs merge=lfs -text
4
+ *.bin filter=lfs diff=lfs merge=lfs -text
5
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.model filter=lfs diff=lfs merge=lfs -text
12
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
13
+ *.onnx filter=lfs diff=lfs merge=lfs -text
14
+ *.ot filter=lfs diff=lfs merge=lfs -text
15
+ *.parquet filter=lfs diff=lfs merge=lfs -text
16
+ *.pb filter=lfs diff=lfs merge=lfs -text
17
+ *.pt filter=lfs diff=lfs merge=lfs -text
18
+ *.pth filter=lfs diff=lfs merge=lfs -text
19
+ *.rar filter=lfs diff=lfs merge=lfs -text
20
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
21
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
22
+ *.tflite filter=lfs diff=lfs merge=lfs -text
23
+ *.tgz filter=lfs diff=lfs merge=lfs -text
24
+ *.wasm filter=lfs diff=lfs merge=lfs -text
25
+ *.xz filter=lfs diff=lfs merge=lfs -text
26
+ *.zip filter=lfs diff=lfs merge=lfs -text
27
+ *.zstandard filter=lfs diff=lfs merge=lfs -text
28
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
.gitmodules ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ [submodule "DualStyleGAN"]
2
+ path = DualStyleGAN
3
+ url = https://github.com/williamyang1991/DualStyleGAN
.pre-commit-config.yaml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ exclude: ^(DualStyleGAN|patch)
2
+ repos:
3
+ - repo: https://github.com/pre-commit/pre-commit-hooks
4
+ rev: v4.2.0
5
+ hooks:
6
+ - id: check-executables-have-shebangs
7
+ - id: check-json
8
+ - id: check-merge-conflict
9
+ - id: check-shebang-scripts-are-executable
10
+ - id: check-toml
11
+ - id: check-yaml
12
+ - id: double-quote-string-fixer
13
+ - id: end-of-file-fixer
14
+ - id: mixed-line-ending
15
+ args: ['--fix=lf']
16
+ - id: requirements-txt-fixer
17
+ - id: trailing-whitespace
18
+ - repo: https://github.com/myint/docformatter
19
+ rev: v1.4
20
+ hooks:
21
+ - id: docformatter
22
+ args: ['--in-place']
23
+ - repo: https://github.com/pycqa/isort
24
+ rev: 5.10.1
25
+ hooks:
26
+ - id: isort
27
+ - repo: https://github.com/pre-commit/mirrors-mypy
28
+ rev: v0.812
29
+ hooks:
30
+ - id: mypy
31
+ args: ['--ignore-missing-imports']
32
+ - repo: https://github.com/google/yapf
33
+ rev: v0.32.0
34
+ hooks:
35
+ - id: yapf
36
+ args: ['--parallel', '--in-place']
37
+ - repo: https://github.com/kynan/nbstripout
38
+ rev: 0.5.0
39
+ hooks:
40
+ - id: nbstripout
41
+ args: ['--extra-keys', 'metadata.interpreter metadata.kernelspec cell.metadata.pycharm']
42
+ - repo: https://github.com/nbQA-dev/nbQA
43
+ rev: 1.3.1
44
+ hooks:
45
+ - id: nbqa-isort
46
+ - id: nbqa-yapf
.style.yapf ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ [style]
2
+ based_on_style = pep8
3
+ blank_line_before_nested_class_or_def = false
4
+ spaces_before_comment = 2
5
+ split_before_logical_operator = true
DualStyleGAN ADDED
@@ -0,0 +1 @@
 
 
1
+ Subproject commit 64285b179d0929e301a97c2f2c438546ff49e20d
README.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Portrait Style Transfer
3
+ emoji: 😻
4
+ colorFrom: purple
5
+ colorTo: red
6
+ sdk: gradio
7
+ sdk_version: 3.0.17
8
+ app_file: app.py
9
+ pinned: false
10
+ duplicated_from: Gradio-Blocks/DualStyleGAN
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
app.py ADDED
@@ -0,0 +1,236 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import pathlib
7
+
8
+ import gradio as gr
9
+
10
+ from dualstylegan import Model
11
+
12
+ DESCRIPTION = '''# Portrait Style Transfer with <a href="https://github.com/williamyang1991/DualStyleGAN">DualStyleGAN</a>
13
+
14
+ <img id="overview" alt="overview" src="https://raw.githubusercontent.com/williamyang1991/DualStyleGAN/main/doc_images/overview.jpg" />
15
+ '''
16
+ FOOTER = '<img id="visitor-badge" alt="visitor badge" src="https://visitor-badge.glitch.me/badge?page_id=gradio-blocks.dualstylegan" />'
17
+
18
+
19
+ def parse_args() -> argparse.Namespace:
20
+ parser = argparse.ArgumentParser()
21
+ parser.add_argument('--device', type=str, default='cpu')
22
+ parser.add_argument('--theme', type=str)
23
+ parser.add_argument('--share', action='store_true')
24
+ parser.add_argument('--port', type=int)
25
+ parser.add_argument('--disable-queue',
26
+ dest='enable_queue',
27
+ action='store_false')
28
+ return parser.parse_args()
29
+
30
+
31
+ def get_style_image_url(style_name: str) -> str:
32
+ base_url = 'https://raw.githubusercontent.com/williamyang1991/DualStyleGAN/main/doc_images'
33
+ filenames = {
34
+ 'cartoon': 'cartoon_overview.jpg',
35
+ 'caricature': 'caricature_overview.jpg',
36
+ 'anime': 'anime_overview.jpg',
37
+ 'arcane': 'Reconstruction_arcane_overview.jpg',
38
+ 'comic': 'Reconstruction_comic_overview.jpg',
39
+ 'pixar': 'Reconstruction_pixar_overview.jpg',
40
+ 'slamdunk': 'Reconstruction_slamdunk_overview.jpg',
41
+ }
42
+ return f'{base_url}/{filenames[style_name]}'
43
+
44
+
45
+ def get_style_image_markdown_text(style_name: str) -> str:
46
+ url = get_style_image_url(style_name)
47
+ return f'<center><img id="style-image" src="{url}" alt="style image"></center>'
48
+
49
+
50
+ def update_slider(choice: str) -> dict:
51
+ max_vals = {
52
+ 'cartoon': 316,
53
+ 'caricature': 198,
54
+ 'anime': 173,
55
+ 'arcane': 99,
56
+ 'comic': 100,
57
+ 'pixar': 121,
58
+ 'slamdunk': 119,
59
+ }
60
+ return gr.Slider.update(maximum=max_vals[choice])
61
+
62
+
63
+ def update_style_image(style_name: str) -> dict:
64
+ text = get_style_image_markdown_text(style_name)
65
+ return gr.Markdown.update(value=text)
66
+
67
+
68
+ def set_example_image(example: list) -> dict:
69
+ return gr.Image.update(value=example[0])
70
+
71
+
72
+ def set_example_styles(example: list) -> list[dict]:
73
+ return [
74
+ gr.Radio.update(value=example[0]),
75
+ gr.Slider.update(value=example[1]),
76
+ ]
77
+
78
+
79
+ def set_example_weights(example: list) -> list[dict]:
80
+ return [
81
+ gr.Slider.update(value=example[0]),
82
+ gr.Slider.update(value=example[1]),
83
+ ]
84
+
85
+
86
+ def main():
87
+ args = parse_args()
88
+ model = Model(device=args.device)
89
+
90
+ with gr.Blocks(theme=args.theme, css='style.css') as demo:
91
+ gr.Markdown(DESCRIPTION)
92
+
93
+ with gr.Box():
94
+ gr.Markdown('''## Step 1 (Preprocess Input Image)
95
+
96
+ - Drop an image containing a near-frontal face to the **Input Image**.
97
+ - If there are multiple faces in the image, hit the Edit button in the upper right corner and crop the input image beforehand.
98
+ - Hit the **Detect & Align Face** button.
99
+ - Hit the **Reconstruct Face** button.
100
+ - The final result will be based on this **Reconstructed Face**. So, if the reconstructed image is not satisfactory, you may want to change the input image.
101
+ ''')
102
+ with gr.Row():
103
+ with gr.Column():
104
+ with gr.Row():
105
+ input_image = gr.Image(label='Input Image',
106
+ type='file')
107
+ with gr.Row():
108
+ detect_button = gr.Button('Detect & Align Face')
109
+ with gr.Column():
110
+ with gr.Row():
111
+ aligned_face = gr.Image(label='Aligned Face',
112
+ type='numpy',
113
+ interactive=False)
114
+ with gr.Row():
115
+ reconstruct_button = gr.Button('Reconstruct Face')
116
+ with gr.Column():
117
+ reconstructed_face = gr.Image(label='Reconstructed Face',
118
+ type='numpy')
119
+ instyle = gr.Variable()
120
+
121
+ with gr.Row():
122
+ paths = sorted(pathlib.Path('images').glob('*.jpg'))
123
+ example_images = gr.Dataset(components=[input_image],
124
+ samples=[[path.as_posix()]
125
+ for path in paths])
126
+
127
+ with gr.Box():
128
+ gr.Markdown('''## Step 2 (Select Style Image)
129
+
130
+ - Select **Style Type**.
131
+ - Select **Style Image Index** from the image table below.
132
+ ''')
133
+ with gr.Row():
134
+ with gr.Column():
135
+ style_type = gr.Radio(model.style_types,
136
+ label='Style Type')
137
+ text = get_style_image_markdown_text('cartoon')
138
+ style_image = gr.Markdown(value=text)
139
+ style_index = gr.Slider(0,
140
+ 316,
141
+ value=26,
142
+ step=1,
143
+ label='Style Image Index')
144
+
145
+ with gr.Row():
146
+ example_styles = gr.Dataset(
147
+ components=[style_type, style_index],
148
+ samples=[
149
+ ['cartoon', 26],
150
+ ['caricature', 65],
151
+ ['arcane', 63],
152
+ ['pixar', 80],
153
+ ])
154
+
155
+ with gr.Box():
156
+ gr.Markdown('''## Step 3 (Generate Style Transferred Image)
157
+
158
+ - Adjust **Structure Weight** and **Color Weight**.
159
+ - These are weights for the style image, so the larger the value, the closer the resulting image will be to the style image.
160
+ - Hit the **Generate** button.
161
+ ''')
162
+ with gr.Row():
163
+ with gr.Column():
164
+ with gr.Row():
165
+ structure_weight = gr.Slider(0,
166
+ 1,
167
+ value=0.6,
168
+ step=0.1,
169
+ label='Structure Weight')
170
+ with gr.Row():
171
+ color_weight = gr.Slider(0,
172
+ 1,
173
+ value=1,
174
+ step=0.1,
175
+ label='Color Weight')
176
+ with gr.Row():
177
+ structure_only = gr.Checkbox(label='Structure Only')
178
+ with gr.Row():
179
+ generate_button = gr.Button('Generate')
180
+
181
+ with gr.Column():
182
+ result = gr.Image(label='Result')
183
+
184
+ with gr.Row():
185
+ example_weights = gr.Dataset(
186
+ components=[structure_weight, color_weight],
187
+ samples=[
188
+ [0.6, 1.0],
189
+ [0.3, 1.0],
190
+ [0.0, 1.0],
191
+ [1.0, 0.0],
192
+ ])
193
+
194
+ gr.Markdown(FOOTER)
195
+
196
+ detect_button.click(fn=model.detect_and_align_face,
197
+ inputs=input_image,
198
+ outputs=aligned_face)
199
+ reconstruct_button.click(fn=model.reconstruct_face,
200
+ inputs=aligned_face,
201
+ outputs=[reconstructed_face, instyle])
202
+ style_type.change(fn=update_slider,
203
+ inputs=style_type,
204
+ outputs=style_index)
205
+ style_type.change(fn=update_style_image,
206
+ inputs=style_type,
207
+ outputs=style_image)
208
+ generate_button.click(fn=model.generate,
209
+ inputs=[
210
+ style_type,
211
+ style_index,
212
+ structure_weight,
213
+ color_weight,
214
+ structure_only,
215
+ instyle,
216
+ ],
217
+ outputs=result)
218
+ example_images.click(fn=set_example_image,
219
+ inputs=example_images,
220
+ outputs=example_images.components)
221
+ example_styles.click(fn=set_example_styles,
222
+ inputs=example_styles,
223
+ outputs=example_styles.components)
224
+ example_weights.click(fn=set_example_weights,
225
+ inputs=example_weights,
226
+ outputs=example_weights.components)
227
+
228
+ demo.launch(
229
+ enable_queue=args.enable_queue,
230
+ server_port=args.port,
231
+ share=args.share,
232
+ )
233
+
234
+
235
+ if __name__ == '__main__':
236
+ main()
dualstylegan.py ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import os
5
+ import pathlib
6
+ import subprocess
7
+ import sys
8
+ from typing import Callable, Union
9
+
10
+ import dlib
11
+ import huggingface_hub
12
+ import numpy as np
13
+ import PIL.Image
14
+ import torch
15
+ import torch.nn as nn
16
+ import torchvision.transforms as T
17
+
18
+ if os.getenv('SYSTEM') == 'spaces':
19
+ with open('patch') as f:
20
+ subprocess.run('patch -p1'.split(), cwd='DualStyleGAN', stdin=f)
21
+
22
+ app_dir = pathlib.Path(__file__).parent
23
+ submodule_dir = app_dir / 'DualStyleGAN'
24
+ sys.path.insert(0, submodule_dir.as_posix())
25
+
26
+ from model.dualstylegan import DualStyleGAN
27
+ from model.encoder.align_all_parallel import align_face
28
+ from model.encoder.psp import pSp
29
+
30
+ HF_TOKEN = os.environ['HF_TOKEN']
31
+ MODEL_REPO = 'hysts/DualStyleGAN'
32
+
33
+
34
+ class Model:
35
+ def __init__(self, device: Union[torch.device, str]):
36
+ self.device = torch.device(device)
37
+ self.landmark_model = self._create_dlib_landmark_model()
38
+ self.encoder = self._load_encoder()
39
+ self.transform = self._create_transform()
40
+
41
+ self.style_types = [
42
+ 'cartoon',
43
+ 'caricature',
44
+ 'anime',
45
+ 'arcane',
46
+ 'comic',
47
+ 'pixar',
48
+ 'slamdunk',
49
+ ]
50
+ self.generator_dict = {
51
+ style_type: self._load_generator(style_type)
52
+ for style_type in self.style_types
53
+ }
54
+ self.exstyle_dict = {
55
+ style_type: self._load_exstylecode(style_type)
56
+ for style_type in self.style_types
57
+ }
58
+
59
+ @staticmethod
60
+ def _create_dlib_landmark_model():
61
+ path = huggingface_hub.hf_hub_download(
62
+ 'hysts/dlib_face_landmark_model',
63
+ 'shape_predictor_68_face_landmarks.dat',
64
+ use_auth_token=HF_TOKEN)
65
+ return dlib.shape_predictor(path)
66
+
67
+ def _load_encoder(self) -> nn.Module:
68
+ ckpt_path = huggingface_hub.hf_hub_download(MODEL_REPO,
69
+ 'models/encoder.pt',
70
+ use_auth_token=HF_TOKEN)
71
+ ckpt = torch.load(ckpt_path, map_location='cpu')
72
+ opts = ckpt['opts']
73
+ opts['device'] = self.device.type
74
+ opts['checkpoint_path'] = ckpt_path
75
+ opts = argparse.Namespace(**opts)
76
+ model = pSp(opts)
77
+ model.to(self.device)
78
+ model.eval()
79
+ return model
80
+
81
+ @staticmethod
82
+ def _create_transform() -> Callable:
83
+ transform = T.Compose([
84
+ T.Resize(256),
85
+ T.CenterCrop(256),
86
+ T.ToTensor(),
87
+ T.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5]),
88
+ ])
89
+ return transform
90
+
91
+ def _load_generator(self, style_type: str) -> nn.Module:
92
+ model = DualStyleGAN(1024, 512, 8, 2, res_index=6)
93
+ ckpt_path = huggingface_hub.hf_hub_download(
94
+ MODEL_REPO,
95
+ f'models/{style_type}/generator.pt',
96
+ use_auth_token=HF_TOKEN)
97
+ ckpt = torch.load(ckpt_path, map_location='cpu')
98
+ model.load_state_dict(ckpt['g_ema'])
99
+ model.to(self.device)
100
+ model.eval()
101
+ return model
102
+
103
+ @staticmethod
104
+ def _load_exstylecode(style_type: str) -> dict[str, np.ndarray]:
105
+ if style_type in ['cartoon', 'caricature', 'anime']:
106
+ filename = 'refined_exstyle_code.npy'
107
+ else:
108
+ filename = 'exstyle_code.npy'
109
+ path = huggingface_hub.hf_hub_download(
110
+ MODEL_REPO,
111
+ f'models/{style_type}/{filename}',
112
+ use_auth_token=HF_TOKEN)
113
+ exstyles = np.load(path, allow_pickle=True).item()
114
+ return exstyles
115
+
116
+ def detect_and_align_face(self, image) -> np.ndarray:
117
+ image = align_face(filepath=image.name, predictor=self.landmark_model)
118
+ return image
119
+
120
+ @staticmethod
121
+ def denormalize(tensor: torch.Tensor) -> torch.Tensor:
122
+ return torch.clamp((tensor + 1) / 2 * 255, 0, 255).to(torch.uint8)
123
+
124
+ def postprocess(self, tensor: torch.Tensor) -> np.ndarray:
125
+ tensor = self.denormalize(tensor)
126
+ return tensor.cpu().numpy().transpose(1, 2, 0)
127
+
128
+ @torch.inference_mode()
129
+ def reconstruct_face(self,
130
+ image: np.ndarray) -> tuple[np.ndarray, torch.Tensor]:
131
+ image = PIL.Image.fromarray(image)
132
+ input_data = self.transform(image).unsqueeze(0).to(self.device)
133
+ img_rec, instyle = self.encoder(input_data,
134
+ randomize_noise=False,
135
+ return_latents=True,
136
+ z_plus_latent=True,
137
+ return_z_plus_latent=True,
138
+ resize=False)
139
+ img_rec = torch.clamp(img_rec.detach(), -1, 1)
140
+ img_rec = self.postprocess(img_rec[0])
141
+ return img_rec, instyle
142
+
143
+ @torch.inference_mode()
144
+ def generate(self, style_type: str, style_id: int, structure_weight: float,
145
+ color_weight: float, structure_only: bool,
146
+ instyle: torch.Tensor) -> np.ndarray:
147
+ generator = self.generator_dict[style_type]
148
+ exstyles = self.exstyle_dict[style_type]
149
+
150
+ style_id = int(style_id)
151
+ stylename = list(exstyles.keys())[style_id]
152
+
153
+ latent = torch.tensor(exstyles[stylename]).to(self.device)
154
+ if structure_only:
155
+ latent[0, 7:18] = instyle[0, 7:18]
156
+ exstyle = generator.generator.style(
157
+ latent.reshape(latent.shape[0] * latent.shape[1],
158
+ latent.shape[2])).reshape(latent.shape)
159
+
160
+ img_gen, _ = generator([instyle],
161
+ exstyle,
162
+ z_plus_latent=True,
163
+ truncation=0.7,
164
+ truncation_latent=0,
165
+ use_res=True,
166
+ interp_weights=[structure_weight] * 7 +
167
+ [color_weight] * 11)
168
+ img_gen = torch.clamp(img_gen.detach(), -1, 1)
169
+ img_gen = self.postprocess(img_gen[0])
170
+ return img_gen
images/95UF6LXe-Lo.jpg ADDED

Git LFS Details

  • SHA256: 9ba751a6519822fa683e062ee3a383e748f15b41d4ca87d14c4fa73f9beed845
  • Pointer size: 131 Bytes
  • Size of remote file: 503 kB
images/ILip77SbmOE.jpg ADDED

Git LFS Details

  • SHA256: 3eed82923bc76a90f067415f148d56239fdfa4a1aca9eef1d459bc6050c9dde8
  • Pointer size: 131 Bytes
  • Size of remote file: 939 kB
images/README.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ These images are freely-usable ones from [Unsplash](https://unsplash.com/).
2
+
3
+ - https://unsplash.com/photos/rDEOVtE7vOs
4
+ - https://unsplash.com/photos/et_78QkMMQs
5
+ - https://unsplash.com/photos/ILip77SbmOE
6
+ - https://unsplash.com/photos/95UF6LXe-Lo
7
+
images/et_78QkMMQs.jpg ADDED

Git LFS Details

  • SHA256: c63a2e9de5eda3cb28012cfc8e4ba9384daeda8cca7a8989ad90b21a1293cc6f
  • Pointer size: 131 Bytes
  • Size of remote file: 371 kB
images/rDEOVtE7vOs.jpg ADDED

Git LFS Details

  • SHA256: b136bf195fef5599f277a563f0eef79af5301d9352d4ebf82bd7a0a061b7bdc0
  • Pointer size: 131 Bytes
  • Size of remote file: 155 kB
packages.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ cmake
2
+ ninja-build
patch ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/model/stylegan/op/fused_act.py b/model/stylegan/op/fused_act.py
2
+ index c3b735c..67e7972 100644
3
+ --- a/model/stylegan/op/fused_act.py
4
+ +++ b/model/stylegan/op/fused_act.py
5
+ @@ -7,14 +7,6 @@ from torch.autograd import Function
6
+ from torch.utils.cpp_extension import load
7
+
8
+
9
+ -module_path = os.path.dirname(__file__)
10
+ -fused = load(
11
+ - "fused",
12
+ - sources=[
13
+ - os.path.join(module_path, "fused_bias_act.cpp"),
14
+ - os.path.join(module_path, "fused_bias_act_kernel.cu"),
15
+ - ],
16
+ -)
17
+
18
+
19
+ class FusedLeakyReLUFunctionBackward(Function):
20
+ diff --git a/model/stylegan/op/upfirdn2d.py b/model/stylegan/op/upfirdn2d.py
21
+ index 67e0375..97565d7 100644
22
+ --- a/model/stylegan/op/upfirdn2d.py
23
+ +++ b/model/stylegan/op/upfirdn2d.py
24
+ @@ -7,14 +7,6 @@ from torch.autograd import Function
25
+ from torch.utils.cpp_extension import load
26
+
27
+
28
+ -module_path = os.path.dirname(__file__)
29
+ -upfirdn2d_op = load(
30
+ - "upfirdn2d",
31
+ - sources=[
32
+ - os.path.join(module_path, "upfirdn2d.cpp"),
33
+ - os.path.join(module_path, "upfirdn2d_kernel.cu"),
34
+ - ],
35
+ -)
36
+
37
+
38
+ class UpFirDn2dBackward(Function):
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ dlib==19.23.0
2
+ numpy==1.22.3
3
+ opencv-python-headless==4.5.5.62
4
+ Pillow==9.0.1
5
+ scipy==1.8.0
6
+ torch==1.11.0
7
+ torchvision==0.12.0
style.css ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ h1 {
2
+ text-align: center;
3
+ }
4
+ img#overview {
5
+ max-width: 800px;
6
+ max-height: 600px;
7
+ display: block;
8
+ margin: auto;
9
+ }
10
+ img#style-image {
11
+ max-width: 1000px;
12
+ max-height: 600px;
13
+ }
14
+ img#visitor-badge {
15
+ display: block;
16
+ margin: auto;
17
+ }