ethansmith2000 commited on
Commit
1ad84b5
Β·
1 Parent(s): 297bcf6

cuda/cpu based on availability

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -13,6 +13,7 @@ endpoint = Endpoint()
13
  is_shared_ui = True if "ethansmith2000/MegaEdit" in os.environ['SPACE_ID'] else False
14
  modelid = "runwayml/stable-diffusion-v1-5"
15
  is_gpu_associated = True if torch.cuda.is_available() else False
 
16
 
17
  # examples = [
18
  # ['square_ims/american_gothic.jpg', 'A painting of two people frowning', 'A painting of two people smiling', 0.5, 3],
@@ -68,7 +69,7 @@ Parameters explained:
68
 
69
 
70
  def main():
71
- editpipeline = MegaEdit(modelid, device="cuda", dtype=torch.float16)
72
 
73
  def generate(
74
  input_image: Image.Image,
 
13
  is_shared_ui = True if "ethansmith2000/MegaEdit" in os.environ['SPACE_ID'] else False
14
  modelid = "runwayml/stable-diffusion-v1-5"
15
  is_gpu_associated = True if torch.cuda.is_available() else False
16
+ device = "cuda" if is_gpu_associated else "cpu"
17
 
18
  # examples = [
19
  # ['square_ims/american_gothic.jpg', 'A painting of two people frowning', 'A painting of two people smiling', 0.5, 3],
 
69
 
70
 
71
  def main():
72
+ editpipeline = MegaEdit(modelid, device=device, dtype=torch.float16)
73
 
74
  def generate(
75
  input_image: Image.Image,