Spaces:
Running
on
L4
Running
on
L4
Update app.py
Browse files
app.py
CHANGED
@@ -13,6 +13,8 @@ import matplotlib.patches as patches
|
|
13 |
import random
|
14 |
import numpy as np
|
15 |
|
|
|
|
|
16 |
models = {
|
17 |
#'microsoft/Florence-2-large-ft': AutoModelForCausalLM.from_pretrained('microsoft/Florence-2-large-ft', trust_remote_code=True).to("cuda").eval(),
|
18 |
'microsoft/Florence-2-large': AutoModelForCausalLM.from_pretrained('microsoft/Florence-2-large', trust_remote_code=True).to("cuda").eval(),
|
@@ -65,6 +67,8 @@ def run_example(task_prompt, image, text_input=None, model_id='microsoft/Florenc
|
|
65 |
task=task_prompt,
|
66 |
image_size=(image.width, image.height)
|
67 |
)
|
|
|
|
|
68 |
return parsed_answer
|
69 |
|
70 |
def plot_bbox(image, data):
|
@@ -275,7 +279,7 @@ with gr.Blocks(css=css) as demo:
|
|
275 |
inputs=[input_img, task_prompt],
|
276 |
outputs=[output_text, output_img],
|
277 |
fn=process_image,
|
278 |
-
|
279 |
label='Try examples'
|
280 |
)
|
281 |
|
|
|
13 |
import random
|
14 |
import numpy as np
|
15 |
|
16 |
+
import gc
|
17 |
+
|
18 |
models = {
|
19 |
#'microsoft/Florence-2-large-ft': AutoModelForCausalLM.from_pretrained('microsoft/Florence-2-large-ft', trust_remote_code=True).to("cuda").eval(),
|
20 |
'microsoft/Florence-2-large': AutoModelForCausalLM.from_pretrained('microsoft/Florence-2-large', trust_remote_code=True).to("cuda").eval(),
|
|
|
67 |
task=task_prompt,
|
68 |
image_size=(image.width, image.height)
|
69 |
)
|
70 |
+
torch.cuda.empty_cache()
|
71 |
+
gc.collect()
|
72 |
return parsed_answer
|
73 |
|
74 |
def plot_bbox(image, data):
|
|
|
279 |
inputs=[input_img, task_prompt],
|
280 |
outputs=[output_text, output_img],
|
281 |
fn=process_image,
|
282 |
+
cache_examples=False,
|
283 |
label='Try examples'
|
284 |
)
|
285 |
|