commit
Browse files
app.py
CHANGED
@@ -5,19 +5,9 @@ from unittest.mock import patch
|
|
5 |
import gradio as gr
|
6 |
import ast
|
7 |
from transformers import AutoModelForCausalLM, AutoProcessor
|
8 |
-
from transformers.dynamic_module_utils import get_imports
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
if not str(filename).endswith("/modeling_florence2.py"):
|
13 |
-
return get_imports(filename)
|
14 |
-
imports = get_imports(filename)
|
15 |
-
imports.remove("flash_attn")
|
16 |
-
return imports
|
17 |
-
|
18 |
-
with patch("transformers.dynamic_module_utils.get_imports", fixed_get_imports):
|
19 |
-
model = AutoModelForCausalLM.from_pretrained("microsoft/Florence-2-large-ft", trust_remote_code=True)
|
20 |
-
processor = AutoProcessor.from_pretrained("microsoft/Florence-2-large-ft", trust_remote_code=True)
|
21 |
|
22 |
def draw_boxes(image, quad_boxes):
|
23 |
draw = ImageDraw.Draw(image)
|
|
|
5 |
import gradio as gr
|
6 |
import ast
|
7 |
from transformers import AutoModelForCausalLM, AutoProcessor
|
|
|
8 |
|
9 |
+
model = AutoModelForCausalLM.from_pretrained("microsoft/Florence-2-large-ft", trust_remote_code=True)
|
10 |
+
processor = AutoProcessor.from_pretrained("microsoft/Florence-2-large-ft", trust_remote_code=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
def draw_boxes(image, quad_boxes):
|
13 |
draw = ImageDraw.Draw(image)
|