File size: 4,145 Bytes
2d4e52a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Loaded as API: http://127.0.0.1:7860/ ✔\n",
      "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n",
      "<PcGts xmlns=\"http://schema.primaresearch.org/PAGE/gts/pagecontent/2013-07-15\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://schema.primaresearch.org/PAGE/gts/pagecontent/2013-07-15 http://schema.primaresearch.org/PAGE/gts/pagecontent/2013-07-15/pagecontent.xsd\">\n",
      "    <Metadata>\n",
      "        <Creator>Swedish National Archives</Creator>\n",
      "        <Created>2023-11-23, 09:41:42</Created>\n",
      "    </Metadata>\n",
      "    <Page imageFilename=\"page_xml.xml\" imageWidth=\"1629\" imageHeight=\"626\">\n",
      "    <TextRegion id=\"region_0\" custom=\"readingOrder {index:0;}\">\n",
      "        <Coords points=\"0,313 14,391 0,563 28,608 70,588 90,611 153,570 279,556 397,599 970,625 1026,585 1132,583 1191,611 1353,573 1599,575 1628,541 1595,482 1505,459 1547,451 1580,415 1596,316 1579,288 1536,295 1491,257 1445,169 1352,132 1171,120 1125,98 926,98 847,71 609,57 173,67 122,86 92,224\"/>\n",
      "    <TextLine id=\"line_region_0_0\" custom=\"readingOrder {index:0;}\">\n",
      "                <Coords points=\"124,121 134,200 479,207 617,224 681,248 782,231 1070,252 1110,284 1351,244 1364,209 1356,166 1332,152 965,135 846,81 744,111 600,104 514,54 423,87 338,72 317,54 247,54 241,66 154,79\"/>\n",
      "                                <TextEquiv>\n",
      "            <Unicode>Hushållspenningar</Unicode>\n",
      "        </TextEquiv>\n",
      "                        <PredScore pred_score=\"0.9796\"/>\n",
      "            </TextLine>\n",
      "    <TextLine id=\"line_region_0_1\" custom=\"readingOrder {index:1;}\">\n",
      "                <Coords points=\"26,331 32,371 1035,394 1191,410 1273,453 1370,424 1547,419 1573,391 1571,330 1520,313 1169,291 985,315 846,304 745,268 580,297 274,283 142,250 72,263 32,293\"/>\n",
      "                                <TextEquiv>\n",
      "            <Unicode>Priminieration å Snällporten</Unicode>\n",
      "        </TextEquiv>\n",
      "                        <PredScore pred_score=\"0.9221\"/>\n",
      "            </TextLine>\n",
      "    <TextLine id=\"line_region_0_2\" custom=\"readingOrder {index:2;}\">\n",
      "                <Coords points=\"0,452 0,539 28,570 271,539 676,546 735,592 825,596 985,553 1581,572 1614,535 1581,493 1356,457 1189,469 948,437 800,463 648,436 558,454 441,425 228,439 94,390 30,410\"/>\n",
      "                                <TextEquiv>\n",
      "            <Unicode>Gasverksräkning för för ä kronor</Unicode>\n",
      "        </TextEquiv>\n",
      "                        <PredScore pred_score=\"0.9599\"/>\n",
      "            </TextLine>\n",
      "    </TextRegion>\n",
      "    </Page>\n",
      "</PcGts>\n",
      "\n"
     ]
    }
   ],
   "source": [
    "from gradio_client import Client # pip install gradio_client\n",
    "\n",
    "# Change url to your client (localhost: http://127.0.0.1:7860/)\n",
    "\n",
    "client = Client(\"http://127.0.0.1:7860/\")\n",
    "job = client.submit(\n",
    "    \"https://github.com/Swedish-National-Archives-AI-lab/htrflow_core/blob/main/data/raw/demo_image.jpg?raw=true\", \n",
    "    \"Riksarkivet/satrn_htr\",\n",
    "    api_name=\"/run_htr_pipeline\",\n",
    ")\n",
    "\n",
    "print(job.result())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "venv",
   "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.9"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}