Update README.md
Browse files
README.md
CHANGED
|
@@ -29,7 +29,6 @@ It achieves the following results on the evaluation set:
|
|
| 29 |
processor = AutoProcessor.from_pretrained("Musa07/Florence-2-large-FormClassification-ft", trust_remote_code=True)
|
| 30 |
|
| 31 |
def run_example(task_prompt, image, max_new_tokens=128):
|
| 32 |
-
|
| 33 |
prompt = task_prompt
|
| 34 |
inputs = processor(text=prompt, images=image, return_tensors="pt")
|
| 35 |
generated_ids = model.generate(
|
|
@@ -47,9 +46,8 @@ It achieves the following results on the evaluation set:
|
|
| 47 |
image_size=(image.width, image.height)
|
| 48 |
)
|
| 49 |
return parsed_answer
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
fig, ax = plt.subplots()
|
| 54 |
|
| 55 |
# Display the image
|
|
@@ -72,10 +70,10 @@ It achieves the following results on the evaluation set:
|
|
| 72 |
# Show the plot
|
| 73 |
plt.show()
|
| 74 |
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
|
| 80 |
|
| 81 |
|
|
|
|
| 29 |
processor = AutoProcessor.from_pretrained("Musa07/Florence-2-large-FormClassification-ft", trust_remote_code=True)
|
| 30 |
|
| 31 |
def run_example(task_prompt, image, max_new_tokens=128):
|
|
|
|
| 32 |
prompt = task_prompt
|
| 33 |
inputs = processor(text=prompt, images=image, return_tensors="pt")
|
| 34 |
generated_ids = model.generate(
|
|
|
|
| 46 |
image_size=(image.width, image.height)
|
| 47 |
)
|
| 48 |
return parsed_answer
|
| 49 |
+
|
| 50 |
+
def plot_bbox(image, data):
|
|
|
|
| 51 |
fig, ax = plt.subplots()
|
| 52 |
|
| 53 |
# Display the image
|
|
|
|
| 70 |
# Show the plot
|
| 71 |
plt.show()
|
| 72 |
|
| 73 |
+
image = Image.open('1.jpeg')
|
| 74 |
+
parsed_answer = run_example("<OD>", image=image)
|
| 75 |
+
print(parsed_answer)
|
| 76 |
+
plot_bbox(image, parsed_answer["<OD>"])
|
| 77 |
|
| 78 |
|
| 79 |
|