Spaces:
Running
on
Zero
Running
on
Zero
Commit
ยท
0a1f404
1
Parent(s):
3004ef2
loading model bug fix
Browse files
app.py
CHANGED
@@ -4,22 +4,17 @@ import spaces
|
|
4 |
from PIL import Image
|
5 |
|
6 |
import numpy as np
|
|
|
7 |
import torch.nn.functional as F
|
8 |
|
9 |
-
from utils.pipeline_utils import
|
10 |
from utils import get_args
|
11 |
|
12 |
from main import run
|
13 |
|
14 |
-
pipeline = None
|
15 |
|
16 |
|
17 |
-
def get_pipeline():
|
18 |
-
global pipeline
|
19 |
-
if pipeline is None:
|
20 |
-
pipeline = load_pipeline(fp16=False, cache_dir=None)
|
21 |
-
return pipeline
|
22 |
-
|
23 |
|
24 |
def process_masks(masks):
|
25 |
# masks: list of file paths
|
@@ -52,8 +47,6 @@ def main_pipeline(
|
|
52 |
dift_correction: bool = True,
|
53 |
):
|
54 |
args = get_args()
|
55 |
-
pipeline = get_pipeline()
|
56 |
-
|
57 |
args.alpha = alpha
|
58 |
args.beta = beta
|
59 |
args.w1 = w1
|
@@ -70,7 +63,6 @@ def main_pipeline(
|
|
70 |
|
71 |
DESCRIPTION = """# Cora ๐ผ๏ธ๐ฑ๐ฆ
|
72 |
## Fast & Controllable Image Editing
|
73 |
-
|
74 |
### ๐ ๏ธ Quick start
|
75 |
1. **Upload** or drag-and-drop the image youโd like to edit.
|
76 |
2. **Source prompt** โ describe whatโs in the original image.
|
@@ -78,9 +70,7 @@ DESCRIPTION = """# Cora ๐ผ๏ธ๐ฑ๐ฆ
|
|
78 |
4. Adjust the parameters as needed.
|
79 |
5. *(Optional)* Paint a mask to specify the area to edit.
|
80 |
6. Click **Edit** and wait a few seconds for the output.
|
81 |
-
|
82 |
### โ๏ธ Parameter cheat-sheet
|
83 |
-
|
84 |
| Parameter | What it does | `0` (minimum) | `1` (maximum) |
|
85 |
|-----------|--------------|---------------|---------------|
|
86 |
| **alpha** | Appearance transfer control | preserve source appearance | target prompt affects appearance |
|
@@ -88,7 +78,6 @@ DESCRIPTION = """# Cora ๐ผ๏ธ๐ฑ๐ฆ
|
|
88 |
| **w** | Prompt strength | subtle tweaks | strong changes |
|
89 |
| **Seed** | Fixes randomness for reproducibility | โ | โ |
|
90 |
| **Apply correspondence correction** | Uses correspondence-aware latent fix | โ | โ |
|
91 |
-
|
92 |
### ๐ Tips
|
93 |
- To replicate **TurboEdit**, set **alpha = 1**, **beta = 1**, and turn **off** *Apply correspondence correction*.
|
94 |
- To test reconstruction quality of the inversion, use identical source & target prompts with **alpha = 1**, **beta = 1**, and **w = 1**.
|
|
|
4 |
from PIL import Image
|
5 |
|
6 |
import numpy as np
|
7 |
+
import torch
|
8 |
import torch.nn.functional as F
|
9 |
|
10 |
+
from utils.pipeline_utils import load_pipeline
|
11 |
from utils import get_args
|
12 |
|
13 |
from main import run
|
14 |
|
15 |
+
pipeline = load_pipeline(fp16=False, cache_dir=None)
|
16 |
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
def process_masks(masks):
|
20 |
# masks: list of file paths
|
|
|
47 |
dift_correction: bool = True,
|
48 |
):
|
49 |
args = get_args()
|
|
|
|
|
50 |
args.alpha = alpha
|
51 |
args.beta = beta
|
52 |
args.w1 = w1
|
|
|
63 |
|
64 |
DESCRIPTION = """# Cora ๐ผ๏ธ๐ฑ๐ฆ
|
65 |
## Fast & Controllable Image Editing
|
|
|
66 |
### ๐ ๏ธ Quick start
|
67 |
1. **Upload** or drag-and-drop the image youโd like to edit.
|
68 |
2. **Source prompt** โ describe whatโs in the original image.
|
|
|
70 |
4. Adjust the parameters as needed.
|
71 |
5. *(Optional)* Paint a mask to specify the area to edit.
|
72 |
6. Click **Edit** and wait a few seconds for the output.
|
|
|
73 |
### โ๏ธ Parameter cheat-sheet
|
|
|
74 |
| Parameter | What it does | `0` (minimum) | `1` (maximum) |
|
75 |
|-----------|--------------|---------------|---------------|
|
76 |
| **alpha** | Appearance transfer control | preserve source appearance | target prompt affects appearance |
|
|
|
78 |
| **w** | Prompt strength | subtle tweaks | strong changes |
|
79 |
| **Seed** | Fixes randomness for reproducibility | โ | โ |
|
80 |
| **Apply correspondence correction** | Uses correspondence-aware latent fix | โ | โ |
|
|
|
81 |
### ๐ Tips
|
82 |
- To replicate **TurboEdit**, set **alpha = 1**, **beta = 1**, and turn **off** *Apply correspondence correction*.
|
83 |
- To test reconstruction quality of the inversion, use identical source & target prompts with **alpha = 1**, **beta = 1**, and **w = 1**.
|