multimodalart HF Staff commited on
Commit
1b557eb
·
verified ·
1 Parent(s): 6a8efeb

[Admin maintenance] Migrate grant to ZeroGPU

Browse files
Files changed (1) hide show
  1. app.py +3 -21
app.py CHANGED
@@ -17,42 +17,24 @@ def clone_if_missing(path, repo, branch=None):
17
  subprocess.run(cmd, check=True)
18
 
19
 
20
- clone_if_missing(
21
- "src/blip",
22
- "https://github.com/pharmapsychotic/BLIP.git",
23
- branch="lib",
24
- )
25
  clone_if_missing(
26
  "clip-interrogator",
27
  "https://github.com/pharmapsychotic/clip-interrogator.git",
28
- branch="open-clip",
29
  )
30
 
31
- sys.path.append("src/blip")
32
  sys.path.append("clip-interrogator")
33
 
34
- print("Download preprocessed cache files...")
35
- CACHE_URLS = [
36
- "https://huggingface.co/pharma/ci-preprocess/resolve/main/ViT-H-14_laion2b_s32b_b79k_artists.pkl",
37
- "https://huggingface.co/pharma/ci-preprocess/resolve/main/ViT-H-14_laion2b_s32b_b79k_flavors.pkl",
38
- "https://huggingface.co/pharma/ci-preprocess/resolve/main/ViT-H-14_laion2b_s32b_b79k_mediums.pkl",
39
- "https://huggingface.co/pharma/ci-preprocess/resolve/main/ViT-H-14_laion2b_s32b_b79k_movements.pkl",
40
- "https://huggingface.co/pharma/ci-preprocess/resolve/main/ViT-H-14_laion2b_s32b_b79k_trendings.pkl",
41
- ]
42
- os.makedirs("cache", exist_ok=True)
43
- for url in CACHE_URLS:
44
- subprocess.run(["wget", "-nc", url, "-P", "cache"], check=False)
45
-
46
  import gradio as gr
47
  from clip_interrogator import Config, Interrogator
48
 
49
 
50
  config = Config()
 
51
  config.device = "cuda" if torch.cuda.is_available() else "cpu"
52
- config.blip_offload = False if torch.cuda.is_available() else True
 
53
  config.chunk_size = 2048
54
  config.flavor_intermediate_count = 512
55
- config.blip_num_beams = 64
56
 
57
  ci = Interrogator(config)
58
 
 
17
  subprocess.run(cmd, check=True)
18
 
19
 
 
 
 
 
 
20
  clone_if_missing(
21
  "clip-interrogator",
22
  "https://github.com/pharmapsychotic/clip-interrogator.git",
 
23
  )
24
 
 
25
  sys.path.append("clip-interrogator")
26
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  import gradio as gr
28
  from clip_interrogator import Config, Interrogator
29
 
30
 
31
  config = Config()
32
+ config.clip_model_name = "ViT-H-14/laion2b_s32b_b79k"
33
  config.device = "cuda" if torch.cuda.is_available() else "cpu"
34
+ config.caption_offload = False if torch.cuda.is_available() else True
35
+ config.clip_offload = False if torch.cuda.is_available() else True
36
  config.chunk_size = 2048
37
  config.flavor_intermediate_count = 512
 
38
 
39
  ci = Interrogator(config)
40