deepkyu commited on
Commit
33a2e0a
1 Parent(s): d39bc83

device setting defined by instance type

Browse files
Files changed (2) hide show
  1. app.py +2 -1
  2. demo.py +2 -2
app.py CHANGED
@@ -23,7 +23,8 @@ subprocess.call(
23
  )
24
 
25
  if __name__ == "__main__":
26
- servicer = SdmCompressionDemo()
 
27
  example_list = servicer.get_example_list()
28
 
29
  with gr.Blocks(theme='nota-ai/theme') as demo:
 
23
  )
24
 
25
  if __name__ == "__main__":
26
+ device = 'cuda' if torch.cuda.is_available() else 'cpu'
27
+ servicer = SdmCompressionDemo(device)
28
  example_list = servicer.get_example_list()
29
 
30
  with gr.Blocks(theme='nota-ai/theme') as demo:
demo.py CHANGED
@@ -11,8 +11,8 @@ DEVICE='cuda'
11
  # DEVICE='cpu'
12
 
13
  class SdmCompressionDemo:
14
- def __init__(self) -> None:
15
- self.device = DEVICE
16
  self.torch_dtype = torch.float16 if 'cuda' in self.device else torch.float32
17
 
18
  self.pipe_original = StableDiffusionPipeline.from_pretrained(ORIGINAL_CHECKPOINT_ID,
 
11
  # DEVICE='cpu'
12
 
13
  class SdmCompressionDemo:
14
+ def __init__(self, device) -> None:
15
+ self.device = device
16
  self.torch_dtype = torch.float16 if 'cuda' in self.device else torch.float32
17
 
18
  self.pipe_original = StableDiffusionPipeline.from_pretrained(ORIGINAL_CHECKPOINT_ID,