> For the complete documentation index, see [llms.txt](https://picsellia.gitbook.io/picsellia/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://picsellia.gitbook.io/picsellia/getting-started-2/feedback-loop-send-predictions-from-models-to-datalake-or-datasets.md).

# Feedback loop - Send predictions from models to Datalake or Datasets

This tutorial assumes that you have already deployed a model using Picsell.ia. If you want to learn how to do so, please check the page below :

{% content-ref url="/pages/-MSSlxHathHS-4P-9MDA" %}
[Deploy model in production (Tensorflow only)](/picsellia/getting-started-2/deploy-model-in-production-tensorflow-only.md)
{% endcontent-ref %}

## Make predictions

To make predictions with the models you deployed using Picsll.ia, you can use the following snippet (it can be found in the deployment tab on the platform)

```python
import requests
token = "your api token"
model_id = "chosen model id"
headers = {
    "Authorization": "Token " + token
}
name = "path/to/your/image.jpg"

r = requests.post(
    url="https://eyes.picsellia.com/predict/{}".format(model_id), 
    files={'media': open(name, 'rb')},
    headers=headers)
```

The only things you need to perform prediction is your api token to authenticate you and the API endpoint of your model (which contains the model id). If you don't know it, you can find it in the deployment tab on the platform.

## Send images back to Picsell.ia

If you just want the images your perform predictions on to be sent on Picsell.ia, either in your Datalake or directly in a Dataset, here are the few things you must add.

### Send to Datalake

Now, we will send a JSON body with our request.

```python
data = {
    'loop': True,
}
r = requests.post(
    url="https://eyes.picsellia.com/predict/{}".format(model_id), 
    files={'media': open(name, 'rb')}, data=data,
    headers=headers)
```

You just have to set the `loop` parameter to True and the images will automatically be sent to your Datalake.

{% hint style="info" %}
Please note that in this case, the name of the image once in your Datalake will be something like 'model\_name-prediction-yyyy-mm-dd-hh-mm-ss.jpg'
{% endhint %}

If you want to choose the name of the file to be saved in your Datalake you can add an argument to our JSON

```python
data = {
    'loop': True,
    'name': 'my_super_image.jpg'
}
r = requests.post(
    url="https://eyes.picsellia.com/predict/{}".format(model_id), 
    files={'media': open(name, 'rb')}, data=data,
    headers=headers)
```

Now the image will be saved with the name 'my\_super\_image.jpg' in your Datalake !

### Add tags to images

If you want to add some tags to the images such as the name of the model or whatever you want, you can add a `tags` parameter to the JSON just like this.

```python
data = {
    'loop': True,
    'name': 'my_super_image.jpg',
    'tags': ['model_name', 'camera1']
}
r = requests.post(
    url="https://eyes.picsellia.com/predict/{}".format(model_id), 
    files={'media': open(name, 'rb')}, data=data,
    headers=headers)
```

{% hint style="warning" %}
The `tags` parameter must be a list !
{% endhint %}

### Send to Datalake + add to a Dataset

If you want to not only add the image to your Datalake but also automatically add it to a Dataset of your choice, it's really simple, just add a `dataset` parameter to the JSON.

```python
data = {
    'loop': True,
    'name': 'my_super_image.jpg',
    'dataset': 'my_awesome_dataset/version_name'
}
r = requests.post(
    url="https://eyes.picsellia.com/predict/{}".format(model_id), 
    files={'media': open(name, 'rb')}, data=data,
    headers=headers)
```

See ? The images are now automatically added to your Datalake AND your awesome Dataset 😉

## Send images + predictions

If you want to send the predictions (bounding-boxes, masks, classifications) along with the images to one of your Dataset, it's also possible with just two new parameters.

```python
data = {
    'loop': True,
    'dataset': 'my_awesome_dataset/version_name',
    'send_prediction': True,
    'threshold': 0.85
}
r = requests.post(
    url="https://eyes.picsellia.com/predict/{}".format(model_id), 
    files={'media': open(name, 'rb')}, data=data,
    headers=headers)
```

Just set `send_prediction` to True and the predictions will be sent along with images, you can also adjust the `threshold` of the predictions to send (the default threshold is 0.7).

{% hint style="warning" %}
As predictions (which will be vizualized as annotations) can only be send to a Dataset, the `dataset` parameter can't be null.
{% endhint %}

That's it ! You now know how to build fully operational pipelines using only Picsell.ia !

See you on the next tutorials 👋


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://picsellia.gitbook.io/picsellia/getting-started-2/feedback-loop-send-predictions-from-models-to-datalake-or-datasets.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
