jassinghNY commited on
Commit
c68fa92
·
verified ·
1 Parent(s): 99b3556

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  from typing import List
2
  from pydantic import BaseModel
3
  from lama_cleaner.server import main
@@ -16,7 +17,7 @@ class FakeArgs(BaseModel):
16
  sd_run_local: bool = False
17
  local_files_only: bool = False
18
  cpu_offload: bool = False
19
- device: str = "cuda"
20
  gui: bool = False
21
  gui_size: List[int] = [1000, 1000]
22
  input: str = ''
@@ -27,12 +28,12 @@ class FakeArgs(BaseModel):
27
  enable_xformers: bool = False
28
  enable_interactive_seg: bool = True
29
  interactive_seg_model: str = "vit_b"
30
- interactive_seg_device: str = "cuda"
31
  enable_remove_bg: bool = False
32
  enable_anime_seg: bool = False
33
  enable_realesrgan: bool = False
34
  enable_gfpgan: bool = False
35
- gfpgan_device: str = "cuda"
36
  enable_restoreformer: bool = False
37
  enable_gif: bool = False
38
  quality: int = 95
@@ -40,4 +41,11 @@ class FakeArgs(BaseModel):
40
  output_dir: str = None
41
 
42
  if __name__ == "__main__":
43
- main(FakeArgs())
 
 
 
 
 
 
 
 
1
+ import torch
2
  from typing import List
3
  from pydantic import BaseModel
4
  from lama_cleaner.server import main
 
17
  sd_run_local: bool = False
18
  local_files_only: bool = False
19
  cpu_offload: bool = False
20
+ device: str = "cuda" if torch.cuda.is_available() else "cpu"
21
  gui: bool = False
22
  gui_size: List[int] = [1000, 1000]
23
  input: str = ''
 
28
  enable_xformers: bool = False
29
  enable_interactive_seg: bool = True
30
  interactive_seg_model: str = "vit_b"
31
+ interactive_seg_device: str = "cuda" if torch.cuda.is_available() else "cpu"
32
  enable_remove_bg: bool = False
33
  enable_anime_seg: bool = False
34
  enable_realesrgan: bool = False
35
  enable_gfpgan: bool = False
36
+ gfpgan_device: str = "cuda" if torch.cuda.is_available() else "cpu"
37
  enable_restoreformer: bool = False
38
  enable_gif: bool = False
39
  quality: int = 95
 
41
  output_dir: str = None
42
 
43
  if __name__ == "__main__":
44
+ if torch.cuda.is_available():
45
+ print("CUDA is available. Using GPU.")
46
+ else:
47
+ print("CUDA is not available. Using CPU.")
48
+
49
+ args = FakeArgs()
50
+ print(f"Using device: {args.device}")
51
+ main(args)