Spaces:
Runtime error
Runtime error
Refactor
Browse files
app.py
CHANGED
|
@@ -3,18 +3,10 @@
|
|
| 3 |
from __future__ import annotations
|
| 4 |
|
| 5 |
import argparse
|
| 6 |
-
import os
|
| 7 |
import pathlib
|
| 8 |
-
import subprocess
|
| 9 |
|
| 10 |
import gradio as gr
|
| 11 |
|
| 12 |
-
if os.getenv('SYSTEM') == 'spaces':
|
| 13 |
-
with open('patch.e4e') as f:
|
| 14 |
-
subprocess.run('patch -p1'.split(), cwd='encoder4editing', stdin=f)
|
| 15 |
-
with open('patch.hairclip') as f:
|
| 16 |
-
subprocess.run('patch -p1'.split(), cwd='HairCLIP', stdin=f)
|
| 17 |
-
|
| 18 |
from model import Model
|
| 19 |
|
| 20 |
|
|
|
|
| 3 |
from __future__ import annotations
|
| 4 |
|
| 5 |
import argparse
|
|
|
|
| 6 |
import pathlib
|
|
|
|
| 7 |
|
| 8 |
import gradio as gr
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
from model import Model
|
| 11 |
|
| 12 |
|
model.py
CHANGED
|
@@ -2,6 +2,8 @@ from __future__ import annotations
|
|
| 2 |
|
| 3 |
import argparse
|
| 4 |
import os
|
|
|
|
|
|
|
| 5 |
import sys
|
| 6 |
from typing import Callable, Union
|
| 7 |
|
|
@@ -13,13 +15,24 @@ import torch
|
|
| 13 |
import torch.nn as nn
|
| 14 |
import torchvision.transforms as T
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
from models.psp import pSp
|
| 19 |
from utils.alignment import align_face
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
| 23 |
|
| 24 |
from mapper.datasets.latents_dataset_inference import LatentsDatasetInference
|
| 25 |
from mapper.hairclip_mapper import HairCLIPMapper
|
|
|
|
| 2 |
|
| 3 |
import argparse
|
| 4 |
import os
|
| 5 |
+
import pathlib
|
| 6 |
+
import subprocess
|
| 7 |
import sys
|
| 8 |
from typing import Callable, Union
|
| 9 |
|
|
|
|
| 15 |
import torch.nn as nn
|
| 16 |
import torchvision.transforms as T
|
| 17 |
|
| 18 |
+
if os.getenv('SYSTEM') == 'spaces':
|
| 19 |
+
with open('patch.e4e') as f:
|
| 20 |
+
subprocess.run('patch -p1'.split(), cwd='encoder4editing', stdin=f)
|
| 21 |
+
with open('patch.hairclip') as f:
|
| 22 |
+
subprocess.run('patch -p1'.split(), cwd='HairCLIP', stdin=f)
|
| 23 |
+
|
| 24 |
+
app_dir = pathlib.Path(__file__).parent
|
| 25 |
+
|
| 26 |
+
e4e_dir = app_dir / 'encoder4editing'
|
| 27 |
+
sys.path.insert(0, e4e_dir.as_posix())
|
| 28 |
|
| 29 |
from models.psp import pSp
|
| 30 |
from utils.alignment import align_face
|
| 31 |
|
| 32 |
+
hairclip_dir = app_dir / 'HairCLIP'
|
| 33 |
+
mapper_dir = hairclip_dir / 'mapper'
|
| 34 |
+
sys.path.insert(0, hairclip_dir.as_posix())
|
| 35 |
+
sys.path.insert(0, mapper_dir.as_posix())
|
| 36 |
|
| 37 |
from mapper.datasets.latents_dataset_inference import LatentsDatasetInference
|
| 38 |
from mapper.hairclip_mapper import HairCLIPMapper
|