{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/ritesh.thawkar/Ritesh/nutrigenics/nutrigenics-chatbot/chatbot-env/lib/python3.9/site-packages/urllib3/__init__.py:35: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020\n", " warnings.warn(\n", "/Users/ritesh.thawkar/Ritesh/nutrigenics/nutrigenics-chatbot/chatbot-env/lib/python3.9/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", " from .autonotebook import tqdm as notebook_tqdm\n" ] } ], "source": [ "import pandas as pd\n", "import json\n", "from PIL import Image\n", "import numpy as np\n", "import gradio as gr " ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import os\n", "import sys\n", "from pathlib import Path\n", "\n", "import torch\n", "import torch.nn.functional as F\n", "\n", "from src.data.embs import ImageDataset\n", "from src.model.blip_embs import blip_embs" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "from src.data.transforms import transform_test\n", "#\n", "transform = transform_test(384)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [], "source": [ "import json \n", "import numpy as np \n", "from PIL import Image\n", "import torch.nn.functional as F\n", "import torch\n", "from transformers import StoppingCriteria, StoppingCriteriaList, TextIteratorStreamer\n", "\n", "\n", "\n", "class StoppingCriteriaSub(StoppingCriteria):\n", "\n", " def __init__(self, stops=[], encounters=1):\n", " super().__init__()\n", " self.stops = stops\n", "\n", " def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor):\n", " for stop in self.stops:\n", " if torch.all(input_ids[:, -len(stop):] == stop).item():\n", " return True\n", "\n", " return False\n", "\n", "\n", "\n", "class Chat:\n", "\n", " def __init__(self, model, transform, dataframe, tar_img_feats, device='cuda:0', stopping_criteria=None):\n", " self.device = device\n", " self.model = model\n", " self.transform = transform\n", " self.df = dataframe\n", " self.tar_img_feats = tar_img_feats\n", " self.img_feats = None\n", " self.target_recipe = None\n", " self.messages = []\n", "\n", " if stopping_criteria is not None:\n", " self.stopping_criteria = stopping_criteria\n", " else:\n", " stop_words_ids = [torch.tensor([2]).to(self.device)]\n", " self.stopping_criteria = StoppingCriteriaList([StoppingCriteriaSub(stops=stop_words_ids)])\n", "\n", " def encode_image(self, image_path):\n", " img = Image.fromarray(image_path).convert(\"RGB\")\n", " img = self.transform(img).unsqueeze(0)\n", " img = img.to(self.device)\n", " img_embs = self.model.visual_encoder(img)\n", " img_feats = F.normalize(self.model.vision_proj(img_embs[:, 0, :]), dim=-1).cpu()\n", "\n", " self.img_feats = img_feats \n", "\n", " self.get_target(self.img_feats, self.tar_img_feats)\n", "\n", " def get_target(self, img_feats, tar_img_feats) : \n", " score = (img_feats @ tar_img_feats.t()).squeeze(0).cpu().detach().numpy()\n", " index = np.argsort(score)[::-1][0]\n", " print(index)\n", " self.target_recipe = self.df.iloc[index]\n", "\n", " def ask(self, msg):\n", " if \"nutrition\" in msg or \"nutrients\" in msg : \n", " return json.dumps(self.target_recipe[\"recipe_nutrients\"], indent=4)\n", " elif \"instruction\" in msg :\n", " return json.dumps(self.target_recipe[\"recipe_instructions\"], indent=4)\n", " elif \"ingredients\" in msg :\n", " return json.dumps(self.target_recipe[\"recipe_ingredients\"], indent=4)\n", " elif \"tag\" in msg or \"class\" in msg :\n", " return json.dumps(self.target_recipe[\"tags\"], indent=4)\n", " else:\n", " return \"Conversational capabilities will be included later.\"\n" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "def get_blip_config(model=\"base\"):\n", " config = dict()\n", " if model == \"base\":\n", " config[\n", " \"pretrained\"\n", " ] = \"https://storage.googleapis.com/sfr-vision-language-research/BLIP/models/model_base_capfilt_large.pth \"\n", " config[\"vit\"] = \"base\"\n", " config[\"batch_size_train\"] = 32\n", " config[\"batch_size_test\"] = 16\n", " config[\"vit_grad_ckpt\"] = True\n", " config[\"vit_ckpt_layer\"] = 4\n", " config[\"init_lr\"] = 1e-5\n", " elif model == \"large\":\n", " config[\n", " \"pretrained\"\n", " ] = \"https://storage.googleapis.com/sfr-vision-language-research/BLIP/models/model_large_retrieval_coco.pth\"\n", " config[\"vit\"] = \"large\"\n", " config[\"batch_size_train\"] = 16\n", " config[\"batch_size_test\"] = 32\n", " config[\"vit_grad_ckpt\"] = True\n", " config[\"vit_ckpt_layer\"] = 12\n", " config[\"init_lr\"] = 5e-6\n", "\n", " config[\"image_size\"] = 384\n", " config[\"queue_size\"] = 57600\n", " config[\"alpha\"] = 0.4\n", " config[\"k_test\"] = 256\n", " config[\"negative_all_rank\"] = True\n", "\n", " return config" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Creating model\n", "load checkpoint from https://storage.googleapis.com/sfr-vision-language-research/BLIP/models/model_large_retrieval_coco.pth\n", "missing keys:\n", "[]\n" ] }, { "data": { "text/plain": [ "BLIPEmbs(\n", " (visual_encoder): VisionTransformer(\n", " (patch_embed): PatchEmbed(\n", " (proj): Conv2d(3, 1024, kernel_size=(16, 16), stride=(16, 16))\n", " (norm): Identity()\n", " )\n", " (pos_drop): Dropout(p=0.0, inplace=False)\n", " (blocks): ModuleList(\n", " (0): Block(\n", " (norm1): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (attn): Attention(\n", " (qkv): Linear(in_features=1024, out_features=3072, bias=True)\n", " (attn_drop): Dropout(p=0.0, inplace=False)\n", " (proj): Linear(in_features=1024, out_features=1024, bias=True)\n", " (proj_drop): Dropout(p=0.0, inplace=False)\n", " )\n", " (drop_path): Identity()\n", " (norm2): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (mlp): Mlp(\n", " (fc1): Linear(in_features=1024, out_features=4096, bias=True)\n", " (act): GELU(approximate='none')\n", " (fc2): Linear(in_features=4096, out_features=1024, bias=True)\n", " (drop): Dropout(p=0.0, inplace=False)\n", " )\n", " )\n", " (1): Block(\n", " (norm1): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (attn): Attention(\n", " (qkv): Linear(in_features=1024, out_features=3072, bias=True)\n", " (attn_drop): Dropout(p=0.0, inplace=False)\n", " (proj): Linear(in_features=1024, out_features=1024, bias=True)\n", " (proj_drop): Dropout(p=0.0, inplace=False)\n", " )\n", " (drop_path): DropPath(drop_prob=0.004)\n", " (norm2): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (mlp): Mlp(\n", " (fc1): Linear(in_features=1024, out_features=4096, bias=True)\n", " (act): GELU(approximate='none')\n", " (fc2): Linear(in_features=4096, out_features=1024, bias=True)\n", " (drop): Dropout(p=0.0, inplace=False)\n", " )\n", " )\n", " (2): Block(\n", " (norm1): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (attn): Attention(\n", " (qkv): Linear(in_features=1024, out_features=3072, bias=True)\n", " (attn_drop): Dropout(p=0.0, inplace=False)\n", " (proj): Linear(in_features=1024, out_features=1024, bias=True)\n", " (proj_drop): Dropout(p=0.0, inplace=False)\n", " )\n", " (drop_path): DropPath(drop_prob=0.009)\n", " (norm2): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (mlp): Mlp(\n", " (fc1): Linear(in_features=1024, out_features=4096, bias=True)\n", " (act): GELU(approximate='none')\n", " (fc2): Linear(in_features=4096, out_features=1024, bias=True)\n", " (drop): Dropout(p=0.0, inplace=False)\n", " )\n", " )\n", " (3): Block(\n", " (norm1): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (attn): Attention(\n", " (qkv): Linear(in_features=1024, out_features=3072, bias=True)\n", " (attn_drop): Dropout(p=0.0, inplace=False)\n", " (proj): Linear(in_features=1024, out_features=1024, bias=True)\n", " (proj_drop): Dropout(p=0.0, inplace=False)\n", " )\n", " (drop_path): DropPath(drop_prob=0.013)\n", " (norm2): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (mlp): Mlp(\n", " (fc1): Linear(in_features=1024, out_features=4096, bias=True)\n", " (act): GELU(approximate='none')\n", " (fc2): Linear(in_features=4096, out_features=1024, bias=True)\n", " (drop): Dropout(p=0.0, inplace=False)\n", " )\n", " )\n", " (4): Block(\n", " (norm1): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (attn): Attention(\n", " (qkv): Linear(in_features=1024, out_features=3072, bias=True)\n", " (attn_drop): Dropout(p=0.0, inplace=False)\n", " (proj): Linear(in_features=1024, out_features=1024, bias=True)\n", " (proj_drop): Dropout(p=0.0, inplace=False)\n", " )\n", " (drop_path): DropPath(drop_prob=0.017)\n", " (norm2): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (mlp): Mlp(\n", " (fc1): Linear(in_features=1024, out_features=4096, bias=True)\n", " (act): GELU(approximate='none')\n", " (fc2): Linear(in_features=4096, out_features=1024, bias=True)\n", " (drop): Dropout(p=0.0, inplace=False)\n", " )\n", " )\n", " (5): Block(\n", " (norm1): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (attn): Attention(\n", " (qkv): Linear(in_features=1024, out_features=3072, bias=True)\n", " (attn_drop): Dropout(p=0.0, inplace=False)\n", " (proj): Linear(in_features=1024, out_features=1024, bias=True)\n", " (proj_drop): Dropout(p=0.0, inplace=False)\n", " )\n", " (drop_path): DropPath(drop_prob=0.022)\n", " (norm2): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (mlp): Mlp(\n", " (fc1): Linear(in_features=1024, out_features=4096, bias=True)\n", " (act): GELU(approximate='none')\n", " (fc2): Linear(in_features=4096, out_features=1024, bias=True)\n", " (drop): Dropout(p=0.0, inplace=False)\n", " )\n", " )\n", " (6): Block(\n", " (norm1): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (attn): Attention(\n", " (qkv): Linear(in_features=1024, out_features=3072, bias=True)\n", " (attn_drop): Dropout(p=0.0, inplace=False)\n", " (proj): Linear(in_features=1024, out_features=1024, bias=True)\n", " (proj_drop): Dropout(p=0.0, inplace=False)\n", " )\n", " (drop_path): DropPath(drop_prob=0.026)\n", " (norm2): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (mlp): Mlp(\n", " (fc1): Linear(in_features=1024, out_features=4096, bias=True)\n", " (act): GELU(approximate='none')\n", " (fc2): Linear(in_features=4096, out_features=1024, bias=True)\n", " (drop): Dropout(p=0.0, inplace=False)\n", " )\n", " )\n", " (7): Block(\n", " (norm1): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (attn): Attention(\n", " (qkv): Linear(in_features=1024, out_features=3072, bias=True)\n", " (attn_drop): Dropout(p=0.0, inplace=False)\n", " (proj): Linear(in_features=1024, out_features=1024, bias=True)\n", " (proj_drop): Dropout(p=0.0, inplace=False)\n", " )\n", " (drop_path): DropPath(drop_prob=0.030)\n", " (norm2): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (mlp): Mlp(\n", " (fc1): Linear(in_features=1024, out_features=4096, bias=True)\n", " (act): GELU(approximate='none')\n", " (fc2): Linear(in_features=4096, out_features=1024, bias=True)\n", " (drop): Dropout(p=0.0, inplace=False)\n", " )\n", " )\n", " (8): Block(\n", " (norm1): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (attn): Attention(\n", " (qkv): Linear(in_features=1024, out_features=3072, bias=True)\n", " (attn_drop): Dropout(p=0.0, inplace=False)\n", " (proj): Linear(in_features=1024, out_features=1024, bias=True)\n", " (proj_drop): Dropout(p=0.0, inplace=False)\n", " )\n", " (drop_path): DropPath(drop_prob=0.035)\n", " (norm2): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (mlp): Mlp(\n", " (fc1): Linear(in_features=1024, out_features=4096, bias=True)\n", " (act): GELU(approximate='none')\n", " (fc2): Linear(in_features=4096, out_features=1024, bias=True)\n", " (drop): Dropout(p=0.0, inplace=False)\n", " )\n", " )\n", " (9): Block(\n", " (norm1): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (attn): Attention(\n", " (qkv): Linear(in_features=1024, out_features=3072, bias=True)\n", " (attn_drop): Dropout(p=0.0, inplace=False)\n", " (proj): Linear(in_features=1024, out_features=1024, bias=True)\n", " (proj_drop): Dropout(p=0.0, inplace=False)\n", " )\n", " (drop_path): DropPath(drop_prob=0.039)\n", " (norm2): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (mlp): Mlp(\n", " (fc1): Linear(in_features=1024, out_features=4096, bias=True)\n", " (act): GELU(approximate='none')\n", " (fc2): Linear(in_features=4096, out_features=1024, bias=True)\n", " (drop): Dropout(p=0.0, inplace=False)\n", " )\n", " )\n", " (10): Block(\n", " (norm1): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (attn): Attention(\n", " (qkv): Linear(in_features=1024, out_features=3072, bias=True)\n", " (attn_drop): Dropout(p=0.0, inplace=False)\n", " (proj): Linear(in_features=1024, out_features=1024, bias=True)\n", " (proj_drop): Dropout(p=0.0, inplace=False)\n", " )\n", " (drop_path): DropPath(drop_prob=0.043)\n", " (norm2): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (mlp): Mlp(\n", " (fc1): Linear(in_features=1024, out_features=4096, bias=True)\n", " (act): GELU(approximate='none')\n", " (fc2): Linear(in_features=4096, out_features=1024, bias=True)\n", " (drop): Dropout(p=0.0, inplace=False)\n", " )\n", " )\n", " (11): Block(\n", " (norm1): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (attn): Attention(\n", " (qkv): Linear(in_features=1024, out_features=3072, bias=True)\n", " (attn_drop): Dropout(p=0.0, inplace=False)\n", " (proj): Linear(in_features=1024, out_features=1024, bias=True)\n", " (proj_drop): Dropout(p=0.0, inplace=False)\n", " )\n", " (drop_path): DropPath(drop_prob=0.048)\n", " (norm2): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (mlp): Mlp(\n", " (fc1): Linear(in_features=1024, out_features=4096, bias=True)\n", " (act): GELU(approximate='none')\n", " (fc2): Linear(in_features=4096, out_features=1024, bias=True)\n", " (drop): Dropout(p=0.0, inplace=False)\n", " )\n", " )\n", " (12): Block(\n", " (norm1): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (attn): Attention(\n", " (qkv): Linear(in_features=1024, out_features=3072, bias=True)\n", " (attn_drop): Dropout(p=0.0, inplace=False)\n", " (proj): Linear(in_features=1024, out_features=1024, bias=True)\n", " (proj_drop): Dropout(p=0.0, inplace=False)\n", " )\n", " (drop_path): DropPath(drop_prob=0.052)\n", " (norm2): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (mlp): Mlp(\n", " (fc1): Linear(in_features=1024, out_features=4096, bias=True)\n", " (act): GELU(approximate='none')\n", " (fc2): Linear(in_features=4096, out_features=1024, bias=True)\n", " (drop): Dropout(p=0.0, inplace=False)\n", " )\n", " )\n", " (13): Block(\n", " (norm1): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (attn): Attention(\n", " (qkv): Linear(in_features=1024, out_features=3072, bias=True)\n", " (attn_drop): Dropout(p=0.0, inplace=False)\n", " (proj): Linear(in_features=1024, out_features=1024, bias=True)\n", " (proj_drop): Dropout(p=0.0, inplace=False)\n", " )\n", " (drop_path): DropPath(drop_prob=0.057)\n", " (norm2): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (mlp): Mlp(\n", " (fc1): Linear(in_features=1024, out_features=4096, bias=True)\n", " (act): GELU(approximate='none')\n", " (fc2): Linear(in_features=4096, out_features=1024, bias=True)\n", " (drop): Dropout(p=0.0, inplace=False)\n", " )\n", " )\n", " (14): Block(\n", " (norm1): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (attn): Attention(\n", " (qkv): Linear(in_features=1024, out_features=3072, bias=True)\n", " (attn_drop): Dropout(p=0.0, inplace=False)\n", " (proj): Linear(in_features=1024, out_features=1024, bias=True)\n", " (proj_drop): Dropout(p=0.0, inplace=False)\n", " )\n", " (drop_path): DropPath(drop_prob=0.061)\n", " (norm2): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (mlp): Mlp(\n", " (fc1): Linear(in_features=1024, out_features=4096, bias=True)\n", " (act): GELU(approximate='none')\n", " (fc2): Linear(in_features=4096, out_features=1024, bias=True)\n", " (drop): Dropout(p=0.0, inplace=False)\n", " )\n", " )\n", " (15): Block(\n", " (norm1): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (attn): Attention(\n", " (qkv): Linear(in_features=1024, out_features=3072, bias=True)\n", " (attn_drop): Dropout(p=0.0, inplace=False)\n", " (proj): Linear(in_features=1024, out_features=1024, bias=True)\n", " (proj_drop): Dropout(p=0.0, inplace=False)\n", " )\n", " (drop_path): DropPath(drop_prob=0.065)\n", " (norm2): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (mlp): Mlp(\n", " (fc1): Linear(in_features=1024, out_features=4096, bias=True)\n", " (act): GELU(approximate='none')\n", " (fc2): Linear(in_features=4096, out_features=1024, bias=True)\n", " (drop): Dropout(p=0.0, inplace=False)\n", " )\n", " )\n", " (16): Block(\n", " (norm1): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (attn): Attention(\n", " (qkv): Linear(in_features=1024, out_features=3072, bias=True)\n", " (attn_drop): Dropout(p=0.0, inplace=False)\n", " (proj): Linear(in_features=1024, out_features=1024, bias=True)\n", " (proj_drop): Dropout(p=0.0, inplace=False)\n", " )\n", " (drop_path): DropPath(drop_prob=0.070)\n", " (norm2): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (mlp): Mlp(\n", " (fc1): Linear(in_features=1024, out_features=4096, bias=True)\n", " (act): GELU(approximate='none')\n", " (fc2): Linear(in_features=4096, out_features=1024, bias=True)\n", " (drop): Dropout(p=0.0, inplace=False)\n", " )\n", " )\n", " (17): Block(\n", " (norm1): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (attn): Attention(\n", " (qkv): Linear(in_features=1024, out_features=3072, bias=True)\n", " (attn_drop): Dropout(p=0.0, inplace=False)\n", " (proj): Linear(in_features=1024, out_features=1024, bias=True)\n", " (proj_drop): Dropout(p=0.0, inplace=False)\n", " )\n", " (drop_path): DropPath(drop_prob=0.074)\n", " (norm2): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (mlp): Mlp(\n", " (fc1): Linear(in_features=1024, out_features=4096, bias=True)\n", " (act): GELU(approximate='none')\n", " (fc2): Linear(in_features=4096, out_features=1024, bias=True)\n", " (drop): Dropout(p=0.0, inplace=False)\n", " )\n", " )\n", " (18): Block(\n", " (norm1): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (attn): Attention(\n", " (qkv): Linear(in_features=1024, out_features=3072, bias=True)\n", " (attn_drop): Dropout(p=0.0, inplace=False)\n", " (proj): Linear(in_features=1024, out_features=1024, bias=True)\n", " (proj_drop): Dropout(p=0.0, inplace=False)\n", " )\n", " (drop_path): DropPath(drop_prob=0.078)\n", " (norm2): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (mlp): Mlp(\n", " (fc1): Linear(in_features=1024, out_features=4096, bias=True)\n", " (act): GELU(approximate='none')\n", " (fc2): Linear(in_features=4096, out_features=1024, bias=True)\n", " (drop): Dropout(p=0.0, inplace=False)\n", " )\n", " )\n", " (19): Block(\n", " (norm1): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (attn): Attention(\n", " (qkv): Linear(in_features=1024, out_features=3072, bias=True)\n", " (attn_drop): Dropout(p=0.0, inplace=False)\n", " (proj): Linear(in_features=1024, out_features=1024, bias=True)\n", " (proj_drop): Dropout(p=0.0, inplace=False)\n", " )\n", " (drop_path): DropPath(drop_prob=0.083)\n", " (norm2): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (mlp): Mlp(\n", " (fc1): Linear(in_features=1024, out_features=4096, bias=True)\n", " (act): GELU(approximate='none')\n", " (fc2): Linear(in_features=4096, out_features=1024, bias=True)\n", " (drop): Dropout(p=0.0, inplace=False)\n", " )\n", " )\n", " (20): Block(\n", " (norm1): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (attn): Attention(\n", " (qkv): Linear(in_features=1024, out_features=3072, bias=True)\n", " (attn_drop): Dropout(p=0.0, inplace=False)\n", " (proj): Linear(in_features=1024, out_features=1024, bias=True)\n", " (proj_drop): Dropout(p=0.0, inplace=False)\n", " )\n", " (drop_path): DropPath(drop_prob=0.087)\n", " (norm2): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (mlp): Mlp(\n", " (fc1): Linear(in_features=1024, out_features=4096, bias=True)\n", " (act): GELU(approximate='none')\n", " (fc2): Linear(in_features=4096, out_features=1024, bias=True)\n", " (drop): Dropout(p=0.0, inplace=False)\n", " )\n", " )\n", " (21): Block(\n", " (norm1): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (attn): Attention(\n", " (qkv): Linear(in_features=1024, out_features=3072, bias=True)\n", " (attn_drop): Dropout(p=0.0, inplace=False)\n", " (proj): Linear(in_features=1024, out_features=1024, bias=True)\n", " (proj_drop): Dropout(p=0.0, inplace=False)\n", " )\n", " (drop_path): DropPath(drop_prob=0.091)\n", " (norm2): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (mlp): Mlp(\n", " (fc1): Linear(in_features=1024, out_features=4096, bias=True)\n", " (act): GELU(approximate='none')\n", " (fc2): Linear(in_features=4096, out_features=1024, bias=True)\n", " (drop): Dropout(p=0.0, inplace=False)\n", " )\n", " )\n", " (22): Block(\n", " (norm1): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (attn): Attention(\n", " (qkv): Linear(in_features=1024, out_features=3072, bias=True)\n", " (attn_drop): Dropout(p=0.0, inplace=False)\n", " (proj): Linear(in_features=1024, out_features=1024, bias=True)\n", " (proj_drop): Dropout(p=0.0, inplace=False)\n", " )\n", " (drop_path): DropPath(drop_prob=0.096)\n", " (norm2): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (mlp): Mlp(\n", " (fc1): Linear(in_features=1024, out_features=4096, bias=True)\n", " (act): GELU(approximate='none')\n", " (fc2): Linear(in_features=4096, out_features=1024, bias=True)\n", " (drop): Dropout(p=0.0, inplace=False)\n", " )\n", " )\n", " (23): Block(\n", " (norm1): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (attn): Attention(\n", " (qkv): Linear(in_features=1024, out_features=3072, bias=True)\n", " (attn_drop): Dropout(p=0.0, inplace=False)\n", " (proj): Linear(in_features=1024, out_features=1024, bias=True)\n", " (proj_drop): Dropout(p=0.0, inplace=False)\n", " )\n", " (drop_path): DropPath(drop_prob=0.100)\n", " (norm2): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " (mlp): Mlp(\n", " (fc1): Linear(in_features=1024, out_features=4096, bias=True)\n", " (act): GELU(approximate='none')\n", " (fc2): Linear(in_features=4096, out_features=1024, bias=True)\n", " (drop): Dropout(p=0.0, inplace=False)\n", " )\n", " )\n", " )\n", " (norm): LayerNorm((1024,), eps=1e-06, elementwise_affine=True)\n", " )\n", " (text_encoder): BertModel(\n", " (embeddings): BertEmbeddings(\n", " (word_embeddings): Embedding(30524, 768, padding_idx=0)\n", " (position_embeddings): Embedding(512, 768)\n", " (LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)\n", " (dropout): Dropout(p=0.1, inplace=False)\n", " )\n", " (encoder): BertEncoder(\n", " (layer): ModuleList(\n", " (0-11): 12 x BertLayer(\n", " (attention): BertAttention(\n", " (self): BertSelfAttention(\n", " (query): Linear(in_features=768, out_features=768, bias=True)\n", " (key): Linear(in_features=768, out_features=768, bias=True)\n", " (value): Linear(in_features=768, out_features=768, bias=True)\n", " (dropout): Dropout(p=0.1, inplace=False)\n", " )\n", " (output): BertSelfOutput(\n", " (dense): Linear(in_features=768, out_features=768, bias=True)\n", " (LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)\n", " (dropout): Dropout(p=0.1, inplace=False)\n", " )\n", " )\n", " (crossattention): BertAttention(\n", " (self): BertSelfAttention(\n", " (query): Linear(in_features=768, out_features=768, bias=True)\n", " (key): Linear(in_features=1024, out_features=768, bias=True)\n", " (value): Linear(in_features=1024, out_features=768, bias=True)\n", " (dropout): Dropout(p=0.1, inplace=False)\n", " )\n", " (output): BertSelfOutput(\n", " (dense): Linear(in_features=768, out_features=768, bias=True)\n", " (LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)\n", " (dropout): Dropout(p=0.1, inplace=False)\n", " )\n", " )\n", " (intermediate): BertIntermediate(\n", " (dense): Linear(in_features=768, out_features=3072, bias=True)\n", " (intermediate_act_fn): GELUActivation()\n", " )\n", " (output): BertOutput(\n", " (dense): Linear(in_features=3072, out_features=768, bias=True)\n", " (LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)\n", " (dropout): Dropout(p=0.1, inplace=False)\n", " )\n", " )\n", " )\n", " )\n", " )\n", " (vision_proj): Linear(in_features=1024, out_features=256, bias=True)\n", " (text_proj): Linear(in_features=768, out_features=256, bias=True)\n", ")" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "print(\"Creating model\")\n", "config = get_blip_config(\"large\")\n", "\n", "model = blip_embs(\n", " pretrained=config[\"pretrained\"],\n", " image_size=config[\"image_size\"],\n", " vit=config[\"vit\"],\n", " vit_grad_ckpt=config[\"vit_grad_ckpt\"],\n", " vit_ckpt_layer=config[\"vit_ckpt_layer\"],\n", " queue_size=config[\"queue_size\"],\n", " negative_all_rank=config[\"negative_all_rank\"],\n", " )\n", "\n", "model = model.to(device)\n", "model.eval()" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "df = pd.read_json(\"datasets/sidechef/my_recipes.json\")" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
recipe_namerecipe_timerecipe_yieldsrecipe_ingredientsrecipe_instructionsrecipe_imagebloggerrecipe_nutrientstagsid_
0Asian Potato Salad with Seven Minute Egg04 servings[2 1/2 cup Multi-Colored Fingerling Potato, 3/...Fill a large stock pot with water.\\nAdd the Mu...https://www.sidechef.com/recipe/eeeeeceb-493e-...sidechef.com{'calories': '80 calories', 'proteinContent': ...[Salad, Lunch, Brunch, Appetizers, Side Dish, ...1
1Everything Breakfast Bombs08 servings[5 tablespoon Butter, 12 ounce Turkey Breakfas...First, preheat the oven to 375 degrees F (190 ...https://www.sidechef.com/recipe/525f6843-4337-...sidechef.com{'calories': '56 calories', 'proteinContent': ...[Breakfast, Brunch, Low-Carb, Eggs, American, ...2
2Bacon Swiss Deviled Eggs06 servings[6 Egg, 1/4 cup Mayonnaise, 1/4 cup Avocado, 1...Cut each hard boiled Egg (6) in half lengthwis...https://www.sidechef.com/recipe/2075e8cf-4fa9-...sidechef.com{'calories': '38 calories', 'proteinContent': ...[Breakfast, Brunch, Low-Carb, Eggs, American, ...3
3Farmers Market Breakfast Pizza02 servings[1/2 Pizza Dough, 1/2 cup Kale, 1/2 cup Onion,...For homemade pizza sauce, finely chop the Swee...https://www.sidechef.com/recipe/1cd15944-9411-...sidechef.com{'calories': '315 calories', 'proteinContent':...[Breakfast, Brunch, Main Dish, Budget-Friendly...4
4Scrambled Eggs02 servings[3 Egg, 2 tablespoon Heavy Cream, 2 tablespoon...Crack Egg (3) into a bowl.\\nPour in Heavy Crea...https://www.sidechef.com/recipe/08d39a01-c030-...sidechef.com{'calories': '127 calories', 'proteinContent':...[Breakfast, Brunch, Vegetarian, Low-Carb, Pesc...5
5Fettuccini Carbonara02 servings[2 Shallot, 1 clove Garlic, 2 Egg, 6 slice Bac...Put a generously salted pot of water on to boi...https://www.sidechef.com/recipe/9e5df75f-bf1a-...sidechef.com{'calories': '495 calories', 'proteinContent':...[Pasta, Dinner, Side Dish, Main Dish, Pork, Eg...6
6Sausage Egg Muffins06 servings[1 pound Ground Pork, 1 1/2 teaspoon Fresh Par...Preheat your oven to 350 degrees F (175 degree...https://www.sidechef.com/recipe/49d5e5a3-4d16-...sidechef.com{'calories': '44 calories', 'proteinContent': ...[Keto, Breakfast, Brunch, Budget-Friendly, Low...7
7Shakshuka04 servings[1 tablespoon Oil, 3 Tomato, 1 Green Chili Pep...Preheat oven to 180 degrees C (350 degrees F) ...https://www.sidechef.com/recipe/de00577b-38d4-...sidechef.com{'calories': '99 calories', 'fatContent': '2.5...[Breakfast, Brunch, Main Dish, Vegetarian, Pes...8
8Huevos Rancheros01 serving[2 Yellow Corn Tortilla, 2 tablespoon Pinto Be...In a small frying pan, spray a little Nonstick...https://www.sidechef.com/recipe/5284bc88-1305-...sidechef.com{'calories': '290 calories', 'proteinContent':...[Breakfast, Brunch, Eggs, Quick, Mexican, Shel...9
9Homemade Pasta04 servings[1 cup All-Purpose Flour, 1 teaspoon Salt, 1 Egg]Mix All-Purpose Flour (1 cup) and Salt (1 teas...https://www.sidechef.com/recipe/8528a7af-b6d8-...sidechef.com{'calories': '33 calories', 'proteinContent': ...[Pasta, Budget-Friendly, Vegetarian, Pescatari...10
\n", "
" ], "text/plain": [ " recipe_name recipe_time recipe_yields \\\n", "0 Asian Potato Salad with Seven Minute Egg 0 4 servings \n", "1 Everything Breakfast Bombs 0 8 servings \n", "2 Bacon Swiss Deviled Eggs 0 6 servings \n", "3 Farmers Market Breakfast Pizza 0 2 servings \n", "4 Scrambled Eggs 0 2 servings \n", "5 Fettuccini Carbonara 0 2 servings \n", "6 Sausage Egg Muffins 0 6 servings \n", "7 Shakshuka 0 4 servings \n", "8 Huevos Rancheros 0 1 serving \n", "9 Homemade Pasta 0 4 servings \n", "\n", " recipe_ingredients \\\n", "0 [2 1/2 cup Multi-Colored Fingerling Potato, 3/... \n", "1 [5 tablespoon Butter, 12 ounce Turkey Breakfas... \n", "2 [6 Egg, 1/4 cup Mayonnaise, 1/4 cup Avocado, 1... \n", "3 [1/2 Pizza Dough, 1/2 cup Kale, 1/2 cup Onion,... \n", "4 [3 Egg, 2 tablespoon Heavy Cream, 2 tablespoon... \n", "5 [2 Shallot, 1 clove Garlic, 2 Egg, 6 slice Bac... \n", "6 [1 pound Ground Pork, 1 1/2 teaspoon Fresh Par... \n", "7 [1 tablespoon Oil, 3 Tomato, 1 Green Chili Pep... \n", "8 [2 Yellow Corn Tortilla, 2 tablespoon Pinto Be... \n", "9 [1 cup All-Purpose Flour, 1 teaspoon Salt, 1 Egg] \n", "\n", " recipe_instructions \\\n", "0 Fill a large stock pot with water.\\nAdd the Mu... \n", "1 First, preheat the oven to 375 degrees F (190 ... \n", "2 Cut each hard boiled Egg (6) in half lengthwis... \n", "3 For homemade pizza sauce, finely chop the Swee... \n", "4 Crack Egg (3) into a bowl.\\nPour in Heavy Crea... \n", "5 Put a generously salted pot of water on to boi... \n", "6 Preheat your oven to 350 degrees F (175 degree... \n", "7 Preheat oven to 180 degrees C (350 degrees F) ... \n", "8 In a small frying pan, spray a little Nonstick... \n", "9 Mix All-Purpose Flour (1 cup) and Salt (1 teas... \n", "\n", " recipe_image blogger \\\n", "0 https://www.sidechef.com/recipe/eeeeeceb-493e-... sidechef.com \n", "1 https://www.sidechef.com/recipe/525f6843-4337-... sidechef.com \n", "2 https://www.sidechef.com/recipe/2075e8cf-4fa9-... sidechef.com \n", "3 https://www.sidechef.com/recipe/1cd15944-9411-... sidechef.com \n", "4 https://www.sidechef.com/recipe/08d39a01-c030-... sidechef.com \n", "5 https://www.sidechef.com/recipe/9e5df75f-bf1a-... sidechef.com \n", "6 https://www.sidechef.com/recipe/49d5e5a3-4d16-... sidechef.com \n", "7 https://www.sidechef.com/recipe/de00577b-38d4-... sidechef.com \n", "8 https://www.sidechef.com/recipe/5284bc88-1305-... sidechef.com \n", "9 https://www.sidechef.com/recipe/8528a7af-b6d8-... sidechef.com \n", "\n", " recipe_nutrients \\\n", "0 {'calories': '80 calories', 'proteinContent': ... \n", "1 {'calories': '56 calories', 'proteinContent': ... \n", "2 {'calories': '38 calories', 'proteinContent': ... \n", "3 {'calories': '315 calories', 'proteinContent':... \n", "4 {'calories': '127 calories', 'proteinContent':... \n", "5 {'calories': '495 calories', 'proteinContent':... \n", "6 {'calories': '44 calories', 'proteinContent': ... \n", "7 {'calories': '99 calories', 'fatContent': '2.5... \n", "8 {'calories': '290 calories', 'proteinContent':... \n", "9 {'calories': '33 calories', 'proteinContent': ... \n", "\n", " tags id_ \n", "0 [Salad, Lunch, Brunch, Appetizers, Side Dish, ... 1 \n", "1 [Breakfast, Brunch, Low-Carb, Eggs, American, ... 2 \n", "2 [Breakfast, Brunch, Low-Carb, Eggs, American, ... 3 \n", "3 [Breakfast, Brunch, Main Dish, Budget-Friendly... 4 \n", "4 [Breakfast, Brunch, Vegetarian, Low-Carb, Pesc... 5 \n", "5 [Pasta, Dinner, Side Dish, Main Dish, Pork, Eg... 6 \n", "6 [Keto, Breakfast, Brunch, Budget-Friendly, Low... 7 \n", "7 [Breakfast, Brunch, Main Dish, Vegetarian, Pes... 8 \n", "8 [Breakfast, Brunch, Eggs, Quick, Mexican, Shel... 9 \n", "9 [Pasta, Budget-Friendly, Vegetarian, Pescatari... 10 " ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.head(10)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Loading Target Embedding\n" ] } ], "source": [ "print(\"Loading Target Embedding\")\n", "tar_img_feats = []\n", "for _id in df[\"id_\"].tolist(): \n", " tar_img_feats.append(torch.load(\"datasets/sidechef/blip-embs-large/{:07d}.pth\".format(_id)).unsqueeze(0))\n", "\n", "tar_img_feats = torch.cat(tar_img_feats, dim=0)" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "torch.Size([8333, 256])" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "tar_img_feats.shape" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "def respond_to_user(image, message):\n", " # Process the image and message here\n", " # For demonstration, I'll just return a simple text response\n", " chat = Chat(model,transform,df,tar_img_feats)\n", " chat.encode_image(image)\n", " response = chat.ask(message)\n", " return response" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "from PIL import Image\n", "import numpy as np\n", "\n", "# Load the image\n", "image_path = '/home/fahadkhan/omkar/CoVR_old/Nutrigenics-flask-chatbot/datasets/sidechef/images/0000006.png' # Replace with your image path\n", "img = Image.open(image_path)\n", "\n", "# Convert image to NumPy array\n", "img_array = np.array(img)\n" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "5\n", "('[\\n'\n", " ' \"2 Shallot\",\\n'\n", " ' \"1 clove Garlic\",\\n'\n", " ' \"2 Egg\",\\n'\n", " ' \"6 slice Bacon\",\\n'\n", " ' \"1/2 cup Heavy Cream\",\\n'\n", " ' \"1/4 cup Grated Parmesan Cheese\",\\n'\n", " ' \"8 ounce Fettuccine\",\\n'\n", " ' \"1 tablespoon Olive Oil\",\\n'\n", " ' \"to taste Salt\",\\n'\n", " ' \"to taste Ground Black Pepper\",\\n'\n", " ' \"to taste Fresh Parsley\"\\n'\n", " ']')\n" ] } ], "source": [ "res = respond_to_user(image=img_array, message=\"ingredients\")\n", "\n", "import pprint\n", "\n", "pprint.pprint(res)" ] }, { "cell_type": "code", "execution_count": 46, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Running on local URL: http://127.0.0.1:7866\n", "\n", "To create a public link, set `share=True` in `launch()`.\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [] }, "execution_count": 46, "metadata": {}, "output_type": "execute_result" } ], "source": [ "\n", "\n", "# Define the custom CSS to add a footer\n", "custom_css = \"\"\"\n", "/* Footer style */\n", ".gradio-footer {\n", " display: flex;\n", " justify-content: center;\n", " align-items: center;\n", " padding: 10px;\n", " background-color: #f8f9fa;\n", " color: #333;\n", " font-size: 0.9em;\n", "}\n", "\n", ".custom-header {\n", " text-align: center;\n", " padding: 12px;\n", " background-color: #333; \n", " color: white;\n", " position: bottom;\n", " bottom: 0;\n", " width: 100%;\n", " font-size: 0.8em;\n", "}\n", "\n", ".footer {\n", " width: 100%;\n", " background-color: #f2f2f2;\n", " color: #555;\n", " text-align: center;\n", " padding: 10px 0;\n", " position: absolute;\n", " bottom: 0;\n", " left: 0;\n", "}\n", "\n", "/* Make sure the interface leaves space for the footer */\n", ".body {\n", " margin-bottom: 50px;\n", "}\n", "\"\"\"\n", "\n", "# Add a custom footer by injecting HTML into the description\n", "custom_footer_html = \"\"\"\n", "\n", "\"\"\"\n", "\n", "custom_header_html = \"\"\"\n", "
Nutrition-GPT Demo
\n", "\"\"\"\n", "\n", "def respond_to_user(image, message):\n", " # Process the image and message here\n", " # For demonstration, I'll just return a simple text response\n", " chat = Chat(model,transform,df,tar_img_feats)\n", " chat.encode_image(image)\n", " response = chat.ask(message)\n", " return response\n", "\n", "iface = gr.Interface(\n", " fn=respond_to_user,\n", " inputs=[gr.Image(height=\"70%\"), gr.Textbox(label=\"Ask Query\"),],\n", " outputs=[gr.Textbox(label=\"Nutrition-GPT\")],\n", " title=custom_header_html, \n", " # description=\"Upload an food image and ask queries!\",\n", " css=custom_css,\n", " # description=custom_footer_html \n", ")\n", "\n", "iface.launch(show_error=True, height=\"650px\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# example_texts = gr.Dataset(components=[gr.Textbox(visible=False)],\n", " # label=\"Prompt Examples\",\n", " # samples=[\n", " # [\"Provide nutritional information for given food image.\"],\n", " # [\"What are the nutrients available in given food image.\"],\n", " # [\"Could you provide a detailed nutritional data of the given food image?\"],\n", " # [\"Describe the instructions to prepare given food.\"],\n", " # [\"What are the key ingredients in this food image?\"],\n", " # [\"Could you highlight the dietary tags for this food image?\"],\n", " # ],)\n", "\n", "# example_images = gr.Dataset(components=[image], label=\"Food Examples\",\n", "# samples=[\n", "# [os.path.join(os.path.dirname(\"./\"), \"./datasets/sidechef/sample_images/0000018.png\")],\n", "# [os.path.join(os.path.dirname(\"./\"), \"./datasets/sidechef/sample_images/0000021.png\")],\n", "# [os.path.join(os.path.dirname(\"./\"), \"./datasets/sidechef/sample_images/0000035.png\")],\n", "# [os.path.join(os.path.dirname(\"./\"), \"./datasets/sidechef/sample_images/0000038.png\")],\n", "# [os.path.join(os.path.dirname(\"./\"), \"./datasets/sidechef/sample_images/0000090.png\")],\n", "# [os.path.join(os.path.dirname(\"./\"), \"./datasets/sidechef/sample_images/0000122.png\")],\n", "# ])\n", "\n" ] } ], "metadata": { "kernelspec": { "display_name": "chatbot-env", "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.9.6" } }, "nbformat": 4, "nbformat_minor": 2 }