akhaliq HF staff cbensimon HF staff commited on
Commit
31dfa92
1 Parent(s): a602adb

- ZeroGPU (9942e6f2eadfdfa1c78f6529e6f8baa84bfb7f18)


Co-authored-by: Charles Bensimon <cbensimon@users.noreply.huggingface.co>

Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import os
2
  import cv2
3
  import math
 
4
  import torch
5
  import random
6
  import numpy as np
@@ -18,7 +19,6 @@ from insightface.app import FaceAnalysis
18
  from style_template import styles
19
  from pipeline_stable_diffusion_xl_instantid import StableDiffusionXLInstantIDPipeline
20
 
21
- import spaces
22
  import gradio as gr
23
 
24
  # global variable
@@ -34,7 +34,7 @@ hf_hub_download(repo_id="InstantX/InstantID", filename="ControlNetModel/diffusio
34
  hf_hub_download(repo_id="InstantX/InstantID", filename="ip-adapter.bin", local_dir="./checkpoints")
35
 
36
  # Load face encoder
37
- app = FaceAnalysis(name='antelopev2', root='./', providers=['CUDAExecutionProvider', 'CPUExecutionProvider'])
38
  app.prepare(ctx_id=0, det_size=(640, 640))
39
 
40
  # Path to InstantID models
@@ -55,6 +55,8 @@ pipe = StableDiffusionXLInstantIDPipeline.from_pretrained(
55
  )
56
  pipe.cuda()
57
  pipe.load_ip_adapter_instantid(face_adapter)
 
 
58
 
59
  def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
60
  if randomize_seed:
 
1
  import os
2
  import cv2
3
  import math
4
+ import spaces
5
  import torch
6
  import random
7
  import numpy as np
 
19
  from style_template import styles
20
  from pipeline_stable_diffusion_xl_instantid import StableDiffusionXLInstantIDPipeline
21
 
 
22
  import gradio as gr
23
 
24
  # global variable
 
34
  hf_hub_download(repo_id="InstantX/InstantID", filename="ip-adapter.bin", local_dir="./checkpoints")
35
 
36
  # Load face encoder
37
+ app = FaceAnalysis(name='antelopev2', root='./', providers=['CPUExecutionProvider'])
38
  app.prepare(ctx_id=0, det_size=(640, 640))
39
 
40
  # Path to InstantID models
 
55
  )
56
  pipe.cuda()
57
  pipe.load_ip_adapter_instantid(face_adapter)
58
+ pipe.image_proj_model.to('cuda')
59
+ pipe.unet.to('cuda')
60
 
61
  def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
62
  if randomize_seed: