Upload Inference.ipynb
Browse files- Inference.ipynb +164 -0
Inference.ipynb
ADDED
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "markdown",
|
5 |
+
"metadata": {
|
6 |
+
"id": "9sEfZoepGP8x"
|
7 |
+
},
|
8 |
+
"source": [
|
9 |
+
"# Setup Environment"
|
10 |
+
]
|
11 |
+
},
|
12 |
+
{
|
13 |
+
"cell_type": "code",
|
14 |
+
"execution_count": 1,
|
15 |
+
"metadata": {
|
16 |
+
"colab": {
|
17 |
+
"base_uri": "https://localhost:8080/"
|
18 |
+
},
|
19 |
+
"id": "brKU69ZQvEiz",
|
20 |
+
"outputId": "dc3c06c4-5a4f-4469-9447-acf5a15750c2"
|
21 |
+
},
|
22 |
+
"outputs": [
|
23 |
+
{
|
24 |
+
"output_type": "stream",
|
25 |
+
"name": "stdout",
|
26 |
+
"text": [
|
27 |
+
"\u001b[?25l \u001b[90mββββββββββββββββββββββββββββββββββββββββ\u001b[0m \u001b[32m0.0/235.8 kB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r\u001b[2K \u001b[91mβββββββββββββββββββββββββββββββββββββββ\u001b[0m\u001b[91mβΈ\u001b[0m \u001b[32m235.5/235.8 kB\u001b[0m \u001b[31m14.3 MB/s\u001b[0m eta \u001b[36m0:00:01\u001b[0m\r\u001b[2K \u001b[90mββββββββββββββββββββββββββββββββββββββββ\u001b[0m \u001b[32m235.8/235.8 kB\u001b[0m \u001b[31m6.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
28 |
+
"\u001b[?25h"
|
29 |
+
]
|
30 |
+
}
|
31 |
+
],
|
32 |
+
"source": [
|
33 |
+
"!pip install -q unidecode"
|
34 |
+
]
|
35 |
+
},
|
36 |
+
{
|
37 |
+
"cell_type": "markdown",
|
38 |
+
"metadata": {
|
39 |
+
"id": "Nwt1YBYVqcva"
|
40 |
+
},
|
41 |
+
"source": [
|
42 |
+
"# Setup Model"
|
43 |
+
]
|
44 |
+
},
|
45 |
+
{
|
46 |
+
"cell_type": "code",
|
47 |
+
"source": [
|
48 |
+
"!git clone https://huggingface.co/MahtaFetrat/Homo-GE2PE-Persian/"
|
49 |
+
],
|
50 |
+
"metadata": {
|
51 |
+
"colab": {
|
52 |
+
"base_uri": "https://localhost:8080/"
|
53 |
+
},
|
54 |
+
"id": "l_KnAgVoAS83",
|
55 |
+
"outputId": "2d3fe260-e8bf-41e2-e35b-3b61dcd59dc7"
|
56 |
+
},
|
57 |
+
"execution_count": 2,
|
58 |
+
"outputs": [
|
59 |
+
{
|
60 |
+
"output_type": "stream",
|
61 |
+
"name": "stdout",
|
62 |
+
"text": [
|
63 |
+
"Cloning into 'Homo-GE2PE-Persian'...\n",
|
64 |
+
"remote: Enumerating objects: 32, done.\u001b[K\n",
|
65 |
+
"remote: Counting objects: 100% (28/28), done.\u001b[K\n",
|
66 |
+
"remote: Compressing objects: 100% (27/27), done.\u001b[K\n",
|
67 |
+
"remote: Total 32 (delta 7), reused 0 (delta 0), pack-reused 4 (from 1)\u001b[K\n",
|
68 |
+
"Unpacking objects: 100% (32/32), 27.25 KiB | 1.36 MiB/s, done.\n",
|
69 |
+
"Filtering content: 100% (3/3), 218.23 MiB | 50.60 MiB/s, done.\n"
|
70 |
+
]
|
71 |
+
}
|
72 |
+
]
|
73 |
+
},
|
74 |
+
{
|
75 |
+
"cell_type": "code",
|
76 |
+
"source": [
|
77 |
+
"!unzip -q Homo-GE2PE-Persian/assets/Parsivar.zip\n",
|
78 |
+
"!unzip -q Homo-GE2PE-Persian/model-weights/homo-ge2pe.zip -d homo-ge2pe\n",
|
79 |
+
"!unzip -q Homo-GE2PE-Persian/model-weights/homo-t5.zip -d homo-t5"
|
80 |
+
],
|
81 |
+
"metadata": {
|
82 |
+
"id": "kbsS_rWVAkYt"
|
83 |
+
},
|
84 |
+
"execution_count": 3,
|
85 |
+
"outputs": []
|
86 |
+
},
|
87 |
+
{
|
88 |
+
"cell_type": "code",
|
89 |
+
"source": [
|
90 |
+
"!mv Homo-GE2PE-Persian/assets/GE2PE.py ./"
|
91 |
+
],
|
92 |
+
"metadata": {
|
93 |
+
"id": "sG6P0nbUAood"
|
94 |
+
},
|
95 |
+
"execution_count": 4,
|
96 |
+
"outputs": []
|
97 |
+
},
|
98 |
+
{
|
99 |
+
"cell_type": "code",
|
100 |
+
"execution_count": 5,
|
101 |
+
"metadata": {
|
102 |
+
"id": "VIRvJy8naB0f"
|
103 |
+
},
|
104 |
+
"outputs": [],
|
105 |
+
"source": [
|
106 |
+
"!sed -i 's+from collections import Iterable+from collections.abc import Iterable+g' /content/Parsivar/token_merger.py"
|
107 |
+
]
|
108 |
+
},
|
109 |
+
{
|
110 |
+
"cell_type": "markdown",
|
111 |
+
"source": [
|
112 |
+
"# Inference"
|
113 |
+
],
|
114 |
+
"metadata": {
|
115 |
+
"id": "3UjjHbxNIIMt"
|
116 |
+
}
|
117 |
+
},
|
118 |
+
{
|
119 |
+
"cell_type": "code",
|
120 |
+
"execution_count": 6,
|
121 |
+
"metadata": {
|
122 |
+
"colab": {
|
123 |
+
"base_uri": "https://localhost:8080/"
|
124 |
+
},
|
125 |
+
"id": "Qs-J5B3ykaYz",
|
126 |
+
"outputId": "a64ca839-b970-4796-88aa-0d80f3342e08"
|
127 |
+
},
|
128 |
+
"outputs": [
|
129 |
+
{
|
130 |
+
"output_type": "execute_result",
|
131 |
+
"data": {
|
132 |
+
"text/plain": [
|
133 |
+
"['teste model t/bdil nevise be vaj', '@in ketabe @ali @/st']"
|
134 |
+
]
|
135 |
+
},
|
136 |
+
"metadata": {},
|
137 |
+
"execution_count": 6
|
138 |
+
}
|
139 |
+
],
|
140 |
+
"source": [
|
141 |
+
"from GE2PE import GE2PE\n",
|
142 |
+
"\n",
|
143 |
+
"g2p = GE2PE(model_path='/content/homo-ge2pe') # or homo-t5\n",
|
144 |
+
"\n",
|
145 |
+
"g2p.generate(['ΨͺΨ³Ψͺ Ω
Ψ―Ω ΨͺΨ¨Ψ―ΫΩ ΩΩΫΨ³Ω Ψ¨Ω ΩΨ§Ψ¬', 'Ψ§ΫΩ Ϊ©ΨͺΨ§Ψ¨Ω ΨΉΩΫ Ψ§Ψ³Ψͺ'], use_rules=True)"
|
146 |
+
]
|
147 |
+
}
|
148 |
+
],
|
149 |
+
"metadata": {
|
150 |
+
"colab": {
|
151 |
+
"provenance": []
|
152 |
+
},
|
153 |
+
"gpuClass": "standard",
|
154 |
+
"kernelspec": {
|
155 |
+
"display_name": "Python 3",
|
156 |
+
"name": "python3"
|
157 |
+
},
|
158 |
+
"language_info": {
|
159 |
+
"name": "python"
|
160 |
+
}
|
161 |
+
},
|
162 |
+
"nbformat": 4,
|
163 |
+
"nbformat_minor": 0
|
164 |
+
}
|