Spaces:
Runtime error
Runtime error
Commit
Β·
f1a4346
1
Parent(s):
42b759b
test input
Browse files
app.py
CHANGED
|
@@ -103,13 +103,26 @@ def deepseek(image, text_input):
|
|
| 103 |
)
|
| 104 |
|
| 105 |
answer = tokenizer.decode(outputs[0].cpu().tolist(), skip_special_tokens=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
print(f"{prepare_inputs['sft_format'][0]}", answer)
|
| 107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
@spaces.GPU
|
| 110 |
def run_example(image, text_input, model_id="OS-Copilot/OS-Atlas-Base-7B"):
|
| 111 |
|
| 112 |
-
deepseek(image, text_input)
|
| 113 |
|
| 114 |
|
| 115 |
def run_example_old(image, text_input, model_id="OS-Copilot/OS-Atlas-Base-7B"):
|
|
|
|
| 103 |
)
|
| 104 |
|
| 105 |
answer = tokenizer.decode(outputs[0].cpu().tolist(), skip_special_tokens=False)
|
| 106 |
+
|
| 107 |
+
object_ref_pattern = r"<\|object_ref_start\|>(.*?)<\|object_ref_end\|>"
|
| 108 |
+
det_pattern = r"<\|det\|>\[\[(.+)]]<\|\/det\|>"
|
| 109 |
+
|
| 110 |
+
det_content = re.search(det_pattern, answer).group(1)
|
| 111 |
+
bbox = [ int(v.trim()) / 999 for v in det_content.split(",")]
|
| 112 |
+
w, h = image.size()
|
| 113 |
+
bbox = [bbox[0] * w, bbox[1] * h, bbox[2] * w, bbox[3] * h]
|
| 114 |
+
answer
|
| 115 |
print(f"{prepare_inputs['sft_format'][0]}", answer)
|
| 116 |
|
| 117 |
+
|
| 118 |
+
scaled_boxes = rescale_bounding_boxes(bbox, image.width, image.height)
|
| 119 |
+
return text_input, scaled_boxes, draw_bounding_boxes(image, scaled_boxes)
|
| 120 |
+
|
| 121 |
|
| 122 |
@spaces.GPU
|
| 123 |
def run_example(image, text_input, model_id="OS-Copilot/OS-Atlas-Base-7B"):
|
| 124 |
|
| 125 |
+
return deepseek(image, text_input)
|
| 126 |
|
| 127 |
|
| 128 |
def run_example_old(image, text_input, model_id="OS-Copilot/OS-Atlas-Base-7B"):
|