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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"nbformat": 4,
|
| 3 |
+
"nbformat_minor": 0,
|
| 4 |
+
"metadata": {
|
| 5 |
+
"colab": {
|
| 6 |
+
"provenance": []
|
| 7 |
+
},
|
| 8 |
+
"kernelspec": {
|
| 9 |
+
"name": "python3",
|
| 10 |
+
"display_name": "Python 3"
|
| 11 |
+
}
|
| 12 |
+
},
|
| 13 |
+
"cells": [
|
| 14 |
+
{
|
| 15 |
+
"cell_type": "markdown",
|
| 16 |
+
"source": [
|
| 17 |
+
"## Installing Libraries"
|
| 18 |
+
],
|
| 19 |
+
"metadata": {
|
| 20 |
+
"id": "MHZGRsR57URH"
|
| 21 |
+
}
|
| 22 |
+
},
|
| 23 |
+
{
|
| 24 |
+
"cell_type": "code",
|
| 25 |
+
"metadata": {
|
| 26 |
+
"colab": {
|
| 27 |
+
"base_uri": "https://localhost:8080/"
|
| 28 |
+
},
|
| 29 |
+
"id": "yR0_MKOOeRNO",
|
| 30 |
+
"outputId": "ba662b01-469b-44d1-e083-22c872672a18"
|
| 31 |
+
},
|
| 32 |
+
"source": [
|
| 33 |
+
"!pip install transformers -U -q"
|
| 34 |
+
],
|
| 35 |
+
"execution_count": null,
|
| 36 |
+
"outputs": [
|
| 37 |
+
{
|
| 38 |
+
"output_type": "stream",
|
| 39 |
+
"name": "stdout",
|
| 40 |
+
"text": [
|
| 41 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m43.5/43.5 kB\u001b[0m \u001b[31m1.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
| 42 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m10.1/10.1 MB\u001b[0m \u001b[31m64.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
| 43 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.0/3.0 MB\u001b[0m \u001b[31m75.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
| 44 |
+
"\u001b[?25h"
|
| 45 |
+
]
|
| 46 |
+
}
|
| 47 |
+
]
|
| 48 |
+
},
|
| 49 |
+
{
|
| 50 |
+
"cell_type": "code",
|
| 51 |
+
"metadata": {
|
| 52 |
+
"colab": {
|
| 53 |
+
"base_uri": "https://localhost:8080/"
|
| 54 |
+
},
|
| 55 |
+
"id": "2RtEvp3Me4va",
|
| 56 |
+
"outputId": "288d9f19-a168-48b2-e1b9-f0402c04bce6"
|
| 57 |
+
},
|
| 58 |
+
"source": [
|
| 59 |
+
"! pip install sentencepiece"
|
| 60 |
+
],
|
| 61 |
+
"execution_count": null,
|
| 62 |
+
"outputs": [
|
| 63 |
+
{
|
| 64 |
+
"output_type": "stream",
|
| 65 |
+
"name": "stdout",
|
| 66 |
+
"text": [
|
| 67 |
+
"Requirement already satisfied: sentencepiece in /usr/local/lib/python3.10/dist-packages (0.2.0)\n"
|
| 68 |
+
]
|
| 69 |
+
}
|
| 70 |
+
]
|
| 71 |
+
},
|
| 72 |
+
{
|
| 73 |
+
"cell_type": "code",
|
| 74 |
+
"metadata": {
|
| 75 |
+
"colab": {
|
| 76 |
+
"base_uri": "https://localhost:8080/"
|
| 77 |
+
},
|
| 78 |
+
"id": "OLwUoKhxD-jt",
|
| 79 |
+
"outputId": "c44a998c-1fec-4cde-b072-5936390f468e"
|
| 80 |
+
},
|
| 81 |
+
"source": [
|
| 82 |
+
"!pip freeze | grep transformers"
|
| 83 |
+
],
|
| 84 |
+
"execution_count": null,
|
| 85 |
+
"outputs": [
|
| 86 |
+
{
|
| 87 |
+
"output_type": "stream",
|
| 88 |
+
"name": "stdout",
|
| 89 |
+
"text": [
|
| 90 |
+
"sentence-transformers==3.2.1\n",
|
| 91 |
+
"transformers==4.47.0\n"
|
| 92 |
+
]
|
| 93 |
+
}
|
| 94 |
+
]
|
| 95 |
+
},
|
| 96 |
+
{
|
| 97 |
+
"cell_type": "markdown",
|
| 98 |
+
"source": [
|
| 99 |
+
"## importing Libraries"
|
| 100 |
+
],
|
| 101 |
+
"metadata": {
|
| 102 |
+
"id": "WnDCnz9x8MhT"
|
| 103 |
+
}
|
| 104 |
+
},
|
| 105 |
+
{
|
| 106 |
+
"cell_type": "code",
|
| 107 |
+
"source": [
|
| 108 |
+
"import gradio as gr\n",
|
| 109 |
+
"from PIL import Image\n",
|
| 110 |
+
"import pytesseract\n",
|
| 111 |
+
"from transformers import MBartForConditionalGeneration, MBart50Tokenizer\n"
|
| 112 |
+
],
|
| 113 |
+
"metadata": {
|
| 114 |
+
"id": "FC_Wo01D8PxV"
|
| 115 |
+
},
|
| 116 |
+
"execution_count": null,
|
| 117 |
+
"outputs": []
|
| 118 |
+
},
|
| 119 |
+
{
|
| 120 |
+
"cell_type": "code",
|
| 121 |
+
"source": [
|
| 122 |
+
"from google.colab import drive\n",
|
| 123 |
+
"drive.mount('/content/drive')"
|
| 124 |
+
],
|
| 125 |
+
"metadata": {
|
| 126 |
+
"colab": {
|
| 127 |
+
"base_uri": "https://localhost:8080/"
|
| 128 |
+
},
|
| 129 |
+
"id": "kmCHgI4v6qxm",
|
| 130 |
+
"outputId": "682030b9-c6e4-4a83-e8f3-d88631e2c859"
|
| 131 |
+
},
|
| 132 |
+
"execution_count": null,
|
| 133 |
+
"outputs": [
|
| 134 |
+
{
|
| 135 |
+
"output_type": "stream",
|
| 136 |
+
"name": "stdout",
|
| 137 |
+
"text": [
|
| 138 |
+
"Mounted at /content/drive\n"
|
| 139 |
+
]
|
| 140 |
+
}
|
| 141 |
+
]
|
| 142 |
+
},
|
| 143 |
+
{
|
| 144 |
+
"cell_type": "markdown",
|
| 145 |
+
"source": [
|
| 146 |
+
"## Loading model"
|
| 147 |
+
],
|
| 148 |
+
"metadata": {
|
| 149 |
+
"id": "DZ5W2COw7gju"
|
| 150 |
+
}
|
| 151 |
+
},
|
| 152 |
+
{
|
| 153 |
+
"cell_type": "code",
|
| 154 |
+
"source": [
|
| 155 |
+
"\n",
|
| 156 |
+
"from transformers import AutoTokenizer, AutoModelForSeq2SeqLM\n",
|
| 157 |
+
"\n",
|
| 158 |
+
"tokenizer = AutoTokenizer.from_pretrained(\"facebook/mbart-large-50-many-to-many-mmt\")\n",
|
| 159 |
+
"model = AutoModelForSeq2SeqLM.from_pretrained(\"facebook/mbart-large-50-many-to-many-mmt\")"
|
| 160 |
+
],
|
| 161 |
+
"metadata": {
|
| 162 |
+
"id": "aVursIUH6xHR"
|
| 163 |
+
},
|
| 164 |
+
"execution_count": null,
|
| 165 |
+
"outputs": []
|
| 166 |
+
},
|
| 167 |
+
{
|
| 168 |
+
"cell_type": "markdown",
|
| 169 |
+
"source": [
|
| 170 |
+
"## transating image functions"
|
| 171 |
+
],
|
| 172 |
+
"metadata": {
|
| 173 |
+
"id": "mMeK4N6q8BWf"
|
| 174 |
+
}
|
| 175 |
+
},
|
| 176 |
+
{
|
| 177 |
+
"cell_type": "code",
|
| 178 |
+
"source": [
|
| 179 |
+
"def translate_image(img_path, src_lang, tgt_lang):\n",
|
| 180 |
+
" # Extract text from the image using Tesseract OCR\n",
|
| 181 |
+
" text = pytesseract.image_to_string(img_path)\n",
|
| 182 |
+
" if not text.strip():\n",
|
| 183 |
+
" return \"No text detected. Please upload a valid image.\", \"\"\n",
|
| 184 |
+
"\n",
|
| 185 |
+
" # Translating the text\n",
|
| 186 |
+
" tokenizer.src_lang = src_lang\n",
|
| 187 |
+
" inputs = tokenizer(text, return_tensors=\"pt\")\n",
|
| 188 |
+
" generated_tokens = model.generate(\n",
|
| 189 |
+
" **inputs, forced_bos_token_id=tokenizer.lang_code_to_id[tgt_lang]\n",
|
| 190 |
+
" )\n",
|
| 191 |
+
" translated_text = tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)[0]\n",
|
| 192 |
+
"\n"
|
| 193 |
+
],
|
| 194 |
+
"metadata": {
|
| 195 |
+
"id": "HuH9KMzn8FnM"
|
| 196 |
+
},
|
| 197 |
+
"execution_count": null,
|
| 198 |
+
"outputs": []
|
| 199 |
+
},
|
| 200 |
+
{
|
| 201 |
+
"cell_type": "markdown",
|
| 202 |
+
"source": [
|
| 203 |
+
"## Putting it all together in the gradio webpage"
|
| 204 |
+
],
|
| 205 |
+
"metadata": {
|
| 206 |
+
"id": "OWhIkDbZ8YTb"
|
| 207 |
+
}
|
| 208 |
+
},
|
| 209 |
+
{
|
| 210 |
+
"cell_type": "code",
|
| 211 |
+
"source": [
|
| 212 |
+
"# Installing necessary libraries\n",
|
| 213 |
+
"!pip install gradio pytesseract transformers sentencepiece\n",
|
| 214 |
+
"\n",
|
| 215 |
+
"# Installing Tesseract OCR\n",
|
| 216 |
+
"!apt-get install -y tesseract-ocr\n",
|
| 217 |
+
"!pip install Pillow\n",
|
| 218 |
+
"\n",
|
| 219 |
+
"# Importing libraries\n",
|
| 220 |
+
"import gradio as gr\n",
|
| 221 |
+
"from PIL import Image\n",
|
| 222 |
+
"import pytesseract\n",
|
| 223 |
+
"from transformers import MBartForConditionalGeneration, MBart50Tokenizer\n",
|
| 224 |
+
"\n",
|
| 225 |
+
"# Loading the MBart model and tokenizer\n",
|
| 226 |
+
"MODEL_NAME = \"facebook/mbart-large-50-many-to-many-mmt\"\n",
|
| 227 |
+
"tokenizer = MBart50Tokenizer.from_pretrained(MODEL_NAME)\n",
|
| 228 |
+
"model = MBartForConditionalGeneration.from_pretrained(MODEL_NAME)\n",
|
| 229 |
+
"\n",
|
| 230 |
+
"# Defining the OCR and translation function\n",
|
| 231 |
+
"def translate_image(img_path, src_lang, tgt_lang):\n",
|
| 232 |
+
" try:\n",
|
| 233 |
+
" # Extract text from the image using Tesseract OCR\n",
|
| 234 |
+
" text = pytesseract.image_to_string(img_path)\n",
|
| 235 |
+
" if not text.strip():\n",
|
| 236 |
+
" return \"No text detected. Please upload a valid image.\", \"\"\n",
|
| 237 |
+
"\n",
|
| 238 |
+
" # Translating the text\n",
|
| 239 |
+
" tokenizer.src_lang = src_lang\n",
|
| 240 |
+
" inputs = tokenizer(text, return_tensors=\"pt\")\n",
|
| 241 |
+
" generated_tokens = model.generate(\n",
|
| 242 |
+
" **inputs, forced_bos_token_id=tokenizer.lang_code_to_id[tgt_lang]\n",
|
| 243 |
+
" )\n",
|
| 244 |
+
" translated_text = tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)[0]\n",
|
| 245 |
+
"\n",
|
| 246 |
+
" return text, translated_text\n",
|
| 247 |
+
" except Exception as e:\n",
|
| 248 |
+
" return f\"Error: {str(e)}\", \"\"\n",
|
| 249 |
+
"\n",
|
| 250 |
+
"# Defining the Gradio interface\n",
|
| 251 |
+
"with gr.Blocks() as app:\n",
|
| 252 |
+
" gr.Markdown(\"## OCR and Translation App\")\n",
|
| 253 |
+
" gr.Markdown(\"Upload an image, specify source and target languages, and get the translated text.\")\n",
|
| 254 |
+
"\n",
|
| 255 |
+
" with gr.Row():\n",
|
| 256 |
+
" img_input = gr.File(label=\"Upload Image\", type=\"filepath\")\n",
|
| 257 |
+
" src_lang = gr.Textbox(label=\"Source Language Code (OCR works best with english)\")\n",
|
| 258 |
+
" tgt_lang = gr.Textbox(label=\"Target Language Code (any target language)\")\n",
|
| 259 |
+
"\n",
|
| 260 |
+
" with gr.Row():\n",
|
| 261 |
+
" extracted_text = gr.Textbox(label=\"Extracted Text\")\n",
|
| 262 |
+
" translated_text = gr.Textbox(label=\"Translated Text\")\n",
|
| 263 |
+
"\n",
|
| 264 |
+
" translate_button = gr.Button(\"Translate\")\n",
|
| 265 |
+
" translate_button.click(\n",
|
| 266 |
+
" translate_image, inputs=[img_input, src_lang, tgt_lang], outputs=[extracted_text, translated_text]\n",
|
| 267 |
+
" )\n",
|
| 268 |
+
"\n",
|
| 269 |
+
"# Launching the app\n",
|
| 270 |
+
"app.launch()\n",
|
| 271 |
+
"\n",
|
| 272 |
+
"# Language codes. Note - The OCR app can only translate from english to the languges mentioned below\n",
|
| 273 |
+
"\n",
|
| 274 |
+
"# Arabic (ar_AR), Czech (cs_CZ), German (de_DE), English (en_XX), Spanish (es_XX),\n",
|
| 275 |
+
"# Estonian (et_EE), Finnish (fi_FI), French (fr_XX), Gujarati (gu_IN), Hindi (hi_IN),\n",
|
| 276 |
+
"# Italian (it_IT), Japanese (ja_XX), Kazakh (kk_KZ), Korean (ko_KR), Lithuanian (lt_LT),\n",
|
| 277 |
+
"# Latvian (lv_LV), Burmese (my_MM), Nepali (ne_NP), Dutch (nl_XX), Romanian (ro_RO),\n",
|
| 278 |
+
"# Russian (ru_RU), Sinhala (si_LK), Turkish (tr_TR), Vietnamese (vi_VN), Chinese (zh_CN),\n",
|
| 279 |
+
"# Afrikaans (af_ZA), Azerbaijani (az_AZ), Bengali (bn_IN), Persian (fa_IR), Hebrew (he_IL),\n",
|
| 280 |
+
"# Croatian (hr_HR), Indonesian (id_ID), Georgian (ka_GE),\n",
|
| 281 |
+
"# Khmer (km_KH), Macedonian (mk_MK), Malayalam (ml_IN), Mongolian (mn_MN), Marathi (mr_IN),\n",
|
| 282 |
+
"# Polish (pl_PL), Pashto (ps_AF), Portuguese ), Swedish (sv_SE), Swahili (sw_KE), Tamil (ta_IN),\n",
|
| 283 |
+
"# Telugu (te_IN), Thai (th_TH), Tagalog (tl_XX), Ukrainian (uk_UA), Urdu (ur_PK), Xhosa (xh_ZA),\n",
|
| 284 |
+
"# Galician (gl_ES), Slovene (sl_SI)\n"
|
| 285 |
+
],
|
| 286 |
+
"metadata": {
|
| 287 |
+
"colab": {
|
| 288 |
+
"base_uri": "https://localhost:8080/",
|
| 289 |
+
"height": 1000
|
| 290 |
+
},
|
| 291 |
+
"id": "LPq0MtL0Kmvz",
|
| 292 |
+
"outputId": "c06f9b31-0f1b-4da6-8150-d97b259312cc"
|
| 293 |
+
},
|
| 294 |
+
"execution_count": null,
|
| 295 |
+
"outputs": [
|
| 296 |
+
{
|
| 297 |
+
"output_type": "stream",
|
| 298 |
+
"name": "stdout",
|
| 299 |
+
"text": [
|
| 300 |
+
"Requirement already satisfied: gradio in /usr/local/lib/python3.10/dist-packages (5.8.0)\n",
|
| 301 |
+
"Requirement already satisfied: pytesseract in /usr/local/lib/python3.10/dist-packages (0.3.13)\n",
|
| 302 |
+
"Requirement already satisfied: transformers in /usr/local/lib/python3.10/dist-packages (4.46.3)\n",
|
| 303 |
+
"Requirement already satisfied: sentencepiece in /usr/local/lib/python3.10/dist-packages (0.2.0)\n",
|
| 304 |
+
"Requirement already satisfied: aiofiles<24.0,>=22.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (23.2.1)\n",
|
| 305 |
+
"Requirement already satisfied: anyio<5.0,>=3.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (3.7.1)\n",
|
| 306 |
+
"Requirement already satisfied: fastapi<1.0,>=0.115.2 in /usr/local/lib/python3.10/dist-packages (from gradio) (0.115.6)\n",
|
| 307 |
+
"Requirement already satisfied: ffmpy in /usr/local/lib/python3.10/dist-packages (from gradio) (0.4.0)\n",
|
| 308 |
+
"Requirement already satisfied: gradio-client==1.5.1 in /usr/local/lib/python3.10/dist-packages (from gradio) (1.5.1)\n",
|
| 309 |
+
"Requirement already satisfied: httpx>=0.24.1 in /usr/local/lib/python3.10/dist-packages (from gradio) (0.28.0)\n",
|
| 310 |
+
"Requirement already satisfied: huggingface-hub>=0.25.1 in /usr/local/lib/python3.10/dist-packages (from gradio) (0.26.3)\n",
|
| 311 |
+
"Requirement already satisfied: jinja2<4.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (3.1.4)\n",
|
| 312 |
+
"Requirement already satisfied: markupsafe~=2.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (2.1.5)\n",
|
| 313 |
+
"Requirement already satisfied: numpy<3.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (1.26.4)\n",
|
| 314 |
+
"Requirement already satisfied: orjson~=3.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (3.10.12)\n",
|
| 315 |
+
"Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from gradio) (24.2)\n",
|
| 316 |
+
"Requirement already satisfied: pandas<3.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (2.2.2)\n",
|
| 317 |
+
"Requirement already satisfied: pillow<12.0,>=8.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (11.0.0)\n",
|
| 318 |
+
"Requirement already satisfied: pydantic>=2.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (2.10.3)\n",
|
| 319 |
+
"Requirement already satisfied: pydub in /usr/local/lib/python3.10/dist-packages (from gradio) (0.25.1)\n",
|
| 320 |
+
"Requirement already satisfied: python-multipart>=0.0.18 in /usr/local/lib/python3.10/dist-packages (from gradio) (0.0.19)\n",
|
| 321 |
+
"Requirement already satisfied: pyyaml<7.0,>=5.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (6.0.2)\n",
|
| 322 |
+
"Requirement already satisfied: ruff>=0.2.2 in /usr/local/lib/python3.10/dist-packages (from gradio) (0.8.2)\n",
|
| 323 |
+
"Requirement already satisfied: safehttpx<0.2.0,>=0.1.6 in /usr/local/lib/python3.10/dist-packages (from gradio) (0.1.6)\n",
|
| 324 |
+
"Requirement already satisfied: semantic-version~=2.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (2.10.0)\n",
|
| 325 |
+
"Requirement already satisfied: starlette<1.0,>=0.40.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (0.41.3)\n",
|
| 326 |
+
"Requirement already satisfied: tomlkit<0.14.0,>=0.12.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (0.13.2)\n",
|
| 327 |
+
"Requirement already satisfied: typer<1.0,>=0.12 in /usr/local/lib/python3.10/dist-packages (from gradio) (0.15.0)\n",
|
| 328 |
+
"Requirement already satisfied: typing-extensions~=4.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (4.12.2)\n",
|
| 329 |
+
"Requirement already satisfied: uvicorn>=0.14.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (0.32.1)\n",
|
| 330 |
+
"Requirement already satisfied: fsspec in /usr/local/lib/python3.10/dist-packages (from gradio-client==1.5.1->gradio) (2024.10.0)\n",
|
| 331 |
+
"Requirement already satisfied: websockets<15.0,>=10.0 in /usr/local/lib/python3.10/dist-packages (from gradio-client==1.5.1->gradio) (14.1)\n",
|
| 332 |
+
"Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from transformers) (3.16.1)\n",
|
| 333 |
+
"Requirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.10/dist-packages (from transformers) (2024.9.11)\n",
|
| 334 |
+
"Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from transformers) (2.32.3)\n",
|
| 335 |
+
"Requirement already satisfied: tokenizers<0.21,>=0.20 in /usr/local/lib/python3.10/dist-packages (from transformers) (0.20.3)\n",
|
| 336 |
+
"Requirement already satisfied: safetensors>=0.4.1 in /usr/local/lib/python3.10/dist-packages (from transformers) (0.4.5)\n",
|
| 337 |
+
"Requirement already satisfied: tqdm>=4.27 in /usr/local/lib/python3.10/dist-packages (from transformers) (4.66.6)\n",
|
| 338 |
+
"Requirement already satisfied: idna>=2.8 in /usr/local/lib/python3.10/dist-packages (from anyio<5.0,>=3.0->gradio) (3.10)\n",
|
| 339 |
+
"Requirement already satisfied: sniffio>=1.1 in /usr/local/lib/python3.10/dist-packages (from anyio<5.0,>=3.0->gradio) (1.3.1)\n",
|
| 340 |
+
"Requirement already satisfied: exceptiongroup in /usr/local/lib/python3.10/dist-packages (from anyio<5.0,>=3.0->gradio) (1.2.2)\n",
|
| 341 |
+
"Requirement already satisfied: certifi in /usr/local/lib/python3.10/dist-packages (from httpx>=0.24.1->gradio) (2024.8.30)\n",
|
| 342 |
+
"Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.10/dist-packages (from httpx>=0.24.1->gradio) (1.0.7)\n",
|
| 343 |
+
"Requirement already satisfied: h11<0.15,>=0.13 in /usr/local/lib/python3.10/dist-packages (from httpcore==1.*->httpx>=0.24.1->gradio) (0.14.0)\n",
|
| 344 |
+
"Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.10/dist-packages (from pandas<3.0,>=1.0->gradio) (2.8.2)\n",
|
| 345 |
+
"Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas<3.0,>=1.0->gradio) (2024.2)\n",
|
| 346 |
+
"Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.10/dist-packages (from pandas<3.0,>=1.0->gradio) (2024.2)\n",
|
| 347 |
+
"Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from pydantic>=2.0->gradio) (0.7.0)\n",
|
| 348 |
+
"Requirement already satisfied: pydantic-core==2.27.1 in /usr/local/lib/python3.10/dist-packages (from pydantic>=2.0->gradio) (2.27.1)\n",
|
| 349 |
+
"Requirement already satisfied: click>=8.0.0 in /usr/local/lib/python3.10/dist-packages (from typer<1.0,>=0.12->gradio) (8.1.7)\n",
|
| 350 |
+
"Requirement already satisfied: shellingham>=1.3.0 in /usr/local/lib/python3.10/dist-packages (from typer<1.0,>=0.12->gradio) (1.5.4)\n",
|
| 351 |
+
"Requirement already satisfied: rich>=10.11.0 in /usr/local/lib/python3.10/dist-packages (from typer<1.0,>=0.12->gradio) (13.9.4)\n",
|
| 352 |
+
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->transformers) (3.4.0)\n",
|
| 353 |
+
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->transformers) (2.2.3)\n",
|
| 354 |
+
"Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.8.2->pandas<3.0,>=1.0->gradio) (1.16.0)\n",
|
| 355 |
+
"Requirement already satisfied: markdown-it-py>=2.2.0 in /usr/local/lib/python3.10/dist-packages (from rich>=10.11.0->typer<1.0,>=0.12->gradio) (3.0.0)\n",
|
| 356 |
+
"Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.10/dist-packages (from rich>=10.11.0->typer<1.0,>=0.12->gradio) (2.18.0)\n",
|
| 357 |
+
"Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.10/dist-packages (from markdown-it-py>=2.2.0->rich>=10.11.0->typer<1.0,>=0.12->gradio) (0.1.2)\n",
|
| 358 |
+
"Reading package lists... Done\n",
|
| 359 |
+
"Building dependency tree... Done\n",
|
| 360 |
+
"Reading state information... Done\n",
|
| 361 |
+
"tesseract-ocr is already the newest version (4.1.1-2.1build1).\n",
|
| 362 |
+
"0 upgraded, 0 newly installed, 0 to remove and 49 not upgraded.\n",
|
| 363 |
+
"Requirement already satisfied: Pillow in /usr/local/lib/python3.10/dist-packages (11.0.0)\n",
|
| 364 |
+
"Running Gradio in a Colab notebook requires sharing enabled. Automatically setting `share=True` (you can turn this off by setting `share=False` in `launch()` explicitly).\n",
|
| 365 |
+
"\n",
|
| 366 |
+
"Colab notebook detected. To show errors in colab notebook, set debug=True in launch()\n",
|
| 367 |
+
"* Running on public URL: https://08e78290e64bdebf00.gradio.live\n",
|
| 368 |
+
"\n",
|
| 369 |
+
"This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from the terminal in the working directory to deploy to Hugging Face Spaces (https://huggingface.co/spaces)\n"
|
| 370 |
+
]
|
| 371 |
+
},
|
| 372 |
+
{
|
| 373 |
+
"output_type": "display_data",
|
| 374 |
+
"data": {
|
| 375 |
+
"text/plain": [
|
| 376 |
+
"<IPython.core.display.HTML object>"
|
| 377 |
+
],
|
| 378 |
+
"text/html": [
|
| 379 |
+
"<div><iframe src=\"https://08e78290e64bdebf00.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
| 380 |
+
]
|
| 381 |
+
},
|
| 382 |
+
"metadata": {}
|
| 383 |
+
},
|
| 384 |
+
{
|
| 385 |
+
"output_type": "execute_result",
|
| 386 |
+
"data": {
|
| 387 |
+
"text/plain": []
|
| 388 |
+
},
|
| 389 |
+
"metadata": {},
|
| 390 |
+
"execution_count": 17
|
| 391 |
+
}
|
| 392 |
+
]
|
| 393 |
+
}
|
| 394 |
+
]
|
| 395 |
+
}
|