# Object Detection inference on images hosted on google drive

**URL:** <https://discuss.roboflow.com/t/object-detection-inference-on-images-hosted-on-google-drive/3351>\
**Category:** 🤝  Community Help\
**Created:** [October 3, 2023, 8:00pm UTC](https://discuss.roboflow.com/t/object-detection-inference-on-images-hosted-on-google-drive/3351 "2023-10-03T20:00:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Riley-livingston](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/riley-livingston/32/2981_2.png) [@Riley-livingston](https://discuss.roboflow.com/u/Riley-livingston)\
**Post date:** [October 3, 2023, 8:00pm UTC](https://discuss.roboflow.com/t/object-detection-inference-on-images-hosted-on-google-drive/3351/1 "2023-10-03T20:00:42Z")

</div>

I’m trying to run an inference from an image working in colab and getting a 500 error.

# infer on an image hosted elsewhere

print(model.predict(“/content/drive/MyDrive/YOLOv5 Images/IMG\_0309.JPG”, hosted=True, confidence=40, overlap=30).json())

Am I missing something obvious or is there a workaround to be able to pull images from Google Drive.

---

<div class="post-metadata">

**Author:** ![Lenny](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/lenny/32/2383_2.png) [@Lenny](https://discuss.roboflow.com/u/Lenny)\
**Post date:** [October 3, 2023, 8:02pm UTC](https://discuss.roboflow.com/t/object-detection-inference-on-images-hosted-on-google-drive/3351/2 "2023-10-03T20:02:46Z")

</div>

The error you’re encountering might be due to the fact that the image you’re trying to infer is not publicly accessible. The `model.predict()` function with `hosted=True` is designed to work with images hosted on a server that are publicly accessible via a URL.

If you’re working in Google Colab and your image is stored in Google Drive, you might need to read the image into memory first, and then pass it to the `model.predict()` function. Unfortunately, the extracts provided do not contain the exact code to do this.

However, you can try the following approach:

1. Mount your Google Drive to the Colab notebook.
2. Read the image into memory using a library like OpenCV or PIL.
3. Pass the image data to the `model.predict()` function.

Here’s a rough example of how you might do this:

```python
from google.colab import drive
drive.mount('/content/gdrive')

from PIL import Image
import numpy as np

# Open the image file
img = Image.open('/content/drive/MyDrive/YOLOv5 Images/IMG_0309.JPG')
# Convert the image to numpy array
img_array = np.array(img)

# Now pass this array to model.predict
print(model.predict(img_array, confidence=40, overlap=30).json())

```

Please note that this is a general approach and might need adjustments based on your exact setup and the Roboflow library’s requirements. For more detailed instructions, you might want to refer to the [Roboflow Documentation](https://docs.roboflow.com/).

* * *

> Hi! I’m Roboflow’s AI powered bot. This is an automated response powered using AI with knowledge from our docs, blog, knowledge base, and previous forum responses. If you find this to be a helpful answer, please mark it as the solution using the checkbox icon below. If this doesn’t solve your issue, please follow up with what you’ve tried/why, and the community will continue to chime in as usual.

---

<div class="post-metadata">

**Author:** ![Riley-livingston](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/riley-livingston/32/2981_2.png) [@Riley-livingston](https://discuss.roboflow.com/u/Riley-livingston)\
**Post date:** [October 3, 2023, 8:15pm UTC](https://discuss.roboflow.com/t/object-detection-inference-on-images-hosted-on-google-drive/3351/3 "2023-10-03T20:15:16Z")

</div>

Do I need to do anything different when I’m running inference on an image with more than one object I need bounding boxes for.
