Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -10,6 +10,7 @@ import open_clip
|
|
10 |
from huggingface_hub import hf_hub_download
|
11 |
from IP_Composer.IP_Adapter.ip_adapter import IPAdapterXL
|
12 |
from IP_Composer.perform_swap import compute_dataset_embeds_svd, get_modified_images_embeds_composition
|
|
|
13 |
|
14 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
15 |
|
@@ -36,6 +37,7 @@ CONCEPTS_MAP = {'age':'age','animal fur':'animal_fur', 'deterioration': 'deterio
|
|
36 |
|
37 |
concept_options = list(CONCEPTS_MAP.keys())
|
38 |
|
|
|
39 |
def get_image_embeds(pil_image, model=clip_model, preproc=preprocess, dev=device):
|
40 |
"""Get CLIP image embeddings for a given PIL image"""
|
41 |
image = preproc(pil_image)[np.newaxis, :, :, :]
|
@@ -43,6 +45,7 @@ def get_image_embeds(pil_image, model=clip_model, preproc=preprocess, dev=device
|
|
43 |
embeds = model.encode_image(image.to(dev))
|
44 |
return embeds.cpu().detach().numpy()
|
45 |
|
|
|
46 |
def process_images(
|
47 |
base_image,
|
48 |
concept_image1, concept_name1,
|
|
|
10 |
from huggingface_hub import hf_hub_download
|
11 |
from IP_Composer.IP_Adapter.ip_adapter import IPAdapterXL
|
12 |
from IP_Composer.perform_swap import compute_dataset_embeds_svd, get_modified_images_embeds_composition
|
13 |
+
import spaces
|
14 |
|
15 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
16 |
|
|
|
37 |
|
38 |
concept_options = list(CONCEPTS_MAP.keys())
|
39 |
|
40 |
+
@spaces.GPU
|
41 |
def get_image_embeds(pil_image, model=clip_model, preproc=preprocess, dev=device):
|
42 |
"""Get CLIP image embeddings for a given PIL image"""
|
43 |
image = preproc(pil_image)[np.newaxis, :, :, :]
|
|
|
45 |
embeds = model.encode_image(image.to(dev))
|
46 |
return embeds.cpu().detach().numpy()
|
47 |
|
48 |
+
@spaces.GPU
|
49 |
def process_images(
|
50 |
base_image,
|
51 |
concept_image1, concept_name1,
|