Spaces:
Configuration error
Configuration error
Update app.py
Browse files
app.py
CHANGED
|
@@ -347,6 +347,8 @@ def generate(text_list, image_list, max_new_tokens, force_boi, force_bbox, force
|
|
| 347 |
generated_text = output['text']
|
| 348 |
generated_text = generated_text.replace(EOI_TOKEN, IMG_FLAG).replace(service.tokenizer.eos_token, '')
|
| 349 |
|
|
|
|
|
|
|
| 350 |
if output['has_img_output']:
|
| 351 |
# print('loading visual encoder and llm to CPU, and sd to GPU')
|
| 352 |
# a = time.time()
|
|
@@ -375,11 +377,10 @@ def generate(text_list, image_list, max_new_tokens, force_boi, force_bbox, force
|
|
| 375 |
image_base64 = encode_image(generated_image)
|
| 376 |
gen_imgs_base64_list.append(image_base64)
|
| 377 |
|
| 378 |
-
|
| 379 |
# service.vae_pipe = service.vae_pipe.to("cpu")
|
| 380 |
# service.sd_adapter = service.sd_adapter.to(service.vit_sd_device, dtype=service.dtype)
|
| 381 |
|
| 382 |
-
|
| 383 |
|
| 384 |
# print('loading visual encoder and llm to GPU, and sd to CPU')
|
| 385 |
# a = time.time()
|
|
|
|
| 347 |
generated_text = output['text']
|
| 348 |
generated_text = generated_text.replace(EOI_TOKEN, IMG_FLAG).replace(service.tokenizer.eos_token, '')
|
| 349 |
|
| 350 |
+
torch.cuda.empty_cache()
|
| 351 |
+
|
| 352 |
if output['has_img_output']:
|
| 353 |
# print('loading visual encoder and llm to CPU, and sd to GPU')
|
| 354 |
# a = time.time()
|
|
|
|
| 377 |
image_base64 = encode_image(generated_image)
|
| 378 |
gen_imgs_base64_list.append(image_base64)
|
| 379 |
|
|
|
|
| 380 |
# service.vae_pipe = service.vae_pipe.to("cpu")
|
| 381 |
# service.sd_adapter = service.sd_adapter.to(service.vit_sd_device, dtype=service.dtype)
|
| 382 |
|
| 383 |
+
torch.cuda.empty_cache()
|
| 384 |
|
| 385 |
# print('loading visual encoder and llm to GPU, and sd to CPU')
|
| 386 |
# a = time.time()
|