# Predictions with \`inference\` library are different from Visualize page

**URL:** <https://discuss.roboflow.com/t/predictions-with-inference-library-are-different-from-visualize-page/4894>\
**Category:** 🤝  Community Help\
**Created:** [March 18, 2024, 5:14pm UTC](https://discuss.roboflow.com/t/predictions-with-inference-library-are-different-from-visualize-page/4894 "2024-03-18T17:14:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonas\_Haag](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/jonas_haag/32/2744_2.png) [@Jonas\_Haag](https://discuss.roboflow.com/u/Jonas_Haag)\
**Post date:** [March 18, 2024, 5:14pm UTC](https://discuss.roboflow.com/t/predictions-with-inference-library-are-different-from-visualize-page/4894/1 "2024-03-18T17:14:44Z")

</div>

I built a local/offline prediction app using the ONNX weights and the `inference` Python library but the predictions are significantly different from those on the “Visualize” page.

Example: Red = my app

 ![Screenshot 2024-03-18 at 18.14.14](https://canada1.discourse-cdn.com/flex029/uploads/roboflow1/original/2X/3/3a86988d3de5aee4f80f63774c04d58e6d3ca047.jpeg)

Anything I’m doing wrong?

Code of the prediction app:

```py
import os

import inference
import streamlit as st
from PIL import Image, ImageDraw

model = inference.get_model(...)

# Function to draw bounding boxes on image
def draw_boxes(image, boxes):
    image = image.copy()
    img_draw = ImageDraw.Draw(image)
    for box in boxes:
        x0 = box.x - box.width / 2
        y0 = box.y - box.height / 2
        x1 = box.x + box.width / 2
        y1 = box.y + box.height / 2
        img_draw.rectangle((x0, y0, x1, y1), outline="red", width=3)
        img_draw.text((x0, y0), f"{box.confidence:.03f}", font_size=16, fill="red")
    return image

# Streamlit app
def main():
    st.title("Handwriting Detection")

    uploaded_images = st.file_uploader(
        "Images to annotate", type=["jpg", "jpeg", "png"], accept_multiple_files=True
    )
    uploaded_images = [Image.open(img).convert("RGB") for img in uploaded_images]

    for img in uploaded_images:
        pred = model.infer(img)[0]
        image_with_boxes = draw_boxes(img, pred.predictions)
        st.image(image_with_boxes, use_column_width=True)

if __name__ == " __main__":
    main()

```

---

<div class="post-metadata">

**Author:** ![Jonas\_Haag](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/jonas_haag/32/2744_2.png) [@Jonas\_Haag](https://discuss.roboflow.com/u/Jonas_Haag)\
**Post date:** [March 18, 2024, 5:50pm UTC](https://discuss.roboflow.com/t/predictions-with-inference-library-are-different-from-visualize-page/4894/2 "2024-03-18T17:50:41Z")

</div>

The answer might be in this post [Locally depoloyed model gives different result from the hosted one - #2 by camerayuhang](https://discuss.roboflow.com/t/locally-depoloyed-model-gives-different-result-from-the-hosted-one/3616/2)

---

<div class="post-metadata">

**Author:** ![Jonas\_Haag](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/jonas_haag/32/2744_2.png) [@Jonas\_Haag](https://discuss.roboflow.com/u/Jonas_Haag)\
**Post date:** [March 19, 2024, 5:54pm UTC](https://discuss.roboflow.com/t/predictions-with-inference-library-are-different-from-visualize-page/4894/3 "2024-03-19T17:54:14Z")

</div>

@Emily in that thread you say that users should tile before sending to the inference server/model. I wanted to understand how tiling is done by Roboflow and it looks like it is done server-side. Could you please refer to the piece of code that does the tiling and un-tiling? Or is this proprietary code?

Thank you!

---

<div class="post-metadata">

**Author:** ![leo](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/leo/32/2228_2.png) [@leo](https://discuss.roboflow.com/u/leo)\
**Post date:** [March 28, 2024, 3:50am UTC](https://discuss.roboflow.com/t/predictions-with-inference-library-are-different-from-visualize-page/4894/4 "2024-03-28T03:50:30Z")

</div>

Hey @Jonas_Haag

Are you using tiling as a preprocessing step while creating your dataset? If so, you can use the [Inference Slicer utility](https://supervision.roboflow.com/detection/tools/inference_slicer/) from Supervision to replicate tiling. We also have this blog post on using [SAHI](https://blog.roboflow.com/how-to-use-sahi-to-detect-small-objects/) (which is a tiling based inference technique)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex029/uploads/roboflow1/original/1X/bb6edbfa56d0cf2ee603f061e9e09103502cc8cc.png) [@system](https://discuss.roboflow.com/u/system)\
**Post date:** [April 18, 2024, 3:51am UTC](https://discuss.roboflow.com/t/predictions-with-inference-library-are-different-from-visualize-page/4894/5 "2024-04-18T03:51:21Z")

</div>

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
