Upload 11 files
Browse files- .gitattributes +3 -0
- TrainingModel(FutureProject).ipynb +0 -0
- batch_emails.txt +5 -0
- index.ipynb +304 -0
- others/.DS_Store +0 -0
- others/Logo.png +3 -0
- others/MainNote Backup.ipynb +532 -0
- others/Screen Shot 2025-03-01 at 2.49.21 AM.png +3 -0
- others/demo-screenshot.png +3 -0
- requirements.txt +4 -0
- sample_emails.csv +6 -0
- sample_emailsNoColumn.csv +6 -0
.gitattributes
CHANGED
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
others/demo-screenshot.png filter=lfs diff=lfs merge=lfs -text
|
37 |
+
others/Logo.png filter=lfs diff=lfs merge=lfs -text
|
38 |
+
others/Screen[[:space:]]Shot[[:space:]]2025-03-01[[:space:]]at[[:space:]]2.49.21[[:space:]]AM.png filter=lfs diff=lfs merge=lfs -text
|
TrainingModel(FutureProject).ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
batch_emails.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Please review the attached quarterly report before Friday's board meeting.
|
2 |
+
Limited time offer! 50% off all premium subscriptions - use code FLASHSALE50
|
3 |
+
Your document 'project_proposal.pdf' is ready for download at https://docs.example.com
|
4 |
+
WARNING: Unusual login attempt detected from new device. Verify your identity now.
|
5 |
+
Don't forget Sarah's birthday tomorrow! Here's her wishlist: https://giftlist.com/sarah
|
index.ipynb
ADDED
@@ -0,0 +1,304 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "markdown",
|
5 |
+
"id": "53e9feaa-53de-4377-8d45-aa1f7264ae3a",
|
6 |
+
"metadata": {},
|
7 |
+
"source": [
|
8 |
+
"### First Neccesary libararies needs to be loaded."
|
9 |
+
]
|
10 |
+
},
|
11 |
+
{
|
12 |
+
"cell_type": "code",
|
13 |
+
"execution_count": 2,
|
14 |
+
"id": "8864f53f-15d2-403c-a905-3da509cfb050",
|
15 |
+
"metadata": {},
|
16 |
+
"outputs": [],
|
17 |
+
"source": [
|
18 |
+
"import gradio as gr\n",
|
19 |
+
"import transformers\n",
|
20 |
+
"from transformers import pipeline\n",
|
21 |
+
"import tf_keras as keras\n",
|
22 |
+
"import pandas as pd\n",
|
23 |
+
"import tempfile\n",
|
24 |
+
"import os"
|
25 |
+
]
|
26 |
+
},
|
27 |
+
{
|
28 |
+
"cell_type": "markdown",
|
29 |
+
"id": "5bb130f0-d8c8-459d-918f-84025c93bc05",
|
30 |
+
"metadata": {},
|
31 |
+
"source": [
|
32 |
+
"### Now we import our already pre-trained model from "
|
33 |
+
]
|
34 |
+
},
|
35 |
+
{
|
36 |
+
"cell_type": "code",
|
37 |
+
"execution_count": 4,
|
38 |
+
"id": "1c4e29a8-9b24-47d6-b14b-0e2a7e4d66a1",
|
39 |
+
"metadata": {},
|
40 |
+
"outputs": [
|
41 |
+
{
|
42 |
+
"name": "stderr",
|
43 |
+
"output_type": "stream",
|
44 |
+
"text": [
|
45 |
+
"Some weights of the PyTorch model were not used when initializing the TF 2.0 model TFBertForSequenceClassification: ['bert.embeddings.position_ids']\n",
|
46 |
+
"- This IS expected if you are initializing TFBertForSequenceClassification from a PyTorch model trained on another task or with another architecture (e.g. initializing a TFBertForSequenceClassification model from a BertForPreTraining model).\n",
|
47 |
+
"- This IS NOT expected if you are initializing TFBertForSequenceClassification from a PyTorch model that you expect to be exactly identical (e.g. initializing a TFBertForSequenceClassification model from a BertForSequenceClassification model).\n",
|
48 |
+
"All the weights of TFBertForSequenceClassification were initialized from the PyTorch model.\n",
|
49 |
+
"If your task is similar to the task the model of the checkpoint was trained on, you can already use TFBertForSequenceClassification for predictions without further training.\n",
|
50 |
+
"Device set to use 0\n"
|
51 |
+
]
|
52 |
+
}
|
53 |
+
],
|
54 |
+
"source": [
|
55 |
+
"# Load pre-trained spam classifier\n",
|
56 |
+
"spam_classifier = pipeline(\n",
|
57 |
+
" \"text-classification\",\n",
|
58 |
+
" model=\"mrm8488/bert-tiny-finetuned-sms-spam-detection\"\n",
|
59 |
+
")"
|
60 |
+
]
|
61 |
+
},
|
62 |
+
{
|
63 |
+
"cell_type": "markdown",
|
64 |
+
"id": "9cb4ab66-2833-40bd-87cb-4d712398e431",
|
65 |
+
"metadata": {},
|
66 |
+
"source": [
|
67 |
+
"### Since single email check is hassle we will make a function for batch classication\n",
|
68 |
+
"### we should assume certain file template or format so our program knows what to expect"
|
69 |
+
]
|
70 |
+
},
|
71 |
+
{
|
72 |
+
"cell_type": "code",
|
73 |
+
"execution_count": 5,
|
74 |
+
"id": "b8ae7b3b-5273-4242-85db-b5cb622a4046",
|
75 |
+
"metadata": {},
|
76 |
+
"outputs": [],
|
77 |
+
"source": [
|
78 |
+
"def classify_batch(file):\n",
|
79 |
+
" \"\"\"Process uploaded CSV/TXT file with multiple emails\"\"\"\n",
|
80 |
+
" try:\n",
|
81 |
+
" results = []\n",
|
82 |
+
" \n",
|
83 |
+
" # Check if file exists\n",
|
84 |
+
" if not file.name:\n",
|
85 |
+
" raise gr.Error(\"No file uploaded\")\n",
|
86 |
+
"\n",
|
87 |
+
" # --- CSV File Handling ---\n",
|
88 |
+
" if file.name.endswith('.csv'):\n",
|
89 |
+
" df = pd.read_csv(file)\n",
|
90 |
+
" \n",
|
91 |
+
" # Check for required email column\n",
|
92 |
+
" if 'email' not in df.columns:\n",
|
93 |
+
" raise gr.Error(\"CSV file must contain a column named 'email'\")\n",
|
94 |
+
" \n",
|
95 |
+
" emails = df['email'].tolist()\n",
|
96 |
+
"\n",
|
97 |
+
" # --- Text File Handling ---\n",
|
98 |
+
" elif file.name.endswith('.txt'):\n",
|
99 |
+
" with open(file.name, 'r') as f:\n",
|
100 |
+
" emails = f.readlines()\n",
|
101 |
+
" \n",
|
102 |
+
" # --- Unsupported Format ---\n",
|
103 |
+
" else:\n",
|
104 |
+
" raise gr.Error(\"Unsupported file format. Only CSV/TXT accepted\")\n",
|
105 |
+
"\n",
|
106 |
+
" # Process emails (common for both formats)\n",
|
107 |
+
" emails = emails[:100] # Limit to 100 emails\n",
|
108 |
+
" for email in emails:\n",
|
109 |
+
" # Handle empty lines in text files\n",
|
110 |
+
" if not email.strip():\n",
|
111 |
+
" continue\n",
|
112 |
+
" \n",
|
113 |
+
" prediction = spam_classifier(email.strip())[0]\n",
|
114 |
+
" results.append({\n",
|
115 |
+
" \"email\": email.strip()[:50] + \"...\",\n",
|
116 |
+
" \"label\": \"SPAM\" if prediction[\"label\"] == \"LABEL_1\" else \"HAM\",\n",
|
117 |
+
" \"confidence\": f\"{prediction['score']:.4f}\"\n",
|
118 |
+
" })\n",
|
119 |
+
"\n",
|
120 |
+
" return pd.DataFrame(results)\n",
|
121 |
+
"\n",
|
122 |
+
" except gr.Error as e:\n",
|
123 |
+
" raise e # Show pop-up for expected errors\n",
|
124 |
+
" except Exception as e:\n",
|
125 |
+
" raise gr.Error(f\"Processing error: {str(e)}\")"
|
126 |
+
]
|
127 |
+
},
|
128 |
+
{
|
129 |
+
"cell_type": "markdown",
|
130 |
+
"id": "6ccb5108-a5d4-4f61-b363-dc4c9d25b4fb",
|
131 |
+
"metadata": {},
|
132 |
+
"source": [
|
133 |
+
"### We define simple function for classification"
|
134 |
+
]
|
135 |
+
},
|
136 |
+
{
|
137 |
+
"cell_type": "code",
|
138 |
+
"execution_count": 6,
|
139 |
+
"id": "1336344b-54c3-431d-8d89-c351b0c24f80",
|
140 |
+
"metadata": {},
|
141 |
+
"outputs": [],
|
142 |
+
"source": [
|
143 |
+
"def classify_text(text):\n",
|
144 |
+
" result = spam_classifier(text)[0]\n",
|
145 |
+
" return {\n",
|
146 |
+
" \"Spam\": result[\"score\"] if result[\"label\"] == \"LABEL_1\" else 1 - result[\"score\"],\n",
|
147 |
+
" \"Ham\": result[\"score\"] if result[\"label\"] == \"LABEL_0\" else 1 - result[\"score\"]\n",
|
148 |
+
" }"
|
149 |
+
]
|
150 |
+
},
|
151 |
+
{
|
152 |
+
"cell_type": "markdown",
|
153 |
+
"id": "4559470b-1356-4f9d-b977-44bfbe117f3d",
|
154 |
+
"metadata": {},
|
155 |
+
"source": [
|
156 |
+
"### using gradio we will make a simple interface for our program"
|
157 |
+
]
|
158 |
+
},
|
159 |
+
{
|
160 |
+
"cell_type": "code",
|
161 |
+
"execution_count": 12,
|
162 |
+
"id": "67927628-4ca2-43ac-80c3-a1f9d4771d5d",
|
163 |
+
"metadata": {
|
164 |
+
"scrolled": true
|
165 |
+
},
|
166 |
+
"outputs": [
|
167 |
+
{
|
168 |
+
"name": "stdout",
|
169 |
+
"output_type": "stream",
|
170 |
+
"text": [
|
171 |
+
"* Running on local URL: http://127.0.0.1:7868\n",
|
172 |
+
"Caching examples at: '/Users/techgarage/Projects/spamedar/.gradio/cached_examples/143'\n",
|
173 |
+
"\n",
|
174 |
+
"To create a public link, set `share=True` in `launch()`.\n"
|
175 |
+
]
|
176 |
+
},
|
177 |
+
{
|
178 |
+
"data": {
|
179 |
+
"text/html": [
|
180 |
+
"<div><iframe src=\"http://127.0.0.1:7868/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
181 |
+
],
|
182 |
+
"text/plain": [
|
183 |
+
"<IPython.core.display.HTML object>"
|
184 |
+
]
|
185 |
+
},
|
186 |
+
"metadata": {},
|
187 |
+
"output_type": "display_data"
|
188 |
+
}
|
189 |
+
],
|
190 |
+
"source": [
|
191 |
+
"with gr.Blocks(title=\"Spam Classifier Pro\") as demo:\n",
|
192 |
+
" gr.Markdown(\"# 📧 Welcome to Spamedar!\")\n",
|
193 |
+
" \n",
|
194 |
+
" \n",
|
195 |
+
" with gr.Tab(\"✉️ Single Email\"):\n",
|
196 |
+
" gr.Interface(\n",
|
197 |
+
" description=\"<h2>Copy your email to find out if it's a is Spam or Ham👇<h2>\",\n",
|
198 |
+
" fn=classify_text,\n",
|
199 |
+
" inputs=gr.Textbox(label=\"Input Email\", lines=3),\n",
|
200 |
+
" outputs=gr.Label(label=\"Classification\"),\n",
|
201 |
+
" examples=[\n",
|
202 |
+
" [\"Urgent: Verify your account details now!\"],\n",
|
203 |
+
" [\"Hey, can we meet tomorrow to discuss the project?\"],\n",
|
204 |
+
" [\"WINNER! You've been selected for a $1000 Walmart Gift Card!\"],\n",
|
205 |
+
" [\"Your account needs verification. Click here to confirm your details.\"],\n",
|
206 |
+
" [\"Meeting rescheduled to Friday 2 PM\"]\n",
|
207 |
+
" ]\n",
|
208 |
+
" )\n",
|
209 |
+
" current_dir = os.getcwd()\n",
|
210 |
+
" with gr.Tab(\"📨 Multiple Emails\"):\n",
|
211 |
+
" gr.Markdown(\"## Upload email batch (CSV or TXT)\")\n",
|
212 |
+
" file_input = gr.File(label=\"Upload File\", file_types=[\".csv\", \".txt\"])\n",
|
213 |
+
" clear_btn = gr.Button(\"Clear Selection\", variant=\"secondary\")\n",
|
214 |
+
" output_table = gr.Dataframe(\n",
|
215 |
+
" headers=[\"email\", \"label\", \"confidence\"],\n",
|
216 |
+
" datatype=[\"str\", \"str\", \"number\"],\n",
|
217 |
+
" interactive=False,\n",
|
218 |
+
" label=\"Classification Results\"\n",
|
219 |
+
" )\n",
|
220 |
+
" download_btn = gr.DownloadButton(label=\"Download Results\")\n",
|
221 |
+
"\n",
|
222 |
+
" def process_file(file):\n",
|
223 |
+
" \"\"\"Process file and return (display_df, download_path)\"\"\"\n",
|
224 |
+
" try:\n",
|
225 |
+
" if file is None:\n",
|
226 |
+
" return pd.DataFrame(), None\n",
|
227 |
+
"\n",
|
228 |
+
" results_df = classify_batch(file)\n",
|
229 |
+
" with tempfile.NamedTemporaryFile(suffix=\".csv\", delete=False) as f:\n",
|
230 |
+
" results_df.to_csv(f.name, index=False)\n",
|
231 |
+
" return results_df, f.name\n",
|
232 |
+
" except Exception as e:\n",
|
233 |
+
" raise gr.Error(f\"Error processing file: {str(e)}\")\n",
|
234 |
+
"\n",
|
235 |
+
" def clear_selection():\n",
|
236 |
+
" ###clear file input and results function\n",
|
237 |
+
" return None, pd.DataFrame(), None\n",
|
238 |
+
" \n",
|
239 |
+
" file_input.upload(\n",
|
240 |
+
" fn=process_file,\n",
|
241 |
+
" inputs=file_input,\n",
|
242 |
+
" outputs=[output_table, download_btn] # Update both components\n",
|
243 |
+
" )\n",
|
244 |
+
"\n",
|
245 |
+
" clear_btn.click(\n",
|
246 |
+
" fn=clear_selection,\n",
|
247 |
+
" outputs=[file_input, output_table, download_btn]\n",
|
248 |
+
" )\n",
|
249 |
+
"\n",
|
250 |
+
" example_files= [\n",
|
251 |
+
" os.path.join(os.getcwd(), \"sample_emails.csv\"),\n",
|
252 |
+
" os.path.join(os.getcwd(), \"batch_emails.txt\"),\n",
|
253 |
+
" ]\n",
|
254 |
+
" if all(os.path.exists(f) for f in example_files):\n",
|
255 |
+
" gr.Examples(\n",
|
256 |
+
" examples=[[f] for f in example_files],\n",
|
257 |
+
" inputs=file_input,\n",
|
258 |
+
" outputs=[output_table, download_btn],\n",
|
259 |
+
" fn=process_file,\n",
|
260 |
+
" cache_examples=True,\n",
|
261 |
+
" label=\"Click any example below to test:\"\n",
|
262 |
+
" )\n",
|
263 |
+
" \n",
|
264 |
+
" else:\n",
|
265 |
+
" print(\"Warning: Example files missing. Place these in your project root:\")\n",
|
266 |
+
" print(\"- sample_emails.csv\")\n",
|
267 |
+
" print(\"- batch_emails.txt\")\n",
|
268 |
+
" \n",
|
269 |
+
"if __name__ == \"__main__\":\n",
|
270 |
+
" demo.launch()"
|
271 |
+
]
|
272 |
+
},
|
273 |
+
{
|
274 |
+
"cell_type": "markdown",
|
275 |
+
"id": "18c2a4bd-0404-46ec-87b1-4f47b5802150",
|
276 |
+
"metadata": {},
|
277 |
+
"source": [
|
278 |
+
"### Thank you for following the guide until the end.🚀👾\n",
|
279 |
+
"code: Raouf Jivad(with a lil help of GPT 😃)"
|
280 |
+
]
|
281 |
+
}
|
282 |
+
],
|
283 |
+
"metadata": {
|
284 |
+
"kernelspec": {
|
285 |
+
"display_name": "Python 3 (ipykernel)",
|
286 |
+
"language": "python",
|
287 |
+
"name": "python3"
|
288 |
+
},
|
289 |
+
"language_info": {
|
290 |
+
"codemirror_mode": {
|
291 |
+
"name": "ipython",
|
292 |
+
"version": 3
|
293 |
+
},
|
294 |
+
"file_extension": ".py",
|
295 |
+
"mimetype": "text/x-python",
|
296 |
+
"name": "python",
|
297 |
+
"nbconvert_exporter": "python",
|
298 |
+
"pygments_lexer": "ipython3",
|
299 |
+
"version": "3.10.16"
|
300 |
+
}
|
301 |
+
},
|
302 |
+
"nbformat": 4,
|
303 |
+
"nbformat_minor": 5
|
304 |
+
}
|
others/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
others/Logo.png
ADDED
![]() |
Git LFS Details
|
others/MainNote Backup.ipynb
ADDED
@@ -0,0 +1,532 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "markdown",
|
5 |
+
"id": "53e9feaa-53de-4377-8d45-aa1f7264ae3a",
|
6 |
+
"metadata": {},
|
7 |
+
"source": [
|
8 |
+
"### First Neccesary libararies needs to be loaded."
|
9 |
+
]
|
10 |
+
},
|
11 |
+
{
|
12 |
+
"cell_type": "code",
|
13 |
+
"execution_count": 32,
|
14 |
+
"id": "8864f53f-15d2-403c-a905-3da509cfb050",
|
15 |
+
"metadata": {},
|
16 |
+
"outputs": [],
|
17 |
+
"source": [
|
18 |
+
"import gradio as gr\n",
|
19 |
+
"import transformers\n",
|
20 |
+
"from transformers import pipeline\n",
|
21 |
+
"import tf_keras as keras\n",
|
22 |
+
"import pandas as pd\n",
|
23 |
+
"import os"
|
24 |
+
]
|
25 |
+
},
|
26 |
+
{
|
27 |
+
"cell_type": "markdown",
|
28 |
+
"id": "5bb130f0-d8c8-459d-918f-84025c93bc05",
|
29 |
+
"metadata": {},
|
30 |
+
"source": [
|
31 |
+
"### Now we import our already pre-trained model from "
|
32 |
+
]
|
33 |
+
},
|
34 |
+
{
|
35 |
+
"cell_type": "code",
|
36 |
+
"execution_count": 13,
|
37 |
+
"id": "1c4e29a8-9b24-47d6-b14b-0e2a7e4d66a1",
|
38 |
+
"metadata": {},
|
39 |
+
"outputs": [
|
40 |
+
{
|
41 |
+
"name": "stderr",
|
42 |
+
"output_type": "stream",
|
43 |
+
"text": [
|
44 |
+
"Some weights of the PyTorch model were not used when initializing the TF 2.0 model TFBertForSequenceClassification: ['bert.embeddings.position_ids']\n",
|
45 |
+
"- This IS expected if you are initializing TFBertForSequenceClassification from a PyTorch model trained on another task or with another architecture (e.g. initializing a TFBertForSequenceClassification model from a BertForPreTraining model).\n",
|
46 |
+
"- This IS NOT expected if you are initializing TFBertForSequenceClassification from a PyTorch model that you expect to be exactly identical (e.g. initializing a TFBertForSequenceClassification model from a BertForSequenceClassification model).\n",
|
47 |
+
"All the weights of TFBertForSequenceClassification were initialized from the PyTorch model.\n",
|
48 |
+
"If your task is similar to the task the model of the checkpoint was trained on, you can already use TFBertForSequenceClassification for predictions without further training.\n",
|
49 |
+
"Device set to use 0\n"
|
50 |
+
]
|
51 |
+
}
|
52 |
+
],
|
53 |
+
"source": [
|
54 |
+
"# Load pre-trained spam classifier\n",
|
55 |
+
"spam_classifier = pipeline(\n",
|
56 |
+
" \"text-classification\",\n",
|
57 |
+
" model=\"mrm8488/bert-tiny-finetuned-sms-spam-detection\"\n",
|
58 |
+
")"
|
59 |
+
]
|
60 |
+
},
|
61 |
+
{
|
62 |
+
"cell_type": "code",
|
63 |
+
"execution_count": 4,
|
64 |
+
"id": "8b27be80-1a6c-4c6c-a3ac-fe3b6f1378ae",
|
65 |
+
"metadata": {},
|
66 |
+
"outputs": [],
|
67 |
+
"source": [
|
68 |
+
"import tempfile"
|
69 |
+
]
|
70 |
+
},
|
71 |
+
{
|
72 |
+
"cell_type": "markdown",
|
73 |
+
"id": "9cb4ab66-2833-40bd-87cb-4d712398e431",
|
74 |
+
"metadata": {},
|
75 |
+
"source": [
|
76 |
+
"### Since single email check is hassle we will make a function for batch classication\n",
|
77 |
+
"### we should assume certain file template or format so our program knows what to expect"
|
78 |
+
]
|
79 |
+
},
|
80 |
+
{
|
81 |
+
"cell_type": "code",
|
82 |
+
"execution_count": 32,
|
83 |
+
"id": "215fd411-623f-43ce-8775-1bbd2c130b56",
|
84 |
+
"metadata": {
|
85 |
+
"jupyter": {
|
86 |
+
"source_hidden": true
|
87 |
+
}
|
88 |
+
},
|
89 |
+
"outputs": [],
|
90 |
+
"source": [
|
91 |
+
"def classify_batch(file):\n",
|
92 |
+
" \"\"\"Process uploaded CSV/TXT file with multiple emails\"\"\"\n",
|
93 |
+
" results = []\n",
|
94 |
+
" if file.name.endswith('.csv'): # Handling the emails in CSV files format\n",
|
95 |
+
" df = pd.read_csv(file)\n",
|
96 |
+
" emails = df['email'].tolist() # we assume there's a column named 'email'\n",
|
97 |
+
" for idx, email in enumerate(emails):\n",
|
98 |
+
" prediction = spam_classifier(email)[0]\n",
|
99 |
+
" results.append({\n",
|
100 |
+
" \"email\": email[:50] + \"...\", # Truncate for display\n",
|
101 |
+
" \"label\": \"SPAM\" if prediction[\"label\"] == \"LABEL_1\" else \"HAM\",\n",
|
102 |
+
" \"confidence\": prediction[\"score\"]\n",
|
103 |
+
" })\n",
|
104 |
+
"\n",
|
105 |
+
" ### Now we almost do the same thing but for text files (one email per line)\n",
|
106 |
+
" elif file.name.endswith('.txt'):\n",
|
107 |
+
" with open(file.name, 'r') as f:\n",
|
108 |
+
" emails = f.readlines()\n",
|
109 |
+
" for email in emails:\n",
|
110 |
+
" prediction = spam_classifier(email.strip())[0]\n",
|
111 |
+
" results.append({\n",
|
112 |
+
" \"email\": email.strip()[:50] + \"...\",\n",
|
113 |
+
" \"label\": \"SPAM\" if prediction[\"label\"] == \"LABEL_1\" else \"HAM\",\n",
|
114 |
+
" \"confidence\": f\"{prediction['score']:.4f}\"\n",
|
115 |
+
" })\n",
|
116 |
+
" ### --------------- Here we implemnt some condition for our uploaded files __________\n",
|
117 |
+
" try:\n",
|
118 |
+
" results = []\n",
|
119 |
+
" if not file.name:\n",
|
120 |
+
" raise gr.Error(\"No file uploaded\")\n",
|
121 |
+
" # Handle CSV files\n",
|
122 |
+
" if file.name.endswith('.csv'):\n",
|
123 |
+
" df = pd.read_csv(file)\n",
|
124 |
+
" if 'email' not in df.columns:\n",
|
125 |
+
" raise gr.Error(\"CSV file must contain 'email' column\")\n",
|
126 |
+
" emails = df['email'].tolist()\n",
|
127 |
+
" \n",
|
128 |
+
" # Handle text files\n",
|
129 |
+
" elif file.name.endswith('.txt'):\n",
|
130 |
+
" with open(file.name, 'r') as f:\n",
|
131 |
+
" emails = f.readlines()\n",
|
132 |
+
" else:\n",
|
133 |
+
" raise gr.Error(\"Unsupported file format. Only CSV/TXT accepted\")\n",
|
134 |
+
" \n",
|
135 |
+
" # Limit to 100 emails max for demo\n",
|
136 |
+
" emails = emails[:100]\n",
|
137 |
+
"\n",
|
138 |
+
"\n",
|
139 |
+
" except gr.Error as e:\n",
|
140 |
+
" raise e # Re-raise Gradio errors to show pop-up\n",
|
141 |
+
" except Exception as e:\n",
|
142 |
+
" raise gr.Error(f\"An unexpected error occurred: {str(e)}\")\n",
|
143 |
+
"\n",
|
144 |
+
"\n",
|
145 |
+
" return pd.DataFrame(results)"
|
146 |
+
]
|
147 |
+
},
|
148 |
+
{
|
149 |
+
"cell_type": "code",
|
150 |
+
"execution_count": 27,
|
151 |
+
"id": "b8ae7b3b-5273-4242-85db-b5cb622a4046",
|
152 |
+
"metadata": {},
|
153 |
+
"outputs": [],
|
154 |
+
"source": [
|
155 |
+
"def classify_batch(file):\n",
|
156 |
+
" \"\"\"Process uploaded CSV/TXT file with multiple emails\"\"\"\n",
|
157 |
+
" try:\n",
|
158 |
+
" results = []\n",
|
159 |
+
" \n",
|
160 |
+
" # Check if file exists\n",
|
161 |
+
" if not file.name:\n",
|
162 |
+
" raise gr.Error(\"No file uploaded\")\n",
|
163 |
+
"\n",
|
164 |
+
" # --- CSV File Handling ---\n",
|
165 |
+
" if file.name.endswith('.csv'):\n",
|
166 |
+
" df = pd.read_csv(file)\n",
|
167 |
+
" \n",
|
168 |
+
" # Check for required email column\n",
|
169 |
+
" if 'email' not in df.columns:\n",
|
170 |
+
" raise gr.Error(\"CSV file must contain a column named 'email'\")\n",
|
171 |
+
" \n",
|
172 |
+
" emails = df['email'].tolist()\n",
|
173 |
+
"\n",
|
174 |
+
" # --- Text File Handling ---\n",
|
175 |
+
" elif file.name.endswith('.txt'):\n",
|
176 |
+
" with open(file.name, 'r') as f:\n",
|
177 |
+
" emails = f.readlines()\n",
|
178 |
+
" \n",
|
179 |
+
" # --- Unsupported Format ---\n",
|
180 |
+
" else:\n",
|
181 |
+
" raise gr.Error(\"Unsupported file format. Only CSV/TXT accepted\")\n",
|
182 |
+
"\n",
|
183 |
+
" # Process emails (common for both formats)\n",
|
184 |
+
" emails = emails[:100] # Limit to 100 emails\n",
|
185 |
+
" for email in emails:\n",
|
186 |
+
" # Handle empty lines in text files\n",
|
187 |
+
" if not email.strip():\n",
|
188 |
+
" continue\n",
|
189 |
+
" \n",
|
190 |
+
" prediction = spam_classifier(email.strip())[0]\n",
|
191 |
+
" results.append({\n",
|
192 |
+
" \"email\": email.strip()[:50] + \"...\",\n",
|
193 |
+
" \"label\": \"SPAM\" if prediction[\"label\"] == \"LABEL_1\" else \"HAM\",\n",
|
194 |
+
" \"confidence\": f\"{prediction['score']:.4f}\"\n",
|
195 |
+
" })\n",
|
196 |
+
"\n",
|
197 |
+
" return pd.DataFrame(results)\n",
|
198 |
+
"\n",
|
199 |
+
" except gr.Error as e:\n",
|
200 |
+
" raise e # Show pop-up for expected errors\n",
|
201 |
+
" except Exception as e:\n",
|
202 |
+
" raise gr.Error(f\"Processing error: {str(e)}\")"
|
203 |
+
]
|
204 |
+
},
|
205 |
+
{
|
206 |
+
"cell_type": "markdown",
|
207 |
+
"id": "6ccb5108-a5d4-4f61-b363-dc4c9d25b4fb",
|
208 |
+
"metadata": {},
|
209 |
+
"source": [
|
210 |
+
"### We define simple function for classification"
|
211 |
+
]
|
212 |
+
},
|
213 |
+
{
|
214 |
+
"cell_type": "code",
|
215 |
+
"execution_count": 28,
|
216 |
+
"id": "1336344b-54c3-431d-8d89-c351b0c24f80",
|
217 |
+
"metadata": {},
|
218 |
+
"outputs": [],
|
219 |
+
"source": [
|
220 |
+
"def classify_text(text):\n",
|
221 |
+
" result = spam_classifier(text)[0]\n",
|
222 |
+
" return {\n",
|
223 |
+
" \"Spam\": result[\"score\"] if result[\"label\"] == \"LABEL_1\" else 1 - result[\"score\"],\n",
|
224 |
+
" \"Ham\": result[\"score\"] if result[\"label\"] == \"LABEL_0\" else 1 - result[\"score\"]\n",
|
225 |
+
" }"
|
226 |
+
]
|
227 |
+
},
|
228 |
+
{
|
229 |
+
"cell_type": "code",
|
230 |
+
"execution_count": 33,
|
231 |
+
"id": "c428e83a-dbe6-4c91-8a05-5b550652c181",
|
232 |
+
"metadata": {},
|
233 |
+
"outputs": [
|
234 |
+
{
|
235 |
+
"name": "stderr",
|
236 |
+
"output_type": "stream",
|
237 |
+
"text": [
|
238 |
+
"huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...\n",
|
239 |
+
"To disable this warning, you can either:\n",
|
240 |
+
"\t- Avoid using `tokenizers` before the fork if possible\n",
|
241 |
+
"\t- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)\n"
|
242 |
+
]
|
243 |
+
},
|
244 |
+
{
|
245 |
+
"name": "stdout",
|
246 |
+
"output_type": "stream",
|
247 |
+
"text": [
|
248 |
+
"* Running on local URL: http://127.0.0.1:7867\n",
|
249 |
+
"Caching examples at: '/Users/techgarage/Projects/spamedar/.gradio/cached_examples/318'\n",
|
250 |
+
"\n",
|
251 |
+
"To create a public link, set `share=True` in `launch()`.\n"
|
252 |
+
]
|
253 |
+
},
|
254 |
+
{
|
255 |
+
"data": {
|
256 |
+
"text/html": [
|
257 |
+
"<div><iframe src=\"http://127.0.0.1:7867/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
258 |
+
],
|
259 |
+
"text/plain": [
|
260 |
+
"<IPython.core.display.HTML object>"
|
261 |
+
]
|
262 |
+
},
|
263 |
+
"metadata": {},
|
264 |
+
"output_type": "display_data"
|
265 |
+
}
|
266 |
+
],
|
267 |
+
"source": [
|
268 |
+
"with gr.Blocks(title=\"Spam Classifier Pro\") as demo:\n",
|
269 |
+
" gr.Markdown(\"# 📧 Spam Classification System\")\n",
|
270 |
+
" \n",
|
271 |
+
" with gr.Tab(\"Single Email\"):\n",
|
272 |
+
" gr.Interface(\n",
|
273 |
+
" fn=classify_text,\n",
|
274 |
+
" inputs=gr.Textbox(label=\"Input Email\", lines=3),\n",
|
275 |
+
" outputs=gr.Label(label=\"Classification\"),\n",
|
276 |
+
" examples=[\n",
|
277 |
+
" [\"Urgent: Verify your account details now!\"],\n",
|
278 |
+
" [\"Meeting rescheduled to Friday 2 PM\"]\n",
|
279 |
+
" ]\n",
|
280 |
+
" )\n",
|
281 |
+
" current_dir = os.getcwd()\n",
|
282 |
+
" with gr.Tab(\"Batch Processing\"):\n",
|
283 |
+
" gr.Markdown(\"## Upload email batch (CSV or TXT)\")\n",
|
284 |
+
" file_input = gr.File(label=\"Upload File\", file_types=[\".csv\", \".txt\"])\n",
|
285 |
+
" clear_btn = gr.Button(\"Clear Selection\", variant=\"secondary\")\n",
|
286 |
+
" output_table = gr.Dataframe(\n",
|
287 |
+
" headers=[\"email\", \"label\", \"confidence\"],\n",
|
288 |
+
" datatype=[\"str\", \"str\", \"number\"],\n",
|
289 |
+
" interactive=False,\n",
|
290 |
+
" label=\"Classification Results\"\n",
|
291 |
+
" )\n",
|
292 |
+
" download_btn = gr.DownloadButton(label=\"Download Results\")\n",
|
293 |
+
" \n",
|
294 |
+
" def process_file(file):\n",
|
295 |
+
" \"\"\"Process file and return (display_df, download_path)\"\"\"\n",
|
296 |
+
" try:\n",
|
297 |
+
" if file is None:\n",
|
298 |
+
" return pd.DataFrame(), None\n",
|
299 |
+
" \n",
|
300 |
+
" results_df = classify_batch(file)\n",
|
301 |
+
" with tempfile.NamedTemporaryFile(suffix=\".csv\", delete=False) as f:\n",
|
302 |
+
" results_df.to_csv(f.name, index=False)\n",
|
303 |
+
" return results_df, f.name\n",
|
304 |
+
" except Exception as e:\n",
|
305 |
+
" raise gr.Error(f\"Error processing file: {str(e)}\")\n",
|
306 |
+
"\n",
|
307 |
+
" def clear_selection():\n",
|
308 |
+
" \"\"\"Clear file input and results\"\"\"\n",
|
309 |
+
" return None, pd.DataFrame(), None\n",
|
310 |
+
" \n",
|
311 |
+
" file_input.upload(\n",
|
312 |
+
" fn=process_file,\n",
|
313 |
+
" inputs=file_input,\n",
|
314 |
+
" outputs=[output_table, download_btn]\n",
|
315 |
+
" )\n",
|
316 |
+
"\n",
|
317 |
+
" clear_btn.click(\n",
|
318 |
+
" fn=clear_selection,\n",
|
319 |
+
" outputs=[file_input, output_table, download_btn]\n",
|
320 |
+
" )\n",
|
321 |
+
" \n",
|
322 |
+
" example_files = [\n",
|
323 |
+
" os.path.join(os.getcwd(), \"sample_emails.csv\"),\n",
|
324 |
+
" os.path.join(os.getcwd(), \"batch_emails.txt\")\n",
|
325 |
+
" ]\n",
|
326 |
+
" if all(os.path.exists(f) for f in example_files):\n",
|
327 |
+
" gr.Examples(\n",
|
328 |
+
" examples=[[f] for f in example_files],\n",
|
329 |
+
" inputs=file_input,\n",
|
330 |
+
" outputs=[output_table, download_btn],\n",
|
331 |
+
" fn=process_file,\n",
|
332 |
+
" cache_examples=True,\n",
|
333 |
+
" label=\"Click any example below to test:\"\n",
|
334 |
+
" )\n",
|
335 |
+
"\n",
|
336 |
+
" else:\n",
|
337 |
+
" print(\"Warning: Example files missing. Place these in your project root:\")\n",
|
338 |
+
" print(\"- sample_emails.csv\")\n",
|
339 |
+
" print(\"- batch_emails.txt\")\n",
|
340 |
+
"\n",
|
341 |
+
"if __name__ == \"__main__\":\n",
|
342 |
+
" demo.launch()"
|
343 |
+
]
|
344 |
+
},
|
345 |
+
{
|
346 |
+
"cell_type": "markdown",
|
347 |
+
"id": "4559470b-1356-4f9d-b977-44bfbe117f3d",
|
348 |
+
"metadata": {},
|
349 |
+
"source": [
|
350 |
+
"### using gradio we will make a simple interface for our program"
|
351 |
+
]
|
352 |
+
},
|
353 |
+
{
|
354 |
+
"cell_type": "code",
|
355 |
+
"execution_count": 21,
|
356 |
+
"id": "dfa7f58b-0ab8-445e-bfab-1396f2443033",
|
357 |
+
"metadata": {},
|
358 |
+
"outputs": [],
|
359 |
+
"source": []
|
360 |
+
},
|
361 |
+
{
|
362 |
+
"cell_type": "code",
|
363 |
+
"execution_count": 17,
|
364 |
+
"id": "67927628-4ca2-43ac-80c3-a1f9d4771d5d",
|
365 |
+
"metadata": {
|
366 |
+
"scrolled": true
|
367 |
+
},
|
368 |
+
"outputs": [
|
369 |
+
{
|
370 |
+
"name": "stderr",
|
371 |
+
"output_type": "stream",
|
372 |
+
"text": [
|
373 |
+
"huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...\n",
|
374 |
+
"To disable this warning, you can either:\n",
|
375 |
+
"\t- Avoid using `tokenizers` before the fork if possible\n",
|
376 |
+
"\t- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)\n"
|
377 |
+
]
|
378 |
+
},
|
379 |
+
{
|
380 |
+
"name": "stdout",
|
381 |
+
"output_type": "stream",
|
382 |
+
"text": [
|
383 |
+
"* Running on local URL: http://127.0.0.1:7863\n",
|
384 |
+
"\n",
|
385 |
+
"To create a public link, set `share=True` in `launch()`.\n"
|
386 |
+
]
|
387 |
+
},
|
388 |
+
{
|
389 |
+
"data": {
|
390 |
+
"text/html": [
|
391 |
+
"<div><iframe src=\"http://127.0.0.1:7863/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
392 |
+
],
|
393 |
+
"text/plain": [
|
394 |
+
"<IPython.core.display.HTML object>"
|
395 |
+
]
|
396 |
+
},
|
397 |
+
"metadata": {},
|
398 |
+
"output_type": "display_data"
|
399 |
+
}
|
400 |
+
],
|
401 |
+
"source": [
|
402 |
+
"with gr.Blocks(title=\"Spam Classifier Pro\") as demo:\n",
|
403 |
+
" gr.Markdown(\"# 📧 Welcome to Spamedar!\")\n",
|
404 |
+
" \n",
|
405 |
+
" \n",
|
406 |
+
" with gr.Tab(\"✉️ Single Email\"):\n",
|
407 |
+
" gr.Interface(\n",
|
408 |
+
" fn=classify_text,\n",
|
409 |
+
" inputs=gr.Textbox(label=\"Input Email\", lines=3),\n",
|
410 |
+
" outputs=gr.Label(label=\"Classification\"),\n",
|
411 |
+
" examples=[\n",
|
412 |
+
" [\"Urgent: Verify your account details now!\"],\n",
|
413 |
+
" [\"Hey, can we meet tomorrow to discuss the project?\"],\n",
|
414 |
+
" [\"WINNER! You've been selected for a $1000 Walmart Gift Card!\"],\n",
|
415 |
+
" [\"Your account needs verification. Click here to confirm your details.\"],\n",
|
416 |
+
" [\"Meeting rescheduled to Friday 2 PM\"]\n",
|
417 |
+
" ]\n",
|
418 |
+
" )\n",
|
419 |
+
" \n",
|
420 |
+
" with gr.Tab(\"📨 Multiple Emails\"):\n",
|
421 |
+
" gr.Markdown(\"## Upload email batch (CSV or TXT)\")\n",
|
422 |
+
" file_input = gr.File(label=\"Upload File\", file_types=[\".csv\", \".txt\"])\n",
|
423 |
+
" output_table = gr.Dataframe(\n",
|
424 |
+
" headers=[\"email\", \"label\", \"confidence\"],\n",
|
425 |
+
" datatype=[\"str\", \"str\", \"number\"],\n",
|
426 |
+
" interactive=False,\n",
|
427 |
+
" label=\"Classification Results\"\n",
|
428 |
+
" )\n",
|
429 |
+
" download_btn = gr.DownloadButton(label=\"Download Results\")\n",
|
430 |
+
"\n",
|
431 |
+
" def process_file(file):\n",
|
432 |
+
" \"\"\"Process file and return (display_df, download_path)\"\"\"\n",
|
433 |
+
" results_df = classify_batch(file)\n",
|
434 |
+
" \n",
|
435 |
+
" with tempfile.NamedTemporaryFile(suffix=\".csv\", delete=False) as f:\n",
|
436 |
+
" results_df.to_csv(f.name, index=False)\n",
|
437 |
+
" return results_df, f.name\n",
|
438 |
+
" \n",
|
439 |
+
" file_input.upload(\n",
|
440 |
+
" fn=process_file,\n",
|
441 |
+
" inputs=file_input,\n",
|
442 |
+
" outputs=[output_table, download_btn] # Update both components\n",
|
443 |
+
" )\n",
|
444 |
+
" \n",
|
445 |
+
" gr.Examples(\n",
|
446 |
+
" examples=[\n",
|
447 |
+
" [\"sample_emails.csv\"],\n",
|
448 |
+
" [\"batch_emails.txt\"]\n",
|
449 |
+
" ],\n",
|
450 |
+
" inputs=file_input\n",
|
451 |
+
" )\n",
|
452 |
+
"if __name__ == \"__main__\":\n",
|
453 |
+
" demo.launch()"
|
454 |
+
]
|
455 |
+
},
|
456 |
+
{
|
457 |
+
"cell_type": "code",
|
458 |
+
"execution_count": 17,
|
459 |
+
"id": "188e3c31-38ef-4191-8b24-5487724466bd",
|
460 |
+
"metadata": {
|
461 |
+
"collapsed": true,
|
462 |
+
"jupyter": {
|
463 |
+
"outputs_hidden": true,
|
464 |
+
"source_hidden": true
|
465 |
+
}
|
466 |
+
},
|
467 |
+
"outputs": [
|
468 |
+
{
|
469 |
+
"ename": "FileNotFoundError",
|
470 |
+
"evalue": "[Errno 2] No such file or directory: 'sample_emails.csv'",
|
471 |
+
"output_type": "error",
|
472 |
+
"traceback": [
|
473 |
+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
474 |
+
"\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)",
|
475 |
+
"Cell \u001b[0;32mIn[17], line 31\u001b[0m\n\u001b[1;32m 23\u001b[0m download_btn \u001b[38;5;241m=\u001b[39m gr\u001b[38;5;241m.\u001b[39mFile(label\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mDownload Results\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 25\u001b[0m file_input\u001b[38;5;241m.\u001b[39mupload(\n\u001b[1;32m 26\u001b[0m fn\u001b[38;5;241m=\u001b[39mclassify_batch,\n\u001b[1;32m 27\u001b[0m inputs\u001b[38;5;241m=\u001b[39mfile_input,\n\u001b[1;32m 28\u001b[0m outputs\u001b[38;5;241m=\u001b[39moutput_table\n\u001b[1;32m 29\u001b[0m )\n\u001b[0;32m---> 31\u001b[0m \u001b[43mgr\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mExamples\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 32\u001b[0m \u001b[43m \u001b[49m\u001b[43mexamples\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\n\u001b[1;32m 33\u001b[0m \u001b[43m \u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43msample_emails.csv\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 34\u001b[0m \u001b[43m \u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mbatch_emails.txt\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\n\u001b[1;32m 35\u001b[0m \u001b[43m \u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 36\u001b[0m \u001b[43m \u001b[49m\u001b[43minputs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mfile_input\u001b[49m\n\u001b[1;32m 37\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 39\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;18m__name__\u001b[39m \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m__main__\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[1;32m 40\u001b[0m demo\u001b[38;5;241m.\u001b[39mlaunch()\n",
|
476 |
+
"File \u001b[0;32m~/anaconda3/envs/grad/lib/python3.10/site-packages/gradio/helpers.py:57\u001b[0m, in \u001b[0;36mcreate_examples\u001b[0;34m(examples, inputs, outputs, fn, cache_examples, cache_mode, examples_per_page, _api_mode, label, elem_id, run_on_click, preprocess, postprocess, api_name, batch, example_labels, visible)\u001b[0m\n\u001b[1;32m 36\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21mcreate_examples\u001b[39m(\n\u001b[1;32m 37\u001b[0m examples: \u001b[38;5;28mlist\u001b[39m[Any] \u001b[38;5;241m|\u001b[39m \u001b[38;5;28mlist\u001b[39m[\u001b[38;5;28mlist\u001b[39m[Any]] \u001b[38;5;241m|\u001b[39m \u001b[38;5;28mstr\u001b[39m,\n\u001b[1;32m 38\u001b[0m inputs: Component \u001b[38;5;241m|\u001b[39m Sequence[Component],\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 54\u001b[0m visible: \u001b[38;5;28mbool\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mTrue\u001b[39;00m,\n\u001b[1;32m 55\u001b[0m ):\n\u001b[1;32m 56\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"Top-level synchronous function that creates Examples. Provided for backwards compatibility, i.e. so that gr.Examples(...) can be used to create the Examples component.\"\"\"\u001b[39;00m\n\u001b[0;32m---> 57\u001b[0m examples_obj \u001b[38;5;241m=\u001b[39m \u001b[43mExamples\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 58\u001b[0m \u001b[43m \u001b[49m\u001b[43mexamples\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mexamples\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 59\u001b[0m \u001b[43m \u001b[49m\u001b[43minputs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43minputs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 60\u001b[0m \u001b[43m \u001b[49m\u001b[43moutputs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43moutputs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 61\u001b[0m \u001b[43m \u001b[49m\u001b[43mfn\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mfn\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 62\u001b[0m \u001b[43m \u001b[49m\u001b[43mcache_examples\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcache_examples\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 63\u001b[0m \u001b[43m \u001b[49m\u001b[43mcache_mode\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcache_mode\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 64\u001b[0m \u001b[43m \u001b[49m\u001b[43mexamples_per_page\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mexamples_per_page\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 65\u001b[0m \u001b[43m \u001b[49m\u001b[43m_api_mode\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m_api_mode\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 66\u001b[0m \u001b[43m \u001b[49m\u001b[43mlabel\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mlabel\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 67\u001b[0m \u001b[43m \u001b[49m\u001b[43melem_id\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43melem_id\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 68\u001b[0m \u001b[43m \u001b[49m\u001b[43mrun_on_click\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrun_on_click\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 69\u001b[0m \u001b[43m \u001b[49m\u001b[43mpreprocess\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mpreprocess\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 70\u001b[0m \u001b[43m \u001b[49m\u001b[43mpostprocess\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mpostprocess\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 71\u001b[0m \u001b[43m \u001b[49m\u001b[43mapi_name\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mapi_name\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 72\u001b[0m \u001b[43m \u001b[49m\u001b[43mbatch\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mbatch\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 73\u001b[0m \u001b[43m \u001b[49m\u001b[43mexample_labels\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mexample_labels\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 74\u001b[0m \u001b[43m \u001b[49m\u001b[43mvisible\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mvisible\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 75\u001b[0m \u001b[43m \u001b[49m\u001b[43m_initiated_directly\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m 76\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 77\u001b[0m examples_obj\u001b[38;5;241m.\u001b[39mcreate()\n\u001b[1;32m 78\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m examples_obj\n",
|
477 |
+
"File \u001b[0;32m~/anaconda3/envs/grad/lib/python3.10/site-packages/gradio/helpers.py:294\u001b[0m, in \u001b[0;36mExamples.__init__\u001b[0;34m(self, examples, inputs, outputs, fn, cache_examples, cache_mode, examples_per_page, _api_mode, label, elem_id, run_on_click, preprocess, postprocess, api_name, batch, example_labels, visible, _initiated_directly)\u001b[0m\n\u001b[1;32m 291\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdataset\u001b[38;5;241m.\u001b[39msamples:\n\u001b[1;32m 292\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m index, example \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28menumerate\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mnon_none_examples):\n\u001b[1;32m 293\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mnon_none_processed_examples[\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdataset\u001b[38;5;241m.\u001b[39msamples[index]] \u001b[38;5;241m=\u001b[39m (\n\u001b[0;32m--> 294\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_get_processed_example\u001b[49m\u001b[43m(\u001b[49m\u001b[43mexample\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 295\u001b[0m )\n\u001b[1;32m 297\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcache_examples \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mlazy\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[1;32m 298\u001b[0m \u001b[38;5;28mprint\u001b[39m(\n\u001b[1;32m 299\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mWill cache examples in \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mutils\u001b[38;5;241m.\u001b[39mabspath(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcached_folder)\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m directory at first use.\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 300\u001b[0m end\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 301\u001b[0m )\n",
|
478 |
+
"File \u001b[0;32m~/anaconda3/envs/grad/lib/python3.10/site-packages/gradio/helpers.py:328\u001b[0m, in \u001b[0;36mExamples._get_processed_example\u001b[0;34m(self, example)\u001b[0m\n\u001b[1;32m 324\u001b[0m sub \u001b[38;5;241m=\u001b[39m []\n\u001b[1;32m 325\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m component, sample \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mzip\u001b[39m(\n\u001b[1;32m 326\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39minputs_with_examples, example, strict\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m\n\u001b[1;32m 327\u001b[0m ):\n\u001b[0;32m--> 328\u001b[0m prediction_value \u001b[38;5;241m=\u001b[39m \u001b[43mcomponent\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mpostprocess\u001b[49m\u001b[43m(\u001b[49m\u001b[43msample\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 329\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(prediction_value, (GradioRootModel, GradioModel)):\n\u001b[1;32m 330\u001b[0m prediction_value \u001b[38;5;241m=\u001b[39m prediction_value\u001b[38;5;241m.\u001b[39mmodel_dump()\n",
|
479 |
+
"File \u001b[0;32m~/anaconda3/envs/grad/lib/python3.10/site-packages/gradio/components/file.py:223\u001b[0m, in \u001b[0;36mFile.postprocess\u001b[0;34m(self, value)\u001b[0m\n\u001b[1;32m 209\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m ListFiles(\n\u001b[1;32m 210\u001b[0m root\u001b[38;5;241m=\u001b[39m[\n\u001b[1;32m 211\u001b[0m FileData(\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 217\u001b[0m ]\n\u001b[1;32m 218\u001b[0m )\n\u001b[1;32m 219\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 220\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m FileData(\n\u001b[1;32m 221\u001b[0m path\u001b[38;5;241m=\u001b[39mvalue,\n\u001b[1;32m 222\u001b[0m orig_name\u001b[38;5;241m=\u001b[39mPath(value)\u001b[38;5;241m.\u001b[39mname,\n\u001b[0;32m--> 223\u001b[0m size\u001b[38;5;241m=\u001b[39m\u001b[43mPath\u001b[49m\u001b[43m(\u001b[49m\u001b[43mvalue\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstat\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241m.\u001b[39mst_size,\n\u001b[1;32m 224\u001b[0m )\n",
|
480 |
+
"File \u001b[0;32m~/anaconda3/envs/grad/lib/python3.10/pathlib.py:1097\u001b[0m, in \u001b[0;36mPath.stat\u001b[0;34m(self, follow_symlinks)\u001b[0m\n\u001b[1;32m 1092\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21mstat\u001b[39m(\u001b[38;5;28mself\u001b[39m, \u001b[38;5;241m*\u001b[39m, follow_symlinks\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m):\n\u001b[1;32m 1093\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 1094\u001b[0m \u001b[38;5;124;03m Return the result of the stat() system call on this path, like\u001b[39;00m\n\u001b[1;32m 1095\u001b[0m \u001b[38;5;124;03m os.stat() does.\u001b[39;00m\n\u001b[1;32m 1096\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[0;32m-> 1097\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_accessor\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstat\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfollow_symlinks\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mfollow_symlinks\u001b[49m\u001b[43m)\u001b[49m\n",
|
481 |
+
"\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: 'sample_emails.csv'"
|
482 |
+
]
|
483 |
+
}
|
484 |
+
],
|
485 |
+
"source": [
|
486 |
+
"demo = gr.Interface(\n",
|
487 |
+
" fn=classify_text,\n",
|
488 |
+
" inputs=gr.Textbox(label=\"Email/Message\", placeholder=\"Enter text here...\"),\n",
|
489 |
+
" outputs=gr.Label(label=\"Classification Results\"),\n",
|
490 |
+
" title=\"Spamedar\",\n",
|
491 |
+
" description=\"Copy your email to find out if it's a is Spam or Ham.👇\",\n",
|
492 |
+
" examples=[\n",
|
493 |
+
" [\"Hey, can we meet tomorrow to discuss the project?\"],\n",
|
494 |
+
" [\"WINNER! You've been selected for a $1000 Walmart Gift Card!\"],\n",
|
495 |
+
" [\"Your account needs verification. Click here to confirm your details.\"]\n",
|
496 |
+
" ]\n",
|
497 |
+
")\n",
|
498 |
+
"\n",
|
499 |
+
"demo.launch()"
|
500 |
+
]
|
501 |
+
},
|
502 |
+
{
|
503 |
+
"cell_type": "code",
|
504 |
+
"execution_count": null,
|
505 |
+
"id": "73be7578-bc18-4af7-8a00-52b6ee4b21e9",
|
506 |
+
"metadata": {},
|
507 |
+
"outputs": [],
|
508 |
+
"source": []
|
509 |
+
}
|
510 |
+
],
|
511 |
+
"metadata": {
|
512 |
+
"kernelspec": {
|
513 |
+
"display_name": "Python 3 (ipykernel)",
|
514 |
+
"language": "python",
|
515 |
+
"name": "python3"
|
516 |
+
},
|
517 |
+
"language_info": {
|
518 |
+
"codemirror_mode": {
|
519 |
+
"name": "ipython",
|
520 |
+
"version": 3
|
521 |
+
},
|
522 |
+
"file_extension": ".py",
|
523 |
+
"mimetype": "text/x-python",
|
524 |
+
"name": "python",
|
525 |
+
"nbconvert_exporter": "python",
|
526 |
+
"pygments_lexer": "ipython3",
|
527 |
+
"version": "3.10.16"
|
528 |
+
}
|
529 |
+
},
|
530 |
+
"nbformat": 4,
|
531 |
+
"nbformat_minor": 5
|
532 |
+
}
|
others/Screen Shot 2025-03-01 at 2.49.21 AM.png
ADDED
![]() |
Git LFS Details
|
others/demo-screenshot.png
ADDED
![]() |
Git LFS Details
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio>=3.0
|
2 |
+
transformers>=4.30
|
3 |
+
torch>=2.0
|
4 |
+
pandas>=1.0
|
sample_emails.csv
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
email
|
2 |
+
"Hi John, just wanted to follow up about tomorrow's meeting. Please confirm your attendance."
|
3 |
+
Congratulations! You've won a free cruise vacation! Click here to claim your prize >>>
|
4 |
+
Your Amazon order #456789 has shipped. Track your package: https://amzn.track/456789
|
5 |
+
URGENT: Your bank account requires immediate verification. Login now to avoid suspension.
|
6 |
+
Reminder: Team lunch today at 1 PM in the main conference room.
|
sample_emailsNoColumn.csv
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
dfsfsd
|
2 |
+
"Hi John, just wanted to follow up about tomorrow's meeting. Please confirm your attendance."
|
3 |
+
Congratulations! You've won a free cruise vacation! Click here to claim your prize >>>
|
4 |
+
Your Amazon order #456789 has shipped. Track your package: https://amzn.track/456789
|
5 |
+
URGENT: Your bank account requires immediate verification. Login now to avoid suspension.
|
6 |
+
Reminder: Team lunch today at 1 PM in the main conference room.
|