willsh1997 commited on
Commit
86af578
·
verified ·
1 Parent(s): a4b49a6

TRY ME BITCH

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -314,11 +314,12 @@ class customUnClipPipeline(UnCLIPImageVariationPipeline):
314
 
315
 
316
  ### ADDITIONAL PIPELINE CODE FOR KARLO
317
- torch_device = 'cuda'
318
  pipe = customUnClipPipeline.from_pretrained("kakaobrain/karlo-v1-alpha-image-variations", torch_dtype=torch.float32, trust_remote_code=True,
319
  # accelerator='ort', device=torch_device
 
320
  )
321
- pipe.to(torch_device)
322
  # pipe.enable_model_cpu_offload()
323
 
324
 
@@ -333,7 +334,6 @@ def load_img_from_URL(URL):
333
  init_image = Image.open(BytesIO(response.content)).convert("RGB")
334
  return init_image
335
 
336
- @spaces.GPU
337
  def embed_img(input_image):
338
  tokens = pipe.feature_extractor(input_image).to(torch_device)
339
  img_model = pipe.image_encoder.to(torch_device)
@@ -419,7 +419,7 @@ will_cand_tensors = torch.cat([chaosclicker_willtensor,
419
  @spaces.GPU
420
  def generate_freak():
421
  will_randomised_input = random_candtensor(will_cand_tensors).unsqueeze(0)
422
- will_randomised_input.to(torch_device)
423
  output = pipe(image_embeddings=will_randomised_input, num_images_per_prompt=1, decoder_num_inference_steps = 15, super_res_num_inference_steps = 4)
424
  return output.images[0]
425
 
 
314
 
315
 
316
  ### ADDITIONAL PIPELINE CODE FOR KARLO
317
+ torch_device = 'cpu'
318
  pipe = customUnClipPipeline.from_pretrained("kakaobrain/karlo-v1-alpha-image-variations", torch_dtype=torch.float32, trust_remote_code=True,
319
  # accelerator='ort', device=torch_device
320
+ device_map='cpu'
321
  )
322
+ # pipe.to(torch_device)
323
  # pipe.enable_model_cpu_offload()
324
 
325
 
 
334
  init_image = Image.open(BytesIO(response.content)).convert("RGB")
335
  return init_image
336
 
 
337
  def embed_img(input_image):
338
  tokens = pipe.feature_extractor(input_image).to(torch_device)
339
  img_model = pipe.image_encoder.to(torch_device)
 
419
  @spaces.GPU
420
  def generate_freak():
421
  will_randomised_input = random_candtensor(will_cand_tensors).unsqueeze(0)
422
+ will_randomised_input.to("cuda")
423
  output = pipe(image_embeddings=will_randomised_input, num_images_per_prompt=1, decoder_num_inference_steps = 15, super_res_num_inference_steps = 4)
424
  return output.images[0]
425