<jupyter_start><jupyter_text><jupyter_code>!pip install -q --no-cache-dir git+https://github.com/yhatpub/yhat_params.git@main
import torch.nn.functional as F
import torch
import io
import base64
import json

from yhat_params.yhat_tools import inference_test, FieldType, inference_predict

input = {"text": FieldType.Text, "image": FieldType.PIL}
output = {"text": FieldType.Text, "image": FieldType.PIL}

@inference_predict(input=input, output=output)
def predict(params):
    text = params['text']
    image = params['image'].convert("RGB")
    return {"text": text, "image": image}
from yhat_params.yhat_tools import in_colab
from PIL import Image

if in_colab():
    torch.hub.download_url_to_file('https://upload.wikimedia.org/wikipedia/en/4/48/Blank.JPG', '1x1.jpg')
    img = Image.open('1x1.jpg')  

if in_colab():
    inference_test(predict_func=predict, params={'text': 'my text', 'image': img})<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14775160599571735, 'fraction_numerical': 0.009635974304068522, 'mean_word_length': 5.726618705035971, 'pattern_counts': {'":': 6, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '378789', 'license': 'Apache-2.0', 'n_tokens_mistral': 336, 'n_tokens_neox': 331, 'n_words': 68, 'path': 'notebooks/unit_tests/unit_test.ipynb', 'repo_name': 'yhatpub/yhatpub', 'size': '934'}