{ "cells": [ { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "import handler\n", "import importlib\n", "\n", "importlib.reload(handler)\n", "\n", "import handler\n", "\n", "h = handler.EndpointHandler()" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "import base64\n", "from pathlib import Path\n", "\n", "if not Path(\"What-is-an-infographic.jpg\").exists():\n", " !wget https://visme.co/blog/wp-content/uploads/2020/02/What-is-an-infographic.jpg\n", "\n", "with open(\"What-is-an-infographic.jpg\", \"rb\") as f:\n", " b64 = base64.b64encode(f.read())\n", "\n", "question = \"What percent of information do we understand through body language?\"\n", "\n", "payload = {\n", " \"inputs\": {\n", " \"image\": [b64.decode(\"utf-8\")]*2, \n", " \"question\": [question]*2\n", " }, \n", " \"parameters\":{\n", " \"max_new_tokens\": 10,\n", " }}" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'output': ['55%', '55%']}" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "h(payload)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.12" } }, "nbformat": 4, "nbformat_minor": 2 }