laura.wagner commited on
Commit
da53813
Β·
1 Parent(s): 263b6e9

added qwen query code

Browse files
jupyter_notebooks/.ipynb_checkpoints/GEMMA_3-checkpoint.ipynb ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [],
3
+ "metadata": {},
4
+ "nbformat": 4,
5
+ "nbformat_minor": 5
6
+ }
jupyter_notebooks/.ipynb_checkpoints/MISTRAL-checkpoint.ipynb ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [],
3
+ "metadata": {},
4
+ "nbformat": 4,
5
+ "nbformat_minor": 5
6
+ }
jupyter_notebooks/.ipynb_checkpoints/QWEN-checkpoint.ipynb ADDED
@@ -0,0 +1,465 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "0543d9c4-055b-49a3-a8d0-9dfb622b2b8c",
6
+ "metadata": {},
7
+ "source": [
8
+ "# QWEN CODE"
9
+ ]
10
+ },
11
+ {
12
+ "cell_type": "code",
13
+ "execution_count": null,
14
+ "id": "fe6ba282-896b-4272-b82b-ef24810732fb",
15
+ "metadata": {},
16
+ "outputs": [],
17
+ "source": [
18
+ "import pandas as pd\n",
19
+ "import json\n",
20
+ "import time\n",
21
+ "import re\n",
22
+ "from pathlib import Path\n",
23
+ "from tqdm import tqdm\n",
24
+ "import torch\n",
25
+ "from transformers import AutoModelForCausalLM, AutoTokenizer\n",
26
+ "import signal\n",
27
+ "from contextlib import contextmanager\n",
28
+ "\n",
29
+ "current_dir = Path.cwd()\n",
30
+ "input_file = current_dir.parent / \"data/CSV/model_adapter/real_person_adapter_step_02_NER.csv\"\n",
31
+ "professions_file = current_dir.parent / \"misc/lists/professions.csv\"\n",
32
+ "professions_mapped_file = current_dir.parent / \"misc/lists/professions_mapped.csv\"\n",
33
+ "# === PROCESS DATA ===\n",
34
+ "\n",
35
+ "\n",
36
+ "# === CONFIGURATION ===\n",
37
+ "TEST_MODE = False\n",
38
+ "TEST_SIZE = 100\n",
39
+ "MAX_ROWS = 50862\n",
40
+ "SAVE_INTERVAL = 10\n",
41
+ "\n",
42
+ "\n",
43
+ "index_file = current_dir.parent / \"misc/query_indicies/qwen_local_query_index.txt\"\n",
44
+ "output_file = current_dir.parent / f\"data/CSV/qwen_local_annotated_POI{'_test' if TEST_MODE else ''}.csv\"\n",
45
+ "\n",
46
+ "# Model settings\n",
47
+ "MODEL_NAME = \"Qwen/Qwen3-235B-A22B-Instruct-2507-FP8\"\n",
48
+ "#MODEL_NAME = \"mistralai/Mistral-7B-Instruct-v0.3\"\n",
49
+ "CACHE_DIR = current_dir.parent / \"data/models\"\n",
50
+ "CACHE_DIR.mkdir(parents=True, exist_ok=True)\n",
51
+ "\n",
52
+ "# Define the SPECIFIC profession categories\n",
53
+ "PROFESSION_CATEGORIES = [\n",
54
+ " \"actor\",\n",
55
+ " \"adult performer\",\n",
56
+ " \"singer/musician\",\n",
57
+ " \"model\",\n",
58
+ " \"online personality\",\n",
59
+ " \"public figure\",\n",
60
+ " \"voice actor/ASMR\",\n",
61
+ " \"sports professional\",\n",
62
+ " \"tv personality\"\n",
63
+ "]\n",
64
+ "\n",
65
+ "# === LOAD MODEL ===\n",
66
+ "print(f\"Loading model: {MODEL_NAME}\")\n",
67
+ "print(f\"Cache directory: {CACHE_DIR}\")\n",
68
+ "print(f\"This may take a while on first run (~65GB download)...\\n\")\n",
69
+ "\n",
70
+ "# Check GPU availability\n",
71
+ "device = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n",
72
+ "print(f\"Device: {device}\")\n",
73
+ "\n",
74
+ "if device == \"cpu\":\n",
75
+ " print(\"⚠️ WARNING: No GPU detected! Inference will be VERY slow.\")\n",
76
+ " print(\" Consider using a GPU or reducing model size.\")\n",
77
+ "\n",
78
+ "# Load tokenizer\n",
79
+ "print(\"Loading tokenizer...\")\n",
80
+ "try:\n",
81
+ " tokenizer = AutoTokenizer.from_pretrained(\n",
82
+ " MODEL_NAME,\n",
83
+ " cache_dir=str(CACHE_DIR),\n",
84
+ " use_fast=True\n",
85
+ " )\n",
86
+ "except Exception as e:\n",
87
+ " print(f\"Failed with use_fast=True, trying use_fast=False...\")\n",
88
+ " tokenizer = AutoTokenizer.from_pretrained(\n",
89
+ " MODEL_NAME,\n",
90
+ " cache_dir=str(CACHE_DIR),\n",
91
+ " use_fast=False\n",
92
+ " )\n",
93
+ "\n",
94
+ "# Ensure pad token is set\n",
95
+ "if tokenizer.pad_token is None:\n",
96
+ " tokenizer.pad_token = tokenizer.eos_token\n",
97
+ "\n",
98
+ "print(\"βœ… Tokenizer loaded\")\n",
99
+ "\n",
100
+ "# Load model with optimizations\n",
101
+ "print(\"Loading model (this may take several minutes)...\")\n",
102
+ "model = AutoModelForCausalLM.from_pretrained(\n",
103
+ " MODEL_NAME,\n",
104
+ " cache_dir=str(CACHE_DIR),\n",
105
+ " torch_dtype=torch.bfloat16,\n",
106
+ " device_map=\"cuda:0\", # Force single GPU instead of \"auto\"\n",
107
+ " trust_remote_code=False,\n",
108
+ " offload_folder=str(CACHE_DIR / \"offload\"), # Explicit offload folder\n",
109
+ " offload_state_dict=False # Try to keep everything on GPU\n",
110
+ ")\n",
111
+ "model.eval()\n",
112
+ "print(\"βœ… Model loaded\")\n",
113
+ "\n",
114
+ "# Load model with optimizations\n",
115
+ "print(\"Loading model (this may take several minutes)...\")\n",
116
+ "model = AutoModelForCausalLM.from_pretrained(\n",
117
+ " MODEL_NAME,\n",
118
+ " cache_dir=str(CACHE_DIR),\n",
119
+ " torch_dtype=torch.bfloat16,\n",
120
+ " device_map=\"auto\",\n",
121
+ " trust_remote_code=False\n",
122
+ ")\n",
123
+ "model.eval()\n",
124
+ "\n",
125
+ "# FORCE COMPLETE LOADING\n",
126
+ "print(\"Ensuring model is fully loaded to device...\")\n",
127
+ "for name, param in tqdm(model.named_parameters(), desc=\"Loading parameters\"):\n",
128
+ " if param.device.type == \"meta\":\n",
129
+ " # This parameter is on meta device and needs to be materialized\n",
130
+ " print(f\"Warning: {name} is on meta device\")\n",
131
+ "\n",
132
+ "# Try to trigger full loading with a dummy forward pass\n",
133
+ "print(\"Running dummy forward pass to ensure full loading...\")\n",
134
+ "dummy_input = torch.tensor([[1]], device=\"cuda\")\n",
135
+ "with torch.no_grad():\n",
136
+ " try:\n",
137
+ " _ = model(dummy_input)\n",
138
+ " except Exception as e:\n",
139
+ " print(f\"Dummy forward pass failed (expected): {e}\")\n",
140
+ "\n",
141
+ "print(\"βœ… Model fully loaded and ready\")\n",
142
+ "\n",
143
+ "\n",
144
+ "# Check VRAM usage\n",
145
+ "if torch.cuda.is_available():\n",
146
+ " vram_gb = torch.cuda.max_memory_allocated() / 1024**3\n",
147
+ " print(f\"VRAM used: {vram_gb:.2f} GB\\n\")\n",
148
+ "\n",
149
+ "# === LOAD DATA ===\n",
150
+ "if output_file.exists():\n",
151
+ " print(\"Loading annotated CSV...\")\n",
152
+ " df = pd.read_csv(output_file)\n",
153
+ "else:\n",
154
+ " print(\"Loading raw input CSV...\")\n",
155
+ " df = pd.read_csv(input_file)\n",
156
+ "\n",
157
+ "\n",
158
+ "# Try to load profession mapping files\n",
159
+ "try:\n",
160
+ " professions_df = pd.read_csv(professions_file)\n",
161
+ " print(f\"βœ… Loaded professions.csv\")\n",
162
+ "except:\n",
163
+ " print(\"⚠️ Warning: professions.csv not found\")\n",
164
+ "\n",
165
+ "try:\n",
166
+ " prof_mapped_df = pd.read_csv(professions_mapped_file)\n",
167
+ " print(f\"βœ… Loaded profession mapping with {len(prof_mapped_df)} categories\")\n",
168
+ "except:\n",
169
+ " print(\"⚠️ Warning: professions_mapped.csv not found, using default categories\")\n",
170
+ "\n",
171
+ "profession_str = \", \".join(PROFESSION_CATEGORIES)\n",
172
+ "\n",
173
+ "print(f\"Loaded {len(df)} rows\")\n",
174
+ "print(f\"\\nProfession categories ({len(PROFESSION_CATEGORIES)}):\")\n",
175
+ "for cat in PROFESSION_CATEGORIES:\n",
176
+ " print(f\" - {cat}\")\n",
177
+ "\n",
178
+ "if TEST_MODE:\n",
179
+ " print(f\"\\nRunning in TEST MODE with {TEST_SIZE} samples\")\n",
180
+ " df = df.head(TEST_SIZE).copy()\n",
181
+ "elif MAX_ROWS:\n",
182
+ " df = df.head(MAX_ROWS).copy()\n",
183
+ "\n",
184
+ "# === CREATE PROMPTS (DEEPSEEK STYLE) ===\n",
185
+ "def create_prompt(row):\n",
186
+ " \"\"\"Create prompt for Qwen annotation with specific profession categories.\"\"\"\n",
187
+ " name = row['real_name'] if pd.notna(row.get('real_name')) else row.get('name', '')\n",
188
+ " \n",
189
+ " # Gather hints\n",
190
+ " hints = []\n",
191
+ " if pd.notna(row.get('likely_profession')):\n",
192
+ " hints.append(str(row['likely_profession']))\n",
193
+ " if pd.notna(row.get('likely_nationality')):\n",
194
+ " hints.append(str(row['likely_nationality']))\n",
195
+ " if pd.notna(row.get('likely_country')):\n",
196
+ " hints.append(str(row['likely_country']))\n",
197
+ " \n",
198
+ " # Add tags if we don't have enough hints\n",
199
+ " if len(hints) < 3:\n",
200
+ " for i in range(1, 8):\n",
201
+ " tag_col = f'tag_{i}'\n",
202
+ " if tag_col in row and pd.notna(row[tag_col]):\n",
203
+ " tag_val = str(row[tag_col])\n",
204
+ " if tag_val not in hints:\n",
205
+ " hints.append(tag_val)\n",
206
+ " if len(hints) >= 5:\n",
207
+ " break\n",
208
+ " \n",
209
+ " hint_text = \", \".join(hints[:5]) if hints else \"none\"\n",
210
+ " \n",
211
+ " return f\"\"\"Given '{name}' ({hint_text}), provide:\n",
212
+ "1. Full legal name (Western order if non-latin script)\n",
213
+ "2. Any stage names/aliases (comma separated)\n",
214
+ "3. Gender (Male/Female/Other/Unknown)\n",
215
+ "4. Top 3 most likely professions from ONLY these categories:\n",
216
+ " - actor\n",
217
+ " - adult performer\n",
218
+ " - singer/musician\n",
219
+ " - model\n",
220
+ " - online personality (includes streamers, cosplayers, influencers)\n",
221
+ " - public figure (includes politicians, activists, journalists, authors)\n",
222
+ " - voice actor/ASMR\n",
223
+ " - sports professional\n",
224
+ " - tv personality (includes hosts, presenters, reality TV)\n",
225
+ "\n",
226
+ "5. Primary country associated\n",
227
+ "\n",
228
+ "IMPORTANT:\n",
229
+ "- Choose professions ONLY from the 9 categories above\n",
230
+ "- Provide up to 3 professions, comma-separated, ordered by relevance\n",
231
+ "- Be SPECIFIC: choose the most accurate category for each role\n",
232
+ "- \"online personality\" includes: streamers, cosplayers, YouTubers, influencers, content creators\n",
233
+ "- Use 'Unknown' when uncertain or for fictional characters/places\n",
234
+ "- For multi-role people, list all relevant categories (e.g., \"actor, singer/musician, online personality\")\n",
235
+ "- For country respond with one word only, for example China or Columbia\n",
236
+ "- actress = actor\n",
237
+ "\n",
238
+ "Respond with exactly 5 numbered lines.\"\"\"\n",
239
+ "\n",
240
+ "# Create prompts\n",
241
+ "print(\"\\nCreating prompts...\")\n",
242
+ "df['prompt'] = df.apply(create_prompt, axis=1)\n",
243
+ "print(\"βœ… Prompts created\")\n",
244
+ "\n",
245
+ "@contextmanager\n",
246
+ "def timeout(duration):\n",
247
+ " def handler(signum, frame):\n",
248
+ " raise TimeoutError(\"Operation timed out\")\n",
249
+ " \n",
250
+ " # Set the signal handler and alarm\n",
251
+ " signal.signal(signal.SIGALRM, handler)\n",
252
+ " signal.alarm(duration)\n",
253
+ " try:\n",
254
+ " yield\n",
255
+ " finally:\n",
256
+ " signal.alarm(0) # Disable the alarm\n",
257
+ "\n",
258
+ "\n",
259
+ "def query_qwen_local(prompt: str) -> str:\n",
260
+ " \"\"\"Query Qwen locally via transformers.\"\"\"\n",
261
+ " try:\n",
262
+ " with timeout(60): # 60 second timeout\n",
263
+ " # Your existing generation code here\n",
264
+ " ...\n",
265
+ " except TimeoutError:\n",
266
+ " print(f\"[ERROR] Generation timed out after 60 seconds\")\n",
267
+ " return None\n",
268
+ " except Exception as e:\n",
269
+ " print(f\"Generation error: {e}\")\n",
270
+ " return None\n",
271
+ " \n",
272
+ " # Format as chat message for Qwen\n",
273
+ " messages = [\n",
274
+ " {\"role\": \"system\", \"content\": \"You are an assistant that extracts key data on a person based on the name. Respond with exactly 5 numbered lines. For professions, choose ONLY from these categories: actor, adult performer, singer/musician, model, online personality, public figure, voice actor/ASMR, sports professional, tv personality.\"},\n",
275
+ " {\"role\": \"user\", \"content\": prompt}\n",
276
+ " ]\n",
277
+ " \n",
278
+ " print(f\"[DEBUG] Applying chat template...\")\n",
279
+ " # Tokenize\n",
280
+ " if hasattr(tokenizer, 'apply_chat_template'):\n",
281
+ " text = tokenizer.apply_chat_template(\n",
282
+ " messages,\n",
283
+ " tokenize=False,\n",
284
+ " add_generation_prompt=True\n",
285
+ " )\n",
286
+ " else:\n",
287
+ " # Fallback for older tokenizers\n",
288
+ " text = f\"[INST] {prompt} [/INST]\"\n",
289
+ " \n",
290
+ " print(f\"[DEBUG] Tokenizing input...\")\n",
291
+ " inputs = tokenizer([text], return_tensors=\"pt\", padding=True).to(device)\n",
292
+ " \n",
293
+ " print(f\"[DEBUG] Input shape: {inputs['input_ids'].shape}\")\n",
294
+ " print(f\"[DEBUG] Starting generation...\")\n",
295
+ " \n",
296
+ " # Generate\n",
297
+ " with torch.no_grad():\n",
298
+ " outputs = model.generate(\n",
299
+ " **inputs,\n",
300
+ " max_new_tokens=100,\n",
301
+ " temperature=0.1,\n",
302
+ " do_sample=False,\n",
303
+ " #top_p=0.9,\n",
304
+ " pad_token_id=tokenizer.eos_token_id\n",
305
+ " )\n",
306
+ " \n",
307
+ " print(f\"[DEBUG] Generation complete, decoding...\")\n",
308
+ " \n",
309
+ " # Decode\n",
310
+ " generated_ids = outputs[0][inputs['input_ids'].shape[1]:]\n",
311
+ " response = tokenizer.decode(generated_ids, skip_special_tokens=True)\n",
312
+ " \n",
313
+ " print(f\"[DEBUG] Response: {response[:100]}...\") # First 100 chars\n",
314
+ " \n",
315
+ " return response.strip()\n",
316
+ " \n",
317
+ " except Exception as e:\n",
318
+ " print(f\"Generation error: {e}\")\n",
319
+ " import traceback\n",
320
+ " traceback.print_exc()\n",
321
+ " return None\n",
322
+ "\n",
323
+ "#output_file = current_dir.parent / f\"data/CSV/qwen_local_annotated_POI{'_test' if TEST_MODE else ''}.csv\"\n",
324
+ "#index_file = current_dir.parent / \"misc/query_indicies/qwen_local_query_index.txt\"\n",
325
+ "\n",
326
+ "\n",
327
+ " \n",
328
+ "# === PARSE RESPONSE (DEEPSEEK STYLE) ===\n",
329
+ "def parse_response(response):\n",
330
+ " \"\"\"Parse Qwen response into structured fields.\"\"\"\n",
331
+ " if not response:\n",
332
+ " return {\n",
333
+ " 'full_name': 'Unknown',\n",
334
+ " 'aliases': 'Unknown',\n",
335
+ " 'gender': 'Unknown',\n",
336
+ " 'profession_llm': 'Unknown',\n",
337
+ " 'country': 'Unknown'\n",
338
+ " }\n",
339
+ " \n",
340
+ " # Split into lines and clean\n",
341
+ " lines = [line.strip() for line in response.split('\\n') if line.strip()]\n",
342
+ " \n",
343
+ " # Initialize with Unknown values\n",
344
+ " fields = {\n",
345
+ " 'full_name': 'Unknown',\n",
346
+ " 'aliases': 'Unknown',\n",
347
+ " 'gender': 'Unknown',\n",
348
+ " 'profession_llm': 'Unknown',\n",
349
+ " 'country': 'Unknown'\n",
350
+ " }\n",
351
+ " \n",
352
+ " # Extract information from each numbered line\n",
353
+ " for line in lines:\n",
354
+ " if line.startswith('1.'):\n",
355
+ " fields['full_name'] = line[2:].strip()\n",
356
+ " elif line.startswith('2.'):\n",
357
+ " fields['aliases'] = line[2:].strip()\n",
358
+ " elif line.startswith('3.'):\n",
359
+ " fields['gender'] = line[2:].strip()\n",
360
+ " elif line.startswith('4.'):\n",
361
+ " fields['profession_llm'] = line[2:].strip()\n",
362
+ " elif line.startswith('5.'):\n",
363
+ " fields['country'] = line[2:].strip()\n",
364
+ " \n",
365
+ " return fields\n",
366
+ "\n",
367
+ "# === PROCESS DATA ===\n",
368
+ "index_file.parent.mkdir(parents=True, exist_ok=True)\n",
369
+ "\n",
370
+ "# Load index\n",
371
+ "current_index = 0\n",
372
+ "if index_file.exists():\n",
373
+ " try:\n",
374
+ " current_index = int(index_file.read_text().strip())\n",
375
+ " except:\n",
376
+ " current_index = 0\n",
377
+ "\n",
378
+ "print(f\"Resuming from index {current_index}\")\n",
379
+ "\n",
380
+ "start_time = time.time()\n",
381
+ "\n",
382
+ "for i in tqdm(range(current_index, len(df)), desc=\"Qwen Local\"):\n",
383
+ "\n",
384
+ " prompt = df.at[i, \"prompt\"]\n",
385
+ "\n",
386
+ " # -------- MODEL QUERY WITH RETRIES --------\n",
387
+ " response = None\n",
388
+ " for attempt in range(3):\n",
389
+ " response = query_qwen_local(prompt)\n",
390
+ " \n",
391
+ " # Valid response?\n",
392
+ " if response and len(response.strip()) > 10:\n",
393
+ " break\n",
394
+ " \n",
395
+ " print(f\"⚠️ Row {i}: Empty or invalid response, retry {attempt+1}/3\")\n",
396
+ " time.sleep(0.5)\n",
397
+ "\n",
398
+ " # If still invalid β†’ DO NOT overwrite previous data\n",
399
+ " if not response or len(response.strip()) <= 10:\n",
400
+ " print(f\"❌ Row {i}: failed after retries, not writing, not advancing index\")\n",
401
+ " continue\n",
402
+ "\n",
403
+ " parsed = parse_response(response)\n",
404
+ "\n",
405
+ " # Additional safety: skip rows that parsed as all 'Unknown'\n",
406
+ " if all(v == \"Unknown\" for v in parsed.values()):\n",
407
+ " print(f\"❌ Row {i}: parsed as all Unknown (likely model crash); skipping.\")\n",
408
+ " continue\n",
409
+ "\n",
410
+ " # -------- WRITE PARSED FIELDS SAFELY --------\n",
411
+ " for key, value in parsed.items():\n",
412
+ " df.at[i, key] = value\n",
413
+ "\n",
414
+ " # Advance progress ONLY after successful write\n",
415
+ " current_index = i + 1\n",
416
+ "\n",
417
+ " # -------- GPU MEMORY CLEANUP --------\n",
418
+ " if torch.cuda.is_available():\n",
419
+ " torch.cuda.empty_cache()\n",
420
+ " torch.cuda.synchronize()\n",
421
+ "\n",
422
+ " # -------- SAVE LIKE YOUR DEEPSEEK VERSION --------\n",
423
+ " if (i + 1) % SAVE_INTERVAL == 0 or (i + 1) == len(df):\n",
424
+ " df.to_csv(output_file, index=False)\n",
425
+ " with open(index_file, \"w\") as f:\n",
426
+ " f.write(str(current_index))\n",
427
+ " print(f\"πŸ’Ύ Progress saved after row {i+1}\")\n",
428
+ "\n",
429
+ "# Final save\n",
430
+ "df.to_csv(output_file, index=False)\n",
431
+ "index_file.write_text(str(current_index))\n",
432
+ "print(\"βœ… Finished full dataset.\")\n"
433
+ ]
434
+ },
435
+ {
436
+ "cell_type": "code",
437
+ "execution_count": null,
438
+ "id": "d9c7deb9-847a-472d-8055-f93dbfa6aa2e",
439
+ "metadata": {},
440
+ "outputs": [],
441
+ "source": []
442
+ }
443
+ ],
444
+ "metadata": {
445
+ "kernelspec": {
446
+ "display_name": "pm-paper",
447
+ "language": "python",
448
+ "name": "pm-paper"
449
+ },
450
+ "language_info": {
451
+ "codemirror_mode": {
452
+ "name": "ipython",
453
+ "version": 3
454
+ },
455
+ "file_extension": ".py",
456
+ "mimetype": "text/x-python",
457
+ "name": "python",
458
+ "nbconvert_exporter": "python",
459
+ "pygments_lexer": "ipython3",
460
+ "version": "3.11.13"
461
+ }
462
+ },
463
+ "nbformat": 4,
464
+ "nbformat_minor": 5
465
+ }
jupyter_notebooks/.ipynb_checkpoints/Section_2-2-2_Figure_4_Demographic_patterns_in_gen_images-checkpoint.ipynb ADDED
@@ -0,0 +1,1795 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "d8161f06-4fd2-436d-9e59-3f68b5a67f2c",
6
+ "metadata": {
7
+ "execution": {
8
+ "iopub.execute_input": "2025-02-06T18:30:16.974712Z",
9
+ "iopub.status.busy": "2025-02-06T18:30:16.974296Z",
10
+ "iopub.status.idle": "2025-02-06T18:30:16.976909Z",
11
+ "shell.execute_reply": "2025-02-06T18:30:16.976526Z",
12
+ "shell.execute_reply.started": "2025-02-06T18:30:16.974692Z"
13
+ }
14
+ },
15
+ "source": [
16
+ "# Section 6.2: Age and Gender Estimation using MiVOLO"
17
+ ]
18
+ },
19
+ {
20
+ "cell_type": "markdown",
21
+ "id": "64aaedec-ef56-4a62-b61e-12de2675a1ae",
22
+ "metadata": {
23
+ "execution": {
24
+ "iopub.execute_input": "2025-02-06T19:52:51.171282Z",
25
+ "iopub.status.busy": "2025-02-06T19:52:51.170711Z",
26
+ "iopub.status.idle": "2025-02-06T19:52:55.405039Z",
27
+ "shell.execute_reply": "2025-02-06T19:52:55.404308Z",
28
+ "shell.execute_reply.started": "2025-02-06T19:52:51.171245Z"
29
+ }
30
+ },
31
+ "source": [
32
+ "![Alt text](../plots/mivolo.svg)"
33
+ ]
34
+ },
35
+ {
36
+ "cell_type": "code",
37
+ "execution_count": 1,
38
+ "id": "4293f307-44fd-455e-90fe-6e6928be9af5",
39
+ "metadata": {
40
+ "execution": {
41
+ "iopub.execute_input": "2025-02-08T21:59:21.970807Z",
42
+ "iopub.status.busy": "2025-02-08T21:59:21.969931Z",
43
+ "iopub.status.idle": "2025-02-08T22:00:09.724295Z",
44
+ "shell.execute_reply": "2025-02-08T22:00:09.723583Z",
45
+ "shell.execute_reply.started": "2025-02-08T21:59:21.970784Z"
46
+ }
47
+ },
48
+ "outputs": [
49
+ {
50
+ "name": "stderr",
51
+ "output_type": "stream",
52
+ "text": [
53
+ "/home/lauwag/data/conda/envs/horde/lib/python3.12/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",
54
+ " from .autonotebook import tqdm as notebook_tqdm\n"
55
+ ]
56
+ }
57
+ ],
58
+ "source": [
59
+ "import csv\n",
60
+ "from pathlib import Path\n",
61
+ "import logging\n",
62
+ "import os\n",
63
+ "import pandas as pd\n",
64
+ "import requests\n",
65
+ "import numpy as np\n",
66
+ "import torch\n",
67
+ "import cv2\n",
68
+ "from io import BytesIO\n",
69
+ "from PIL import Image, UnidentifiedImageError\n",
70
+ "from datetime import datetime, timedelta\n",
71
+ "from dateutil.relativedelta import relativedelta\n",
72
+ "from mivolo.predictor import Predictor\n",
73
+ "import matplotlib.pyplot as plt\n",
74
+ "import matplotlib.patches as mpatches"
75
+ ]
76
+ },
77
+ {
78
+ "cell_type": "code",
79
+ "execution_count": 2,
80
+ "id": "63a54f5f-900c-48dd-8932-2632e56c5670",
81
+ "metadata": {
82
+ "execution": {
83
+ "iopub.execute_input": "2025-02-08T22:00:09.726069Z",
84
+ "iopub.status.busy": "2025-02-08T22:00:09.725699Z",
85
+ "iopub.status.idle": "2025-02-08T22:00:09.730626Z",
86
+ "shell.execute_reply": "2025-02-08T22:00:09.730099Z",
87
+ "shell.execute_reply.started": "2025-02-08T22:00:09.726050Z"
88
+ }
89
+ },
90
+ "outputs": [],
91
+ "source": [
92
+ "current_dir = Path.cwd()\n",
93
+ "mini = current_dir.parent / 'data/CSV/image_subsets/Civiverse-mini.csv'\n",
94
+ "mivolo_in = current_dir.parent / 'data/CSV/image_subsets/Civiverse-mini-by-month/'\n",
95
+ "(current_dir.parent / 'data/CSV/image_subsets/Civiverse-mini-by-month/').mkdir(parents=True, exist_ok=True)"
96
+ ]
97
+ },
98
+ {
99
+ "cell_type": "code",
100
+ "execution_count": 3,
101
+ "id": "1fdfb89a-6094-4382-8755-fae213221ea5",
102
+ "metadata": {
103
+ "execution": {
104
+ "iopub.execute_input": "2025-02-08T22:00:09.731540Z",
105
+ "iopub.status.busy": "2025-02-08T22:00:09.731359Z",
106
+ "iopub.status.idle": "2025-02-08T22:00:09.825738Z",
107
+ "shell.execute_reply": "2025-02-08T22:00:09.825258Z",
108
+ "shell.execute_reply.started": "2025-02-08T22:00:09.731524Z"
109
+ }
110
+ },
111
+ "outputs": [],
112
+ "source": [
113
+ "def split_by_month(input_path, output_dir):\n",
114
+ " # Load the dataset\n",
115
+ " df = pd.read_csv(input_path)\n",
116
+ " \n",
117
+ " # Convert the 'createdAt' column to datetime\n",
118
+ " df['createdAt'] = pd.to_datetime(df['createdAt'], errors='coerce')\n",
119
+ " \n",
120
+ " # Extract year and month\n",
121
+ " df['year_month'] = df['createdAt'].dt.to_period('M')\n",
122
+ " \n",
123
+ " # Group the data by year and month and save each group as a CSV file\n",
124
+ " unique_months = df['year_month'].unique()\n",
125
+ "\n",
126
+ " for month in unique_months:\n",
127
+ " # Filter data for the specific month\n",
128
+ " df_month = df[df['year_month'] == month]\n",
129
+ " \n",
130
+ " # Define the file name based on the year and month\n",
131
+ " file_name = f'{output_dir}/Civiverse-{month}.csv'\n",
132
+ " \n",
133
+ " # Save the file\n",
134
+ " df_month.to_csv(file_name, index=False)\n",
135
+ "\n",
136
+ " print(f\"Data has been split and saved to {output_dir}\")"
137
+ ]
138
+ },
139
+ {
140
+ "cell_type": "code",
141
+ "execution_count": 4,
142
+ "id": "2c909d7c-7d16-4dc7-8364-7f1c0784414c",
143
+ "metadata": {
144
+ "execution": {
145
+ "iopub.execute_input": "2025-02-08T22:00:09.827095Z",
146
+ "iopub.status.busy": "2025-02-08T22:00:09.826919Z",
147
+ "iopub.status.idle": "2025-02-08T22:00:10.479484Z",
148
+ "shell.execute_reply": "2025-02-08T22:00:10.478777Z",
149
+ "shell.execute_reply.started": "2025-02-08T22:00:09.827079Z"
150
+ }
151
+ },
152
+ "outputs": [
153
+ {
154
+ "name": "stderr",
155
+ "output_type": "stream",
156
+ "text": [
157
+ "/sctmp/lauwag/ipykernel_1497673/1825509207.py:9: UserWarning: Converting to PeriodArray/Index representation will drop timezone information.\n",
158
+ " df['year_month'] = df['createdAt'].dt.to_period('M')\n"
159
+ ]
160
+ },
161
+ {
162
+ "name": "stdout",
163
+ "output_type": "stream",
164
+ "text": [
165
+ "Data has been split and saved to /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/Civiverse-mini-by-month\n"
166
+ ]
167
+ }
168
+ ],
169
+ "source": [
170
+ "split_by_month(mini, mivolo_in)"
171
+ ]
172
+ },
173
+ {
174
+ "cell_type": "code",
175
+ "execution_count": 5,
176
+ "id": "4c543306-ffc8-4b9c-a3df-b49b2271caa9",
177
+ "metadata": {
178
+ "execution": {
179
+ "iopub.execute_input": "2025-02-08T22:00:10.480505Z",
180
+ "iopub.status.busy": "2025-02-08T22:00:10.480310Z",
181
+ "iopub.status.idle": "2025-02-08T22:00:10.483961Z",
182
+ "shell.execute_reply": "2025-02-08T22:00:10.483400Z",
183
+ "shell.execute_reply.started": "2025-02-08T22:00:10.480486Z"
184
+ }
185
+ },
186
+ "outputs": [],
187
+ "source": [
188
+ "mivolo_out = current_dir.parent / 'data/CSV/image_subsets/MiVOLO-results/'\n",
189
+ "mivolo_out.mkdir(parents=True, exist_ok=True) # Create the output directory if it doesn't exist"
190
+ ]
191
+ },
192
+ {
193
+ "cell_type": "markdown",
194
+ "id": "ffb7dd23",
195
+ "metadata": {},
196
+ "source": [
197
+ "## MiVOLO gender and age inference"
198
+ ]
199
+ },
200
+ {
201
+ "cell_type": "code",
202
+ "execution_count": null,
203
+ "id": "304ed12f-c7b6-4129-b24d-7ccc793a62c7",
204
+ "metadata": {
205
+ "execution": {
206
+ "iopub.execute_input": "2025-02-08T22:00:10.484802Z",
207
+ "iopub.status.busy": "2025-02-08T22:00:10.484639Z"
208
+ }
209
+ },
210
+ "outputs": [
211
+ {
212
+ "name": "stderr",
213
+ "output_type": "stream",
214
+ "text": [
215
+ "/home/lauwag/data/conda/envs/horde/lib/python3.12/site-packages/ultralytics/nn/tasks.py:634: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.\n",
216
+ " return torch.load(file, map_location=\"cpu\"), file # load\n"
217
+ ]
218
+ },
219
+ {
220
+ "name": "stdout",
221
+ "output_type": "stream",
222
+ "text": [
223
+ "Model summary (fused): 268 layers, 68125494 parameters, 0 gradients, 257.4 GFLOPs\n"
224
+ ]
225
+ },
226
+ {
227
+ "name": "stderr",
228
+ "output_type": "stream",
229
+ "text": [
230
+ "[W208 23:00:15.738708520 NNPACK.cpp:61] Could not initialize NNPACK! Reason: Unsupported hardware.\n",
231
+ "/home/lauwag/data/conda/envs/horde/lib/python3.12/site-packages/mivolo/model/mi_volo.py:33: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.\n",
232
+ " state = torch.load(ckpt_path, map_location=\"cpu\")\n",
233
+ "INFO:MiVOLO:Model meta:\n",
234
+ "min_age: 1, max_age: 95, avg_age: 48.0, num_classes: 3, in_chans: 6, with_persons_model: True, disable_faces: False, use_persons: True, only_age: False, num_classes_gender: 2, input_size: 224, use_person_crops: True, use_face_crops: True\n",
235
+ "/home/lauwag/data/conda/envs/horde/lib/python3.12/site-packages/timm/models/_helpers.py:39: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.\n",
236
+ " checkpoint = torch.load(checkpoint_path, map_location='cpu')\n",
237
+ "INFO:timm.models._helpers:Loaded state_dict from checkpoint '/shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/ext/MiVOLO/models/mivolo_imbd.pth.tar'\n",
238
+ "INFO:MiVOLO:Model mivolo_d1_224 created, param count: 27432414\n",
239
+ "INFO:timm.data.config:Data processing configuration for current model + dataset:\n",
240
+ "INFO:timm.data.config:\tinput_size: (3, 224, 224)\n",
241
+ "INFO:timm.data.config:\tinterpolation: bicubic\n",
242
+ "INFO:timm.data.config:\tmean: (0.485, 0.456, 0.406)\n",
243
+ "INFO:timm.data.config:\tstd: (0.229, 0.224, 0.225)\n",
244
+ "INFO:timm.data.config:\tcrop_pct: 0.96\n",
245
+ "INFO:timm.data.config:\tcrop_mode: center\n"
246
+ ]
247
+ },
248
+ {
249
+ "name": "stdout",
250
+ "output_type": "stream",
251
+ "text": [
252
+ "Processing: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/Civiverse-mini-by-month/Civiverse-2022-11.csv\n",
253
+ "\n",
254
+ "0: 640x640 (no detections), 723.9ms\n",
255
+ "Speed: 12.1ms preprocess, 723.9ms inference, 0.8ms postprocess per image at shape (1, 3, 640, 640)\n",
256
+ "Processed and saved 1 images so far.\n",
257
+ "Processed and saved to: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/MiVOLO-results/2022-11.csv\n",
258
+ "File not found: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/Civiverse-mini-by-month/Civiverse-2022-12.csv\n",
259
+ "File not found: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/Civiverse-mini-by-month/Civiverse-2023-01.csv\n",
260
+ "File not found: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/Civiverse-mini-by-month/Civiverse-2023-02.csv\n",
261
+ "File not found: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/Civiverse-mini-by-month/Civiverse-2023-03.csv\n",
262
+ "File not found: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/Civiverse-mini-by-month/Civiverse-2023-04.csv\n",
263
+ "File not found: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/Civiverse-mini-by-month/Civiverse-2023-05.csv\n",
264
+ "Processing: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/Civiverse-mini-by-month/Civiverse-2023-06.csv\n",
265
+ "\n",
266
+ "0: 416x640 1 person, 455.1ms\n",
267
+ "Speed: 3.5ms preprocess, 455.1ms inference, 33.5ms postprocess per image at shape (1, 3, 416, 640)\n"
268
+ ]
269
+ },
270
+ {
271
+ "name": "stderr",
272
+ "output_type": "stream",
273
+ "text": [
274
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
275
+ "INFO:MiVOLO:\tage: 32.89\n",
276
+ "INFO:MiVOLO:\tgender: male [99%]\n"
277
+ ]
278
+ },
279
+ {
280
+ "name": "stdout",
281
+ "output_type": "stream",
282
+ "text": [
283
+ "Processed and saved 1 images so far.\n",
284
+ "Processed and saved to: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/MiVOLO-results/2023-06.csv\n",
285
+ "Processing: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/Civiverse-mini-by-month/Civiverse-2023-07.csv\n",
286
+ "\n",
287
+ "0: 640x320 1 person, 395.7ms\n",
288
+ "Speed: 2.9ms preprocess, 395.7ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 320)\n"
289
+ ]
290
+ },
291
+ {
292
+ "name": "stderr",
293
+ "output_type": "stream",
294
+ "text": [
295
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
296
+ "INFO:MiVOLO:\tage: 33.49\n",
297
+ "INFO:MiVOLO:\tgender: female [99%]\n"
298
+ ]
299
+ },
300
+ {
301
+ "name": "stdout",
302
+ "output_type": "stream",
303
+ "text": [
304
+ "Processed and saved 1 images so far.\n",
305
+ "\n",
306
+ "0: 640x448 1 person, 1 face, 478.5ms\n",
307
+ "Speed: 1.9ms preprocess, 478.5ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 448)\n"
308
+ ]
309
+ },
310
+ {
311
+ "name": "stderr",
312
+ "output_type": "stream",
313
+ "text": [
314
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
315
+ "INFO:MiVOLO:\tage: 17.81\n",
316
+ "INFO:MiVOLO:\tgender: female [99%]\n"
317
+ ]
318
+ },
319
+ {
320
+ "name": "stdout",
321
+ "output_type": "stream",
322
+ "text": [
323
+ "Processed and saved 2 images so far.\n",
324
+ "Processed and saved to: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/MiVOLO-results/2023-07.csv\n",
325
+ "Processing: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/Civiverse-mini-by-month/Civiverse-2023-08.csv\n",
326
+ "\n",
327
+ "0: 640x448 1 person, 478.0ms\n",
328
+ "Speed: 2.9ms preprocess, 478.0ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 448)\n"
329
+ ]
330
+ },
331
+ {
332
+ "name": "stderr",
333
+ "output_type": "stream",
334
+ "text": [
335
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
336
+ "INFO:MiVOLO:\tage: 40.62\n",
337
+ "INFO:MiVOLO:\tgender: male [99%]\n"
338
+ ]
339
+ },
340
+ {
341
+ "name": "stdout",
342
+ "output_type": "stream",
343
+ "text": [
344
+ "Processed and saved 1 images so far.\n",
345
+ "Processed and saved to: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/MiVOLO-results/2023-08.csv\n",
346
+ "Processing: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/Civiverse-mini-by-month/Civiverse-2023-09.csv\n",
347
+ "\n",
348
+ "0: 416x640 (no detections), 567.1ms\n",
349
+ "Speed: 2.4ms preprocess, 567.1ms inference, 0.4ms postprocess per image at shape (1, 3, 416, 640)\n",
350
+ "Processed and saved 1 images so far.\n",
351
+ "\n",
352
+ "0: 320x640 (no detections), 393.6ms\n",
353
+ "Speed: 1.7ms preprocess, 393.6ms inference, 0.4ms postprocess per image at shape (1, 3, 320, 640)\n",
354
+ "\n",
355
+ "0: 640x640 (no detections), 711.9ms\n",
356
+ "Speed: 3.4ms preprocess, 711.9ms inference, 0.5ms postprocess per image at shape (1, 3, 640, 640)\n",
357
+ "\n",
358
+ "0: 640x640 (no detections), 699.8ms\n",
359
+ "Speed: 2.3ms preprocess, 699.8ms inference, 0.5ms postprocess per image at shape (1, 3, 640, 640)\n",
360
+ "\n",
361
+ "0: 640x576 1 person, 629.6ms\n",
362
+ "Speed: 2.4ms preprocess, 629.6ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 576)\n"
363
+ ]
364
+ },
365
+ {
366
+ "name": "stderr",
367
+ "output_type": "stream",
368
+ "text": [
369
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
370
+ "INFO:MiVOLO:\tage: 28.65\n",
371
+ "INFO:MiVOLO:\tgender: female [99%]\n"
372
+ ]
373
+ },
374
+ {
375
+ "name": "stdout",
376
+ "output_type": "stream",
377
+ "text": [
378
+ "\n",
379
+ "0: 640x448 1 person, 1 face, 598.3ms\n",
380
+ "Speed: 2.1ms preprocess, 598.3ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 448)\n"
381
+ ]
382
+ },
383
+ {
384
+ "name": "stderr",
385
+ "output_type": "stream",
386
+ "text": [
387
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
388
+ "INFO:MiVOLO:\tage: 25.85\n",
389
+ "INFO:MiVOLO:\tgender: female [99%]\n",
390
+ "ERROR:inference:Unidentified image error for URL https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/98848c97-3d1e-4b52-9967-aeeca354a30e/width=656/98848c97-3d1e-4b52-9967-aeeca354a30e.mp4: cannot identify image file <_io.BytesIO object at 0x14cb00133740>\n"
391
+ ]
392
+ },
393
+ {
394
+ "name": "stdout",
395
+ "output_type": "stream",
396
+ "text": [
397
+ "Processed and saved to: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/MiVOLO-results/2023-09.csv\n",
398
+ "Processing: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/Civiverse-mini-by-month/Civiverse-2023-10.csv\n"
399
+ ]
400
+ },
401
+ {
402
+ "name": "stderr",
403
+ "output_type": "stream",
404
+ "text": [
405
+ "ERROR:inference:Unidentified image error for URL https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/e6469288-b487-4a06-99c1-59e7ac22fa77/width=1024/e6469288-b487-4a06-99c1-59e7ac22fa77.mp4: cannot identify image file <_io.BytesIO object at 0x14cb00ecbdd0>\n"
406
+ ]
407
+ },
408
+ {
409
+ "name": "stdout",
410
+ "output_type": "stream",
411
+ "text": [
412
+ "\n",
413
+ "0: 448x640 (no detections), 536.6ms\n",
414
+ "Speed: 10.1ms preprocess, 536.6ms inference, 0.4ms postprocess per image at shape (1, 3, 448, 640)\n",
415
+ "Processed and saved 2 images so far.\n",
416
+ "Processed and saved to: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/MiVOLO-results/2023-10.csv\n",
417
+ "Processing: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/Civiverse-mini-by-month/Civiverse-2023-11.csv\n",
418
+ "\n",
419
+ "0: 640x448 1 person, 1 face, 662.9ms\n",
420
+ "Speed: 2.6ms preprocess, 662.9ms inference, 0.9ms postprocess per image at shape (1, 3, 640, 448)\n"
421
+ ]
422
+ },
423
+ {
424
+ "name": "stderr",
425
+ "output_type": "stream",
426
+ "text": [
427
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
428
+ "INFO:MiVOLO:\tage: 17.0\n",
429
+ "INFO:MiVOLO:\tgender: female [99%]\n"
430
+ ]
431
+ },
432
+ {
433
+ "name": "stdout",
434
+ "output_type": "stream",
435
+ "text": [
436
+ "Processed and saved 1 images so far.\n",
437
+ "\n",
438
+ "0: 640x384 1 person, 895.9ms\n",
439
+ "Speed: 2.0ms preprocess, 895.9ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 384)\n"
440
+ ]
441
+ },
442
+ {
443
+ "name": "stderr",
444
+ "output_type": "stream",
445
+ "text": [
446
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
447
+ "INFO:MiVOLO:\tage: 43.33\n",
448
+ "INFO:MiVOLO:\tgender: male [99%]\n"
449
+ ]
450
+ },
451
+ {
452
+ "name": "stdout",
453
+ "output_type": "stream",
454
+ "text": [
455
+ "\n",
456
+ "0: 640x448 (no detections), 529.4ms\n",
457
+ "Speed: 2.6ms preprocess, 529.4ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 448)\n",
458
+ "\n",
459
+ "0: 640x448 1 person, 539.3ms\n",
460
+ "Speed: 2.8ms preprocess, 539.3ms inference, 0.8ms postprocess per image at shape (1, 3, 640, 448)\n"
461
+ ]
462
+ },
463
+ {
464
+ "name": "stderr",
465
+ "output_type": "stream",
466
+ "text": [
467
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
468
+ "INFO:MiVOLO:\tage: 39.15\n",
469
+ "INFO:MiVOLO:\tgender: male [99%]\n"
470
+ ]
471
+ },
472
+ {
473
+ "name": "stdout",
474
+ "output_type": "stream",
475
+ "text": [
476
+ "\n",
477
+ "0: 640x448 1 person, 1 face, 708.6ms\n",
478
+ "Speed: 2.5ms preprocess, 708.6ms inference, 0.8ms postprocess per image at shape (1, 3, 640, 448)\n"
479
+ ]
480
+ },
481
+ {
482
+ "name": "stderr",
483
+ "output_type": "stream",
484
+ "text": [
485
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
486
+ "INFO:MiVOLO:\tage: 29.64\n",
487
+ "INFO:MiVOLO:\tgender: female [99%]\n",
488
+ "ERROR:inference:Unidentified image error for URL https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/ad4b5481-0a58-4196-a3e8-fca2fe22a3cc/width=1080/ad4b5481-0a58-4196-a3e8-fca2fe22a3cc.mp4: cannot identify image file <_io.BytesIO object at 0x14cb010c24d0>\n"
489
+ ]
490
+ },
491
+ {
492
+ "name": "stdout",
493
+ "output_type": "stream",
494
+ "text": [
495
+ "Processed and saved to: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/MiVOLO-results/2023-11.csv\n",
496
+ "Processing: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/Civiverse-mini-by-month/Civiverse-2023-12.csv\n",
497
+ "\n",
498
+ "0: 640x384 1 person, 1 face, 461.0ms\n",
499
+ "Speed: 2.4ms preprocess, 461.0ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 384)\n"
500
+ ]
501
+ },
502
+ {
503
+ "name": "stderr",
504
+ "output_type": "stream",
505
+ "text": [
506
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
507
+ "INFO:MiVOLO:\tage: 19.61\n",
508
+ "INFO:MiVOLO:\tgender: female [99%]\n"
509
+ ]
510
+ },
511
+ {
512
+ "name": "stdout",
513
+ "output_type": "stream",
514
+ "text": [
515
+ "Processed and saved 1 images so far.\n",
516
+ "\n",
517
+ "0: 640x448 1 person, 1 face, 501.3ms\n",
518
+ "Speed: 3.1ms preprocess, 501.3ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 448)\n"
519
+ ]
520
+ },
521
+ {
522
+ "name": "stderr",
523
+ "output_type": "stream",
524
+ "text": [
525
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
526
+ "INFO:MiVOLO:\tage: 22.58\n",
527
+ "INFO:MiVOLO:\tgender: female [99%]\n",
528
+ "ERROR:inference:Unidentified image error for URL https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/3004b5fa-af81-4de7-829d-1d809d70b878/width=512/3004b5fa-af81-4de7-829d-1d809d70b878.mp4: cannot identify image file <_io.BytesIO object at 0x14cb0020ad40>\n"
529
+ ]
530
+ },
531
+ {
532
+ "name": "stdout",
533
+ "output_type": "stream",
534
+ "text": [
535
+ "\n",
536
+ "0: 640x640 (no detections), 842.5ms\n",
537
+ "Speed: 4.5ms preprocess, 842.5ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 640)\n",
538
+ "\n",
539
+ "0: 640x416 (no detections), 446.8ms\n",
540
+ "Speed: 2.5ms preprocess, 446.8ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 416)\n",
541
+ "Processed and saved 5 images so far.\n",
542
+ "Processed and saved to: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/MiVOLO-results/2023-12.csv\n",
543
+ "Processing: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/Civiverse-mini-by-month/Civiverse-2024-01.csv\n",
544
+ "\n",
545
+ "0: 640x448 (no detections), 638.5ms\n",
546
+ "Speed: 2.3ms preprocess, 638.5ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 448)\n",
547
+ "Processed and saved 1 images so far.\n",
548
+ "\n",
549
+ "0: 640x416 (no detections), 441.7ms\n",
550
+ "Speed: 2.5ms preprocess, 441.7ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 416)\n",
551
+ "\n",
552
+ "0: 640x448 (no detections), 470.3ms\n",
553
+ "Speed: 2.3ms preprocess, 470.3ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 448)\n",
554
+ "\n",
555
+ "0: 640x448 (no detections), 693.9ms\n",
556
+ "Speed: 2.5ms preprocess, 693.9ms inference, 0.5ms postprocess per image at shape (1, 3, 640, 448)\n",
557
+ "\n",
558
+ "0: 640x512 1 person, 1 face, 808.6ms\n",
559
+ "Speed: 3.2ms preprocess, 808.6ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 512)\n"
560
+ ]
561
+ },
562
+ {
563
+ "name": "stderr",
564
+ "output_type": "stream",
565
+ "text": [
566
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
567
+ "INFO:MiVOLO:\tage: 15.01\n",
568
+ "INFO:MiVOLO:\tgender: female [99%]\n"
569
+ ]
570
+ },
571
+ {
572
+ "name": "stdout",
573
+ "output_type": "stream",
574
+ "text": [
575
+ "\n",
576
+ "0: 640x320 1 person, 1 face, 345.6ms\n",
577
+ "Speed: 2.0ms preprocess, 345.6ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 320)\n"
578
+ ]
579
+ },
580
+ {
581
+ "name": "stderr",
582
+ "output_type": "stream",
583
+ "text": [
584
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
585
+ "INFO:MiVOLO:\tage: 20.86\n",
586
+ "INFO:MiVOLO:\tgender: female [99%]\n"
587
+ ]
588
+ },
589
+ {
590
+ "name": "stdout",
591
+ "output_type": "stream",
592
+ "text": [
593
+ "Processed and saved 6 images so far.\n",
594
+ "Processed and saved to: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/MiVOLO-results/2024-01.csv\n",
595
+ "Processing: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/Civiverse-mini-by-month/Civiverse-2024-02.csv\n",
596
+ "\n",
597
+ "0: 640x384 1 person, 1 face, 387.8ms\n",
598
+ "Speed: 1.9ms preprocess, 387.8ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 384)\n"
599
+ ]
600
+ },
601
+ {
602
+ "name": "stderr",
603
+ "output_type": "stream",
604
+ "text": [
605
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
606
+ "INFO:MiVOLO:\tage: 17.31\n",
607
+ "INFO:MiVOLO:\tgender: female [99%]\n"
608
+ ]
609
+ },
610
+ {
611
+ "name": "stdout",
612
+ "output_type": "stream",
613
+ "text": [
614
+ "Processed and saved 1 images so far.\n",
615
+ "\n",
616
+ "0: 640x480 1 person, 1 face, 540.4ms\n",
617
+ "Speed: 2.5ms preprocess, 540.4ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 480)\n"
618
+ ]
619
+ },
620
+ {
621
+ "name": "stderr",
622
+ "output_type": "stream",
623
+ "text": [
624
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
625
+ "INFO:MiVOLO:\tage: 17.47\n",
626
+ "INFO:MiVOLO:\tgender: female [99%]\n"
627
+ ]
628
+ },
629
+ {
630
+ "name": "stdout",
631
+ "output_type": "stream",
632
+ "text": [
633
+ "\n",
634
+ "0: 640x640 1 person, 1 face, 713.1ms\n",
635
+ "Speed: 3.8ms preprocess, 713.1ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 640)\n"
636
+ ]
637
+ },
638
+ {
639
+ "name": "stderr",
640
+ "output_type": "stream",
641
+ "text": [
642
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
643
+ "INFO:MiVOLO:\tage: 17.85\n",
644
+ "INFO:MiVOLO:\tgender: female [99%]\n"
645
+ ]
646
+ },
647
+ {
648
+ "name": "stdout",
649
+ "output_type": "stream",
650
+ "text": [
651
+ "\n",
652
+ "0: 640x640 (no detections), 778.8ms\n",
653
+ "Speed: 28.7ms preprocess, 778.8ms inference, 0.5ms postprocess per image at shape (1, 3, 640, 640)\n",
654
+ "\n",
655
+ "0: 640x448 1 person, 1 face, 528.2ms\n",
656
+ "Speed: 2.3ms preprocess, 528.2ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 448)\n"
657
+ ]
658
+ },
659
+ {
660
+ "name": "stderr",
661
+ "output_type": "stream",
662
+ "text": [
663
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
664
+ "INFO:MiVOLO:\tage: 21.63\n",
665
+ "INFO:MiVOLO:\tgender: female [99%]\n"
666
+ ]
667
+ },
668
+ {
669
+ "name": "stdout",
670
+ "output_type": "stream",
671
+ "text": [
672
+ "\n",
673
+ "0: 640x448 1 person, 1 face, 518.4ms\n",
674
+ "Speed: 3.9ms preprocess, 518.4ms inference, 0.9ms postprocess per image at shape (1, 3, 640, 448)\n"
675
+ ]
676
+ },
677
+ {
678
+ "name": "stderr",
679
+ "output_type": "stream",
680
+ "text": [
681
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
682
+ "INFO:MiVOLO:\tage: 18.25\n",
683
+ "INFO:MiVOLO:\tgender: female [99%]\n"
684
+ ]
685
+ },
686
+ {
687
+ "name": "stdout",
688
+ "output_type": "stream",
689
+ "text": [
690
+ "\n",
691
+ "0: 640x448 1 person, 1 face, 470.7ms\n",
692
+ "Speed: 2.5ms preprocess, 470.7ms inference, 0.8ms postprocess per image at shape (1, 3, 640, 448)\n"
693
+ ]
694
+ },
695
+ {
696
+ "name": "stderr",
697
+ "output_type": "stream",
698
+ "text": [
699
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
700
+ "INFO:MiVOLO:\tage: 20.51\n",
701
+ "INFO:MiVOLO:\tgender: female [99%]\n"
702
+ ]
703
+ },
704
+ {
705
+ "name": "stdout",
706
+ "output_type": "stream",
707
+ "text": [
708
+ "\n",
709
+ "0: 640x480 1 person, 1 face, 647.1ms\n",
710
+ "Speed: 2.4ms preprocess, 647.1ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 480)\n"
711
+ ]
712
+ },
713
+ {
714
+ "name": "stderr",
715
+ "output_type": "stream",
716
+ "text": [
717
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
718
+ "INFO:MiVOLO:\tage: 58.87\n",
719
+ "INFO:MiVOLO:\tgender: male [99%]\n"
720
+ ]
721
+ },
722
+ {
723
+ "name": "stdout",
724
+ "output_type": "stream",
725
+ "text": [
726
+ "\n",
727
+ "0: 640x448 (no detections), 469.8ms\n",
728
+ "Speed: 2.6ms preprocess, 469.8ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 448)\n",
729
+ "\n",
730
+ "0: 640x448 1 person, 1 face, 477.5ms\n",
731
+ "Speed: 2.3ms preprocess, 477.5ms inference, 0.8ms postprocess per image at shape (1, 3, 640, 448)\n"
732
+ ]
733
+ },
734
+ {
735
+ "name": "stderr",
736
+ "output_type": "stream",
737
+ "text": [
738
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
739
+ "INFO:MiVOLO:\tage: 23.79\n",
740
+ "INFO:MiVOLO:\tgender: female [99%]\n"
741
+ ]
742
+ },
743
+ {
744
+ "name": "stdout",
745
+ "output_type": "stream",
746
+ "text": [
747
+ "Processed and saved 10 images so far.\n",
748
+ "Processed and saved to: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/MiVOLO-results/2024-02.csv\n",
749
+ "Processing: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/Civiverse-mini-by-month/Civiverse-2024-03.csv\n",
750
+ "\n",
751
+ "0: 640x448 1 face, 511.4ms\n",
752
+ "Speed: 2.5ms preprocess, 511.4ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 448)\n"
753
+ ]
754
+ },
755
+ {
756
+ "name": "stderr",
757
+ "output_type": "stream",
758
+ "text": [
759
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
760
+ "INFO:MiVOLO:\tage: 24.87\n",
761
+ "INFO:MiVOLO:\tgender: female [99%]\n"
762
+ ]
763
+ },
764
+ {
765
+ "name": "stdout",
766
+ "output_type": "stream",
767
+ "text": [
768
+ "Processed and saved 1 images so far.\n",
769
+ "\n",
770
+ "0: 640x544 (no detections), 576.5ms\n",
771
+ "Speed: 2.9ms preprocess, 576.5ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 544)\n",
772
+ "\n",
773
+ "0: 640x448 1 person, 1 face, 687.1ms\n",
774
+ "Speed: 9.9ms preprocess, 687.1ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 448)\n"
775
+ ]
776
+ },
777
+ {
778
+ "name": "stderr",
779
+ "output_type": "stream",
780
+ "text": [
781
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
782
+ "INFO:MiVOLO:\tage: 25.76\n",
783
+ "INFO:MiVOLO:\tgender: female [99%]\n"
784
+ ]
785
+ },
786
+ {
787
+ "name": "stdout",
788
+ "output_type": "stream",
789
+ "text": [
790
+ "\n",
791
+ "0: 640x448 (no detections), 498.3ms\n",
792
+ "Speed: 2.3ms preprocess, 498.3ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 448)\n",
793
+ "\n",
794
+ "0: 640x512 (no detections), 573.2ms\n",
795
+ "Speed: 3.0ms preprocess, 573.2ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 512)\n",
796
+ "Processed and saved 5 images so far.\n",
797
+ "Processed and saved to: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/MiVOLO-results/2024-03.csv\n",
798
+ "Processing: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/Civiverse-mini-by-month/Civiverse-2024-04.csv\n",
799
+ "\n",
800
+ "0: 640x384 (no detections), 518.2ms\n",
801
+ "Speed: 2.7ms preprocess, 518.2ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 384)\n",
802
+ "Processed and saved 1 images so far.\n",
803
+ "\n",
804
+ "0: 640x512 (no detections), 707.7ms\n",
805
+ "Speed: 3.6ms preprocess, 707.7ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 512)\n",
806
+ "\n",
807
+ "0: 640x416 (no detections), 453.7ms\n",
808
+ "Speed: 2.4ms preprocess, 453.7ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 416)\n",
809
+ "\n",
810
+ "0: 640x384 (no detections), 391.0ms\n",
811
+ "Speed: 2.0ms preprocess, 391.0ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 384)\n",
812
+ "\n",
813
+ "0: 640x448 1 person, 1 face, 449.8ms\n",
814
+ "Speed: 2.3ms preprocess, 449.8ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 448)\n"
815
+ ]
816
+ },
817
+ {
818
+ "name": "stderr",
819
+ "output_type": "stream",
820
+ "text": [
821
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
822
+ "INFO:MiVOLO:\tage: 22.39\n",
823
+ "INFO:MiVOLO:\tgender: female [99%]\n"
824
+ ]
825
+ },
826
+ {
827
+ "name": "stdout",
828
+ "output_type": "stream",
829
+ "text": [
830
+ "\n",
831
+ "0: 640x448 (no detections), 618.4ms\n",
832
+ "Speed: 2.3ms preprocess, 618.4ms inference, 0.5ms postprocess per image at shape (1, 3, 640, 448)\n",
833
+ "\n",
834
+ "0: 640x448 1 person, 1 face, 631.0ms\n",
835
+ "Speed: 2.2ms preprocess, 631.0ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 448)\n"
836
+ ]
837
+ },
838
+ {
839
+ "name": "stderr",
840
+ "output_type": "stream",
841
+ "text": [
842
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
843
+ "INFO:MiVOLO:\tage: 24.05\n",
844
+ "INFO:MiVOLO:\tgender: female [99%]\n"
845
+ ]
846
+ },
847
+ {
848
+ "name": "stdout",
849
+ "output_type": "stream",
850
+ "text": [
851
+ "\n",
852
+ "0: 640x512 1 person, 496.4ms\n",
853
+ "Speed: 2.6ms preprocess, 496.4ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 512)\n"
854
+ ]
855
+ },
856
+ {
857
+ "name": "stderr",
858
+ "output_type": "stream",
859
+ "text": [
860
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
861
+ "INFO:MiVOLO:\tage: 22.81\n",
862
+ "INFO:MiVOLO:\tgender: male [99%]\n"
863
+ ]
864
+ },
865
+ {
866
+ "name": "stdout",
867
+ "output_type": "stream",
868
+ "text": [
869
+ "\n",
870
+ "0: 640x448 (no detections), 442.8ms\n",
871
+ "Speed: 2.3ms preprocess, 442.8ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 448)\n",
872
+ "\n",
873
+ "0: 640x448 1 person, 1 face, 477.7ms\n",
874
+ "Speed: 2.4ms preprocess, 477.7ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 448)\n"
875
+ ]
876
+ },
877
+ {
878
+ "name": "stderr",
879
+ "output_type": "stream",
880
+ "text": [
881
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
882
+ "INFO:MiVOLO:\tage: 21.62\n",
883
+ "INFO:MiVOLO:\tgender: female [99%]\n"
884
+ ]
885
+ },
886
+ {
887
+ "name": "stdout",
888
+ "output_type": "stream",
889
+ "text": [
890
+ "\n",
891
+ "0: 640x448 1 person, 1 face, 447.0ms\n",
892
+ "Speed: 2.2ms preprocess, 447.0ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 448)\n"
893
+ ]
894
+ },
895
+ {
896
+ "name": "stderr",
897
+ "output_type": "stream",
898
+ "text": [
899
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
900
+ "INFO:MiVOLO:\tage: 54.31\n",
901
+ "INFO:MiVOLO:\tgender: male [99%]\n"
902
+ ]
903
+ },
904
+ {
905
+ "name": "stdout",
906
+ "output_type": "stream",
907
+ "text": [
908
+ "\n",
909
+ "0: 640x640 (no detections), 819.0ms\n",
910
+ "Speed: 3.6ms preprocess, 819.0ms inference, 0.5ms postprocess per image at shape (1, 3, 640, 640)\n",
911
+ "\n",
912
+ "0: 640x448 1 person, 1 face, 478.2ms\n",
913
+ "Speed: 1.8ms preprocess, 478.2ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 448)\n"
914
+ ]
915
+ },
916
+ {
917
+ "name": "stderr",
918
+ "output_type": "stream",
919
+ "text": [
920
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
921
+ "INFO:MiVOLO:\tage: 20.56\n",
922
+ "INFO:MiVOLO:\tgender: female [99%]\n"
923
+ ]
924
+ },
925
+ {
926
+ "name": "stdout",
927
+ "output_type": "stream",
928
+ "text": [
929
+ "\n",
930
+ "0: 640x448 1 person, 1 face, 471.2ms\n",
931
+ "Speed: 2.7ms preprocess, 471.2ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 448)\n"
932
+ ]
933
+ },
934
+ {
935
+ "name": "stderr",
936
+ "output_type": "stream",
937
+ "text": [
938
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
939
+ "INFO:MiVOLO:\tage: 21.31\n",
940
+ "INFO:MiVOLO:\tgender: female [99%]\n"
941
+ ]
942
+ },
943
+ {
944
+ "name": "stdout",
945
+ "output_type": "stream",
946
+ "text": [
947
+ "\n",
948
+ "0: 640x448 (no detections), 484.0ms\n",
949
+ "Speed: 2.2ms preprocess, 484.0ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 448)\n",
950
+ "\n",
951
+ "0: 640x640 (no detections), 832.6ms\n",
952
+ "Speed: 3.0ms preprocess, 832.6ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 640)\n",
953
+ "\n",
954
+ "0: 640x448 1 person, 1 face, 508.9ms\n",
955
+ "Speed: 2.5ms preprocess, 508.9ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 448)\n"
956
+ ]
957
+ },
958
+ {
959
+ "name": "stderr",
960
+ "output_type": "stream",
961
+ "text": [
962
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
963
+ "INFO:MiVOLO:\tage: 27.19\n",
964
+ "INFO:MiVOLO:\tgender: female [99%]\n",
965
+ "ERROR:inference:Unidentified image error for URL https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/6879c7b9-5cb3-42db-b409-30b4e2f71945/width=1080/6879c7b9-5cb3-42db-b409-30b4e2f71945.mp4: cannot identify image file <_io.BytesIO object at 0x14cb0020ad40>\n"
966
+ ]
967
+ },
968
+ {
969
+ "name": "stdout",
970
+ "output_type": "stream",
971
+ "text": [
972
+ "\n",
973
+ "0: 640x448 9 persons, 461.8ms\n",
974
+ "Speed: 2.4ms preprocess, 461.8ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 448)\n"
975
+ ]
976
+ },
977
+ {
978
+ "name": "stderr",
979
+ "output_type": "stream",
980
+ "text": [
981
+ "INFO:MiVOLO:faces_input: torch.Size([9, 3, 224, 224]), person_input: torch.Size([9, 3, 224, 224])\n",
982
+ "INFO:MiVOLO:\tage: 30.4\n",
983
+ "INFO:MiVOLO:\tgender: male [55%]\n",
984
+ "INFO:MiVOLO:\tage: 28.89\n",
985
+ "INFO:MiVOLO:\tgender: female [63%]\n",
986
+ "INFO:MiVOLO:\tage: 30.31\n",
987
+ "INFO:MiVOLO:\tgender: female [68%]\n",
988
+ "INFO:MiVOLO:\tage: 31.62\n",
989
+ "INFO:MiVOLO:\tgender: female [53%]\n",
990
+ "INFO:MiVOLO:\tage: 35.17\n",
991
+ "INFO:MiVOLO:\tgender: male [53%]\n",
992
+ "INFO:MiVOLO:\tage: 33.02\n",
993
+ "INFO:MiVOLO:\tgender: male [95%]\n",
994
+ "INFO:MiVOLO:\tage: 35.17\n",
995
+ "INFO:MiVOLO:\tgender: male [53%]\n",
996
+ "INFO:MiVOLO:\tage: 35.17\n",
997
+ "INFO:MiVOLO:\tgender: male [53%]\n",
998
+ "INFO:MiVOLO:\tage: 35.17\n",
999
+ "INFO:MiVOLO:\tgender: male [53%]\n"
1000
+ ]
1001
+ },
1002
+ {
1003
+ "name": "stdout",
1004
+ "output_type": "stream",
1005
+ "text": [
1006
+ "Processed and saved 19 images so far.\n",
1007
+ "Processed and saved to: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/MiVOLO-results/2024-04.csv\n",
1008
+ "Processing: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/Civiverse-mini-by-month/Civiverse-2024-05.csv\n",
1009
+ "\n",
1010
+ "0: 640x448 1 person, 455.5ms\n",
1011
+ "Speed: 2.2ms preprocess, 455.5ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 448)\n"
1012
+ ]
1013
+ },
1014
+ {
1015
+ "name": "stderr",
1016
+ "output_type": "stream",
1017
+ "text": [
1018
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
1019
+ "INFO:MiVOLO:\tage: 37.57\n",
1020
+ "INFO:MiVOLO:\tgender: male [95%]\n"
1021
+ ]
1022
+ },
1023
+ {
1024
+ "name": "stdout",
1025
+ "output_type": "stream",
1026
+ "text": [
1027
+ "Processed and saved 1 images so far.\n",
1028
+ "\n",
1029
+ "0: 640x448 1 person, 1 face, 438.7ms\n",
1030
+ "Speed: 2.2ms preprocess, 438.7ms inference, 0.8ms postprocess per image at shape (1, 3, 640, 448)\n"
1031
+ ]
1032
+ },
1033
+ {
1034
+ "name": "stderr",
1035
+ "output_type": "stream",
1036
+ "text": [
1037
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
1038
+ "INFO:MiVOLO:\tage: 15.62\n",
1039
+ "INFO:MiVOLO:\tgender: female [99%]\n"
1040
+ ]
1041
+ },
1042
+ {
1043
+ "name": "stdout",
1044
+ "output_type": "stream",
1045
+ "text": [
1046
+ "\n",
1047
+ "0: 640x448 (no detections), 444.8ms\n",
1048
+ "Speed: 2.3ms preprocess, 444.8ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 448)\n"
1049
+ ]
1050
+ },
1051
+ {
1052
+ "name": "stderr",
1053
+ "output_type": "stream",
1054
+ "text": [
1055
+ "ERROR:inference:Unidentified image error for URL https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/6032bd70-6d53-4007-9e89-e69d4748efb5/width=528/6032bd70-6d53-4007-9e89-e69d4748efb5.mp4: cannot identify image file <_io.BytesIO object at 0x14cb00ed0950>\n"
1056
+ ]
1057
+ },
1058
+ {
1059
+ "name": "stdout",
1060
+ "output_type": "stream",
1061
+ "text": [
1062
+ "\n",
1063
+ "0: 640x448 (no detections), 453.9ms\n",
1064
+ "Speed: 2.3ms preprocess, 453.9ms inference, 0.5ms postprocess per image at shape (1, 3, 640, 448)\n",
1065
+ "\n",
1066
+ "0: 640x448 1 person, 1 face, 475.0ms\n",
1067
+ "Speed: 1.6ms preprocess, 475.0ms inference, 0.8ms postprocess per image at shape (1, 3, 640, 448)\n"
1068
+ ]
1069
+ },
1070
+ {
1071
+ "name": "stderr",
1072
+ "output_type": "stream",
1073
+ "text": [
1074
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
1075
+ "INFO:MiVOLO:\tage: 22.5\n",
1076
+ "INFO:MiVOLO:\tgender: female [99%]\n"
1077
+ ]
1078
+ },
1079
+ {
1080
+ "name": "stdout",
1081
+ "output_type": "stream",
1082
+ "text": [
1083
+ "\n",
1084
+ "0: 640x448 1 person, 1 face, 447.6ms\n",
1085
+ "Speed: 2.5ms preprocess, 447.6ms inference, 0.8ms postprocess per image at shape (1, 3, 640, 448)\n"
1086
+ ]
1087
+ },
1088
+ {
1089
+ "name": "stderr",
1090
+ "output_type": "stream",
1091
+ "text": [
1092
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
1093
+ "INFO:MiVOLO:\tage: 23.46\n",
1094
+ "INFO:MiVOLO:\tgender: female [99%]\n"
1095
+ ]
1096
+ },
1097
+ {
1098
+ "name": "stdout",
1099
+ "output_type": "stream",
1100
+ "text": [
1101
+ "\n",
1102
+ "0: 640x512 (no detections), 528.5ms\n",
1103
+ "Speed: 3.2ms preprocess, 528.5ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 512)\n",
1104
+ "\n",
1105
+ "0: 640x448 1 person, 1 face, 449.8ms\n",
1106
+ "Speed: 2.3ms preprocess, 449.8ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 448)\n"
1107
+ ]
1108
+ },
1109
+ {
1110
+ "name": "stderr",
1111
+ "output_type": "stream",
1112
+ "text": [
1113
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
1114
+ "INFO:MiVOLO:\tage: 29.32\n",
1115
+ "INFO:MiVOLO:\tgender: female [99%]\n"
1116
+ ]
1117
+ },
1118
+ {
1119
+ "name": "stdout",
1120
+ "output_type": "stream",
1121
+ "text": [
1122
+ "\n",
1123
+ "0: 640x448 1 person, 1 face, 617.7ms\n",
1124
+ "Speed: 2.4ms preprocess, 617.7ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 448)\n"
1125
+ ]
1126
+ },
1127
+ {
1128
+ "name": "stderr",
1129
+ "output_type": "stream",
1130
+ "text": [
1131
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
1132
+ "INFO:MiVOLO:\tage: 21.32\n",
1133
+ "INFO:MiVOLO:\tgender: female [99%]\n"
1134
+ ]
1135
+ },
1136
+ {
1137
+ "name": "stdout",
1138
+ "output_type": "stream",
1139
+ "text": [
1140
+ "\n",
1141
+ "0: 640x448 (no detections), 609.1ms\n",
1142
+ "Speed: 2.3ms preprocess, 609.1ms inference, 0.5ms postprocess per image at shape (1, 3, 640, 448)\n",
1143
+ "\n",
1144
+ "0: 640x448 (no detections), 436.2ms\n",
1145
+ "Speed: 2.5ms preprocess, 436.2ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 448)\n",
1146
+ "\n",
1147
+ "0: 640x512 1 person, 1 face, 585.6ms\n",
1148
+ "Speed: 3.1ms preprocess, 585.6ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 512)\n"
1149
+ ]
1150
+ },
1151
+ {
1152
+ "name": "stderr",
1153
+ "output_type": "stream",
1154
+ "text": [
1155
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
1156
+ "INFO:MiVOLO:\tage: 20.5\n",
1157
+ "INFO:MiVOLO:\tgender: female [99%]\n"
1158
+ ]
1159
+ },
1160
+ {
1161
+ "name": "stdout",
1162
+ "output_type": "stream",
1163
+ "text": [
1164
+ "\n",
1165
+ "0: 640x448 1 person, 457.3ms\n",
1166
+ "Speed: 2.1ms preprocess, 457.3ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 448)\n"
1167
+ ]
1168
+ },
1169
+ {
1170
+ "name": "stderr",
1171
+ "output_type": "stream",
1172
+ "text": [
1173
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
1174
+ "INFO:MiVOLO:\tage: 25.19\n",
1175
+ "INFO:MiVOLO:\tgender: male [81%]\n"
1176
+ ]
1177
+ },
1178
+ {
1179
+ "name": "stdout",
1180
+ "output_type": "stream",
1181
+ "text": [
1182
+ "Processed and saved 14 images so far.\n",
1183
+ "Processed and saved to: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/MiVOLO-results/2024-05.csv\n",
1184
+ "Processing: /shares/weddigen.ki.uzh/laura_wagner/Civitai_page_analysis/Civitai_visualizations/data/CSV/image_subsets/Civiverse-mini-by-month/Civiverse-2024-06.csv\n",
1185
+ "\n",
1186
+ "0: 640x448 (no detections), 484.5ms\n",
1187
+ "Speed: 2.8ms preprocess, 484.5ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 448)\n",
1188
+ "Processed and saved 1 images so far.\n",
1189
+ "\n",
1190
+ "0: 640x512 (no detections), 524.8ms\n",
1191
+ "Speed: 2.9ms preprocess, 524.8ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 512)\n",
1192
+ "\n",
1193
+ "0: 640x480 1 person, 478.0ms\n",
1194
+ "Speed: 2.6ms preprocess, 478.0ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 480)\n"
1195
+ ]
1196
+ },
1197
+ {
1198
+ "name": "stderr",
1199
+ "output_type": "stream",
1200
+ "text": [
1201
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
1202
+ "INFO:MiVOLO:\tage: 39.4\n",
1203
+ "INFO:MiVOLO:\tgender: male [99%]\n"
1204
+ ]
1205
+ },
1206
+ {
1207
+ "name": "stdout",
1208
+ "output_type": "stream",
1209
+ "text": [
1210
+ "\n",
1211
+ "0: 640x512 1 person, 1 face, 539.8ms\n",
1212
+ "Speed: 2.6ms preprocess, 539.8ms inference, 0.8ms postprocess per image at shape (1, 3, 640, 512)\n"
1213
+ ]
1214
+ },
1215
+ {
1216
+ "name": "stderr",
1217
+ "output_type": "stream",
1218
+ "text": [
1219
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
1220
+ "INFO:MiVOLO:\tage: 21.33\n",
1221
+ "INFO:MiVOLO:\tgender: female [99%]\n"
1222
+ ]
1223
+ },
1224
+ {
1225
+ "name": "stdout",
1226
+ "output_type": "stream",
1227
+ "text": [
1228
+ "\n",
1229
+ "0: 640x448 1 person, 2 faces, 446.7ms\n",
1230
+ "Speed: 2.4ms preprocess, 446.7ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 448)\n"
1231
+ ]
1232
+ },
1233
+ {
1234
+ "name": "stderr",
1235
+ "output_type": "stream",
1236
+ "text": [
1237
+ "INFO:MiVOLO:faces_input: torch.Size([2, 3, 224, 224]), person_input: torch.Size([2, 3, 224, 224])\n",
1238
+ "INFO:MiVOLO:\tage: 20.65\n",
1239
+ "INFO:MiVOLO:\tgender: female [99%]\n",
1240
+ "INFO:MiVOLO:\tage: 20.53\n",
1241
+ "INFO:MiVOLO:\tgender: female [99%]\n"
1242
+ ]
1243
+ },
1244
+ {
1245
+ "name": "stdout",
1246
+ "output_type": "stream",
1247
+ "text": [
1248
+ "\n",
1249
+ "0: 640x640 1 person, 1 face, 655.0ms\n",
1250
+ "Speed: 3.3ms preprocess, 655.0ms inference, 0.8ms postprocess per image at shape (1, 3, 640, 640)\n"
1251
+ ]
1252
+ },
1253
+ {
1254
+ "name": "stderr",
1255
+ "output_type": "stream",
1256
+ "text": [
1257
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
1258
+ "INFO:MiVOLO:\tage: 26.34\n",
1259
+ "INFO:MiVOLO:\tgender: female [99%]\n"
1260
+ ]
1261
+ },
1262
+ {
1263
+ "name": "stdout",
1264
+ "output_type": "stream",
1265
+ "text": [
1266
+ "\n",
1267
+ "0: 640x384 (no detections), 400.6ms\n",
1268
+ "Speed: 2.1ms preprocess, 400.6ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 384)\n",
1269
+ "\n",
1270
+ "0: 640x448 1 person, 587.9ms\n",
1271
+ "Speed: 2.2ms preprocess, 587.9ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 448)\n"
1272
+ ]
1273
+ },
1274
+ {
1275
+ "name": "stderr",
1276
+ "output_type": "stream",
1277
+ "text": [
1278
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
1279
+ "INFO:MiVOLO:\tage: 30.4\n",
1280
+ "INFO:MiVOLO:\tgender: female [99%]\n"
1281
+ ]
1282
+ },
1283
+ {
1284
+ "name": "stdout",
1285
+ "output_type": "stream",
1286
+ "text": [
1287
+ "\n",
1288
+ "0: 640x448 (no detections), 610.3ms\n",
1289
+ "Speed: 2.3ms preprocess, 610.3ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 448)\n",
1290
+ "\n",
1291
+ "0: 640x448 (no detections), 453.6ms\n",
1292
+ "Speed: 2.3ms preprocess, 453.6ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 448)\n",
1293
+ "\n",
1294
+ "0: 640x512 1 person, 1 face, 511.3ms\n",
1295
+ "Speed: 2.8ms preprocess, 511.3ms inference, 0.7ms postprocess per image at shape (1, 3, 640, 512)\n"
1296
+ ]
1297
+ },
1298
+ {
1299
+ "name": "stderr",
1300
+ "output_type": "stream",
1301
+ "text": [
1302
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
1303
+ "INFO:MiVOLO:\tage: 34.28\n",
1304
+ "INFO:MiVOLO:\tgender: female [99%]\n"
1305
+ ]
1306
+ },
1307
+ {
1308
+ "name": "stdout",
1309
+ "output_type": "stream",
1310
+ "text": [
1311
+ "\n",
1312
+ "0: 640x448 (no detections), 441.2ms\n",
1313
+ "Speed: 2.3ms preprocess, 441.2ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 448)\n",
1314
+ "\n",
1315
+ "0: 640x448 (no detections), 586.3ms\n",
1316
+ "Speed: 2.3ms preprocess, 586.3ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 448)\n",
1317
+ "\n",
1318
+ "0: 640x448 (no detections), 437.5ms\n",
1319
+ "Speed: 2.4ms preprocess, 437.5ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 448)\n",
1320
+ "\n",
1321
+ "0: 448x640 1 person, 1 face, 437.4ms\n",
1322
+ "Speed: 2.4ms preprocess, 437.4ms inference, 0.7ms postprocess per image at shape (1, 3, 448, 640)\n"
1323
+ ]
1324
+ },
1325
+ {
1326
+ "name": "stderr",
1327
+ "output_type": "stream",
1328
+ "text": [
1329
+ "INFO:MiVOLO:faces_input: torch.Size([1, 3, 224, 224]), person_input: torch.Size([1, 3, 224, 224])\n",
1330
+ "INFO:MiVOLO:\tage: 22.81\n",
1331
+ "INFO:MiVOLO:\tgender: female [99%]\n"
1332
+ ]
1333
+ },
1334
+ {
1335
+ "name": "stdout",
1336
+ "output_type": "stream",
1337
+ "text": [
1338
+ "\n",
1339
+ "0: 640x448 (no detections), 436.8ms\n",
1340
+ "Speed: 2.6ms preprocess, 436.8ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 448)\n",
1341
+ "\n",
1342
+ "0: 448x640 (no detections), 433.0ms\n",
1343
+ "Speed: 1.9ms preprocess, 433.0ms inference, 0.4ms postprocess per image at shape (1, 3, 448, 640)\n",
1344
+ "\n",
1345
+ "0: 640x448 (no detections), 599.7ms\n",
1346
+ "Speed: 2.5ms preprocess, 599.7ms inference, 0.4ms postprocess per image at shape (1, 3, 640, 448)\n",
1347
+ "\n"
1348
+ ]
1349
+ }
1350
+ ],
1351
+ "source": [
1352
+ "# Set up logging\n",
1353
+ "detector_weights = current_dir.parent / 'ext/MiVOLO/models/yolov8x_person_face.pt'\n",
1354
+ "checkpoint = current_dir.parent / 'ext/MiVOLO/models/mivolo_imbd.pth.tar'\n",
1355
+ "\n",
1356
+ "_logger = logging.getLogger(\"inference\")\n",
1357
+ "logging.basicConfig(level=logging.INFO)\n",
1358
+ "\n",
1359
+ "# Placeholder configuration and predictor initialization for MiVOLO\n",
1360
+ "class Config:\n",
1361
+ " def __init__(self, detector_weights, checkpoint, device, with_persons=True, disable_faces=False, draw=False):\n",
1362
+ " self.detector_weights = detector_weights\n",
1363
+ " self.checkpoint = checkpoint\n",
1364
+ " self.device = device\n",
1365
+ " self.with_persons = with_persons\n",
1366
+ " self.disable_faces = disable_faces\n",
1367
+ " self.draw = draw\n",
1368
+ "\n",
1369
+ "\n",
1370
+ "device = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n",
1371
+ "config = Config(detector_weights=detector_weights, checkpoint=checkpoint, device=device)\n",
1372
+ "predictor = Predictor(config, verbose=True)\n",
1373
+ "\n",
1374
+ "def download_image(url):\n",
1375
+ " try:\n",
1376
+ " response = requests.get(url)\n",
1377
+ " response.raise_for_status()\n",
1378
+ " return Image.open(BytesIO(response.content)).convert(\"RGB\")\n",
1379
+ " except requests.RequestException as e:\n",
1380
+ " _logger.error(f\"Failed to download image from {url}: {e}\")\n",
1381
+ " return None\n",
1382
+ " except UnidentifiedImageError as e:\n",
1383
+ " _logger.error(f\"Unidentified image error for URL {url}: {e}\")\n",
1384
+ " return None\n",
1385
+ "\n",
1386
+ "def process_images_with_progress(data, predictor, output_file, start_idx=0):\n",
1387
+ " results = []\n",
1388
+ " total_images = len(data)\n",
1389
+ "\n",
1390
+ " for idx, row in data.iterrows():\n",
1391
+ " if idx < start_idx:\n",
1392
+ " continue\n",
1393
+ "\n",
1394
+ " img_url = row[\"url\"]\n",
1395
+ " pil_image = download_image(img_url)\n",
1396
+ " if pil_image is None:\n",
1397
+ " continue\n",
1398
+ "\n",
1399
+ " np_image = np.array(pil_image)\n",
1400
+ " np_image = cv2.cvtColor(np_image, cv2.COLOR_RGB2BGR)\n",
1401
+ " detected_objects, _ = predictor.recognize(np_image)\n",
1402
+ "\n",
1403
+ " row_result = row.to_dict() # Start with the original row's data\n",
1404
+ "\n",
1405
+ " if detected_objects and detected_objects.ages:\n",
1406
+ " for i in range(len(detected_objects.ages)):\n",
1407
+ " age = detected_objects.ages[i]\n",
1408
+ " gender = detected_objects.genders[i]\n",
1409
+ " gender_confidence = detected_objects.gender_scores[i]\n",
1410
+ "\n",
1411
+ " if gender_confidence >= 0.83:\n",
1412
+ " detection = {\n",
1413
+ " \"detection_type\": 'face' if i in detected_objects.face_to_person_map else 'person',\n",
1414
+ " \"gender\": gender,\n",
1415
+ " \"gender_confidence\": gender_confidence,\n",
1416
+ " \"age\": age,\n",
1417
+ " \"n_persons\": detected_objects.n_persons,\n",
1418
+ " \"n_faces\": detected_objects.n_faces,\n",
1419
+ " \"detected\": True\n",
1420
+ " }\n",
1421
+ " else:\n",
1422
+ " detection = {\n",
1423
+ " \"detection_type\": \"N/A\",\n",
1424
+ " \"gender\": \"N/A\",\n",
1425
+ " \"gender_confidence\": 0,\n",
1426
+ " \"age\": 0,\n",
1427
+ " \"n_persons\": detected_objects.n_persons if detected_objects else 0,\n",
1428
+ " \"n_faces\": detected_objects.n_faces if detected_objects else 0,\n",
1429
+ " \"detected\": False\n",
1430
+ " }\n",
1431
+ "\n",
1432
+ " results.append({**row_result, **detection})\n",
1433
+ " else:\n",
1434
+ " detection = {\n",
1435
+ " \"detection_type\": \"N/A\",\n",
1436
+ " \"gender\": \"N/A\",\n",
1437
+ " \"gender_confidence\": 0,\n",
1438
+ " \"age\": 0,\n",
1439
+ " \"n_persons\": detected_objects.n_persons if detected_objects else 0,\n",
1440
+ " \"n_faces\": detected_objects.n_faces if detected_objects else 0,\n",
1441
+ " \"detected\": False\n",
1442
+ " }\n",
1443
+ " results.append({**row_result, **detection})\n",
1444
+ "\n",
1445
+ " if idx % 100 == 0 or idx == total_images - 1:\n",
1446
+ " df = pd.DataFrame(results)\n",
1447
+ " if os.path.exists(output_file):\n",
1448
+ " df.to_csv(output_file, mode='a', header=False, index=False)\n",
1449
+ " else:\n",
1450
+ " df.to_csv(output_file, mode='w', header=True, index=False)\n",
1451
+ " results = []\n",
1452
+ " print(f\"Processed and saved {idx + 1} images so far.\")\n",
1453
+ "\n",
1454
+ "def generate_months(start, end):\n",
1455
+ " start_date = datetime.strptime(start, '%Y-%m')\n",
1456
+ " end_date = datetime.strptime(end, '%Y-%m')\n",
1457
+ " while start_date <= end_date:\n",
1458
+ " yield start_date.strftime('%Y-%m')\n",
1459
+ " start_date += relativedelta(months=1) # Increment by calendar months\n",
1460
+ "\n",
1461
+ "\n",
1462
+ "start_month = '2022-11'\n",
1463
+ "end_month = '2024-12'\n",
1464
+ "\n",
1465
+ "for month in generate_months(start_month, end_month):\n",
1466
+ " input_file_path = mivolo_in / f'Civiverse-{month}.csv'\n",
1467
+ " output_file_path = mivolo_out / f'{month}.csv'\n",
1468
+ "\n",
1469
+ " if input_file_path.exists():\n",
1470
+ " print(f\"Processing: {input_file_path}\")\n",
1471
+ "\n",
1472
+ " data = pd.read_csv(input_file_path)\n",
1473
+ " start_index = 0\n",
1474
+ " process_images_with_progress(data, predictor, output_file_path, start_idx=start_index)\n",
1475
+ "\n",
1476
+ " print(f\"Processed and saved to: {output_file_path}\")\n",
1477
+ " else:\n",
1478
+ " print(f\"File not found: {input_file_path}\")"
1479
+ ]
1480
+ },
1481
+ {
1482
+ "cell_type": "markdown",
1483
+ "id": "26aeeef7",
1484
+ "metadata": {},
1485
+ "source": [
1486
+ "## Visualization code"
1487
+ ]
1488
+ },
1489
+ {
1490
+ "cell_type": "code",
1491
+ "execution_count": null,
1492
+ "id": "88ec896a-bf9b-4cc6-a787-c1343f8acb41",
1493
+ "metadata": {},
1494
+ "outputs": [],
1495
+ "source": [
1496
+ "import matplotlib.pyplot as plt\n",
1497
+ "import matplotlib.patches as mpatches\n",
1498
+ "\n",
1499
+ "input_dir = current_dir.parent / 'data/CSV/image_subsets/MiVOLO-results/'\n",
1500
+ "plot_dir = current_dir.parent / 'plots/'\n",
1501
+ "\n",
1502
+ "\n",
1503
+ "all_data = pd.DataFrame()\n",
1504
+ "for file_path in input_dir.glob('*.csv'): # Reads all CSV files in the folder\n",
1505
+ " #print(f\"Loading: {file_path}\")\n",
1506
+ " data = pd.read_csv(file_path)\n",
1507
+ " all_data = pd.concat([all_data, data], ignore_index=True)\n",
1508
+ "\n",
1509
+ "# Filter rows where detection_type equals \"person\"\n",
1510
+ "person_data = all_data[all_data['detection_type'] == 'person']\n",
1511
+ "\n",
1512
+ "# Count unique images and categorize by persons detected\n",
1513
+ "n_images = all_data['id'].nunique()\n",
1514
+ "images_with_zero_persons = all_data[all_data['n_persons'] == 0]['id'].nunique()\n",
1515
+ "images_with_one_or_more_persons = all_data[all_data['n_persons'] > 0]['id'].nunique()\n",
1516
+ "\n",
1517
+ "n_persons_detected = person_data['id'].nunique() # Unique images with at least one detected person\n",
1518
+ "total_persons_detected = person_data.shape[0] # Total number of persons detected\n",
1519
+ "\n",
1520
+ "\n",
1521
+ "\n",
1522
+ "n_total_female = person_data[person_data['gender'] == 'female']['id'].nunique()\n",
1523
+ "n_total_male = person_data[person_data['gender'] == 'male']['id'].nunique()\n",
1524
+ "\n",
1525
+ "# Filter the data further for non-missing age and gender\n",
1526
+ "filtered_data = person_data.dropna(subset=['age', 'gender'])\n",
1527
+ "\n",
1528
+ "# Round ages for consistent plotting\n",
1529
+ "filtered_data['rounded_age'] = np.round(filtered_data['age'] * 4) / 4\n",
1530
+ "\n",
1531
+ "# Map browsingLevel to colors\n",
1532
+ "def get_browsing_color(browsing_level):\n",
1533
+ " color_mapping = {\n",
1534
+ " 1: 'silver',\n",
1535
+ " 2: 'rosybrown',\n",
1536
+ " 4: 'coral',\n",
1537
+ " 8: 'crimson',\n",
1538
+ " 16: 'blueviolet'\n",
1539
+ " }\n",
1540
+ " return color_mapping.get(browsing_level, 'black') # Default to black for unknown values\n",
1541
+ "\n",
1542
+ "filtered_data['color'] = filtered_data['browsingLevel'].apply(get_browsing_color)\n",
1543
+ "\n",
1544
+ "# Aggregate data for plotting\n",
1545
+ "aggregated_data = (\n",
1546
+ " filtered_data.groupby(['rounded_age', 'gender', 'color'])\n",
1547
+ " .size()\n",
1548
+ " .unstack(fill_value=0)\n",
1549
+ ")\n",
1550
+ "\n",
1551
+ "# Define NSFW colors\n",
1552
+ "nsfw_colors = ['blueviolet', 'crimson', 'coral', 'rosybrown', 'silver']\n",
1553
+ "\n",
1554
+ "# Plotting function\n",
1555
+ "def plot_gender_data(ax, data, gender_label):\n",
1556
+ " ages = data.index\n",
1557
+ " bottom = np.zeros(len(ages))\n",
1558
+ " \n",
1559
+ " for color in nsfw_colors:\n",
1560
+ " counts = data[color] if color in data.columns else np.zeros(len(ages))\n",
1561
+ " ax.bar(\n",
1562
+ " ages,\n",
1563
+ " counts,\n",
1564
+ " color=color,\n",
1565
+ " edgecolor=color,\n",
1566
+ " linewidth=1,\n",
1567
+ " width=0.2,\n",
1568
+ " bottom=bottom,\n",
1569
+ " alpha=0.5\n",
1570
+ " )\n",
1571
+ " bottom += counts\n",
1572
+ "\n",
1573
+ " x_min = 5\n",
1574
+ " x_max = filtered_data['rounded_age'].max()\n",
1575
+ " ax.set_xticks(np.arange(x_min, x_max + 0.5, 5))\n",
1576
+ " ax.set_xticklabels([f'{int(age)}' for age in np.arange(x_min, x_max + 0.5, 5)], fontsize=12, fontweight='bold')\n",
1577
+ " ax.set_xticks(np.arange(x_min, x_max + 0.5, 0.5), minor=True)\n",
1578
+ "\n",
1579
+ " y_min = 0\n",
1580
+ " y_max = bottom.max() + 100\n",
1581
+ " y_ticks = np.arange(y_min, y_max + 1, 100) # Fine-grained steps of 100\n",
1582
+ " ax.set_yticks(y_ticks)\n",
1583
+ " ax.set_yticklabels([str(int(y)) for y in y_ticks], fontsize=12, fontweight='bold')\n",
1584
+ "\n",
1585
+ " ax.grid(True, which='major', color='lightgrey', linestyle='-', linewidth=0.5)\n",
1586
+ " ax.grid(True, which='minor', color='lightgrey', linestyle=':', linewidth=0.5)\n",
1587
+ "\n",
1588
+ " ax.spines['top'].set_visible(False)\n",
1589
+ " ax.spines['right'].set_visible(False)\n",
1590
+ " ax.spines['left'].set_visible(False)\n",
1591
+ " ax.spines['bottom'].set_visible(False)\n",
1592
+ " \n",
1593
+ " ax.set_xlabel('Age', fontsize=12, fontweight='bold')\n",
1594
+ " if gender_label == 'Female':\n",
1595
+ " ax.set_ylabel('Number of Subjects', fontsize=14, fontweight='bold')\n",
1596
+ " ax.set_title(f'{gender_label} Read', fontsize=14, fontweight='bold')\n",
1597
+ "\n",
1598
+ "# Set up the subplots\n",
1599
+ "fig, axes = plt.subplots(1, 2, figsize=(14, 6.5), sharey=True)\n",
1600
+ "\n",
1601
+ "plot_gender_data(axes[0], aggregated_data.xs('male', level='gender'), 'Male')\n",
1602
+ "plot_gender_data(axes[1], aggregated_data.xs('female', level='gender'), 'Female')\n",
1603
+ "\n",
1604
+ "legend_patches = [\n",
1605
+ " mpatches.Patch(facecolor='blueviolet', edgecolor='blueviolet', linewidth=2, label='Level 16: XXX'),\n",
1606
+ " mpatches.Patch(facecolor='crimson', edgecolor='crimson', linewidth=2, label='Level 8: X'),\n",
1607
+ " mpatches.Patch(facecolor='coral', edgecolor='coral', linewidth=2, label='Level 4: Mature'),\n",
1608
+ " mpatches.Patch(facecolor='rosybrown', edgecolor='rosybrown', linewidth=2, label='Level 2: Soft'),\n",
1609
+ " mpatches.Patch(facecolor='silver', edgecolor='silver', linewidth=2, label='Level 1: SFW'),\n",
1610
+ " mpatches.Patch(facecolor='none', edgecolor='none', label=f'n images: {n_images}', alpha=0),\n",
1611
+ " mpatches.Patch(facecolor='none', edgecolor='none', label=f'Total persons detected: {total_persons_detected}', alpha=0),\n",
1612
+ " mpatches.Patch(facecolor='none', edgecolor='none', label=f'Unique images containing persons: {n_persons_detected}', alpha=0),\n",
1613
+ "]\n",
1614
+ "\n",
1615
+ "axes[0].legend(handles=legend_patches, title=\"Browsing Levels\", loc='upper left', fontsize=12, title_fontsize=12, frameon=True)\n",
1616
+ "plt.savefig(f'{plot_dir}/mivolo.svg', format='svg', bbox_inches='tight')\n",
1617
+ "plt.tight_layout()\n",
1618
+ "\n",
1619
+ "# Count images with at least one person\n",
1620
+ "images_with_one_or_more_persons = all_data[all_data['n_persons'] > 0]['id'].nunique()\n",
1621
+ "\n",
1622
+ "# Count unique images in `person_data`\n",
1623
+ "n_persons_detected = person_data['id'].nunique()\n",
1624
+ "\n",
1625
+ "# Count total persons detected\n",
1626
+ "total_persons = person_data.shape[0] # This counts all detected persons\n",
1627
+ "\n",
1628
+ "# Display potential inconsistencies\n",
1629
+ "print(f\"Total images: {n_images}\")\n",
1630
+ "print(f\"Images with at least one person: {images_with_one_or_more_persons}\")\n",
1631
+ "print(f\"Unique images in `person_data`: {n_persons_detected}\")\n",
1632
+ "print(f\"Total number of persons detected: {total_persons}\")\n",
1633
+ "\n",
1634
+ "\n",
1635
+ "\n",
1636
+ "plt.show()"
1637
+ ]
1638
+ },
1639
+ {
1640
+ "cell_type": "markdown",
1641
+ "id": "42b2a557-b8f4-4d0f-8907-98e3012a1b34",
1642
+ "metadata": {
1643
+ "execution": {
1644
+ "iopub.execute_input": "2025-02-06T20:01:54.848400Z",
1645
+ "iopub.status.busy": "2025-02-06T20:01:54.847713Z",
1646
+ "iopub.status.idle": "2025-02-06T20:01:54.851533Z",
1647
+ "shell.execute_reply": "2025-02-06T20:01:54.851102Z",
1648
+ "shell.execute_reply.started": "2025-02-06T20:01:54.848376Z"
1649
+ }
1650
+ },
1651
+ "source": [
1652
+ "### Latex Table"
1653
+ ]
1654
+ },
1655
+ {
1656
+ "cell_type": "code",
1657
+ "execution_count": null,
1658
+ "id": "3e506c41-6497-4ece-99f3-73f09fe1129e",
1659
+ "metadata": {},
1660
+ "outputs": [],
1661
+ "source": [
1662
+ "import os\n",
1663
+ "import pandas as pd\n",
1664
+ "\n",
1665
+ "# Define the directory containing CSV files\n",
1666
+ "directory_path = current_dir.parent / 'data/CSV/image_subsets/MiVOLO-results/' # Update this path with the actual directory path\n",
1667
+ "\n",
1668
+ "# Prepare data for LaTeX table\n",
1669
+ "table_rows = []\n",
1670
+ "\n",
1671
+ "# Loop through each file in the directory\n",
1672
+ "for file_name in os.listdir(directory_path):\n",
1673
+ " if file_name.endswith('.csv'):\n",
1674
+ " file_path = os.path.join(directory_path, file_name)\n",
1675
+ " print(f\"Processing file: {file_name}\")\n",
1676
+ "\n",
1677
+ " # Load the data\n",
1678
+ " data = pd.read_csv(file_path)\n",
1679
+ "\n",
1680
+ " # Total images analyzed\n",
1681
+ " total_images = data['id'].nunique()\n",
1682
+ "\n",
1683
+ " # Count of images with no persons detected\n",
1684
+ " images_no_persons = data[data['n_persons'] == 0]['id'].nunique()\n",
1685
+ "\n",
1686
+ " # Total persons detected (only using \"person\" detection type)\n",
1687
+ " total_persons_count = data[data['detection_type'] == 'person'].shape[0]\n",
1688
+ "\n",
1689
+ " # Average age and standard deviation for male and female individuals\n",
1690
+ " male_age_stats = data[data['gender'] == 'male']['age'].agg(['mean', 'std']).fillna(0)\n",
1691
+ " female_age_stats = data[data['gender'] == 'female']['age'].agg(['mean', 'std']).fillna(0)\n",
1692
+ "\n",
1693
+ " # Count of female and male subjects\n",
1694
+ " female_images_count = data[data['gender'] == 'female']['id'].nunique()\n",
1695
+ " male_images_count = data[data['gender'] == 'male']['id'].nunique()\n",
1696
+ "\n",
1697
+ " # Female to male ratio\n",
1698
+ " female_to_male_ratio = female_images_count / male_images_count if male_images_count else None\n",
1699
+ "\n",
1700
+ " # Browsing level analysis for females\n",
1701
+ " female_browsing_level_1 = data[(data['gender'] == 'female') & (data['browsingLevel'] == 1)]['id'].nunique()\n",
1702
+ " female_browsing_level_2_16 = data[(data['gender'] == 'female') & (data['browsingLevel'].isin([2, 4, 8, 16]))]['id'].nunique()\n",
1703
+ " \n",
1704
+ " female_browsing_level_1_percentage = (female_browsing_level_1 / female_images_count * 100) if female_images_count else 0\n",
1705
+ " female_browsing_level_2_16_percentage = (female_browsing_level_2_16 / female_images_count * 100) if female_images_count else 0\n",
1706
+ "\n",
1707
+ " # Browsing level analysis for males\n",
1708
+ " male_browsing_level_1 = data[(data['gender'] == 'male') & (data['browsingLevel'] == 1)]['id'].nunique()\n",
1709
+ " male_browsing_level_2_16 = data[(data['gender'] == 'male') & (data['browsingLevel'].isin([2, 4, 8, 16]))]['id'].nunique()\n",
1710
+ "\n",
1711
+ " male_browsing_level_1_percentage = (male_browsing_level_1 / male_images_count * 100) if male_images_count else 0\n",
1712
+ " male_browsing_level_2_16_percentage = (male_browsing_level_2_16 / male_images_count * 100) if male_images_count else 0\n",
1713
+ "\n",
1714
+ " # Add row to table data\n",
1715
+ " table_rows.append([\n",
1716
+ " file_name.replace('.csv', ''), # Remove file extension\n",
1717
+ " total_images,\n",
1718
+ " total_persons_count,\n",
1719
+ " images_no_persons,\n",
1720
+ " f\"{female_browsing_level_1_percentage:.2f}\",\n",
1721
+ " f\"{female_browsing_level_2_16_percentage:.2f}\",\n",
1722
+ " f\"{male_browsing_level_1_percentage:.2f}\",\n",
1723
+ " f\"{male_browsing_level_2_16_percentage:.2f}\",\n",
1724
+ " f\"{female_to_male_ratio:.2f}\" if female_to_male_ratio is not None else \"N/A\",\n",
1725
+ " f\"{female_age_stats['mean']:.2f} ({female_age_stats['std']:.2f})\",\n",
1726
+ " f\"{male_age_stats['mean']:.2f} ({male_age_stats['std']:.2f})\"\n",
1727
+ " ])\n",
1728
+ "\n",
1729
+ "# Sort table rows by the filename (assumes filenames are formatted with sortable dates)\n",
1730
+ "table_rows = sorted(table_rows, key=lambda x: x[0])\n",
1731
+ "\n",
1732
+ "# Generate LaTeX table\n",
1733
+ "latex_table = r\"\"\"\n",
1734
+ "\\begin{table}[H]\n",
1735
+ "\\centering\n",
1736
+ "\\scriptsize\n",
1737
+ "\\renewcommand{\\arraystretch}{0.9}\n",
1738
+ "\\caption{Summary of Image Classification for 2023-2024}\n",
1739
+ "\\label{table:image_classification_2023_2024}\n",
1740
+ "\\begin{tabular}{lrrrrrrrrrr}\n",
1741
+ "\\toprule\n",
1742
+ "File Name & Total Images & Total Persons & No Persons & \\multicolumn{2}{c}{Female (\\%)} & \\multicolumn{2}{c}{Male (\\%)} & Female:Male & Female Age (Mean Β± SD) & Male Age (Mean Β± SD) \\\\\n",
1743
+ " & & & & L1 & L2-16 & L1 & L2-16 & & & \\\\\n",
1744
+ "\\midrule\n",
1745
+ "\"\"\"\n",
1746
+ "for row in table_rows:\n",
1747
+ " latex_table += \" & \".join(map(str, row)) + r\" \\\\\\\\\\n\"\n",
1748
+ "\n",
1749
+ "latex_table += r\"\"\"\n",
1750
+ "\\bottomrule\n",
1751
+ "\\end{tabular}\n",
1752
+ "\\vspace{1em}\n",
1753
+ "\\noindent\n",
1754
+ "\\textbf{Disclaimer:} \\(\\female\\) and \\(\\male\\) refer to female-read and male-read classifications as determined by the MiVOLO system's weights. \n",
1755
+ "We acknowledge the complexities of gender presentations and stress that these terms do not necessarily correspond to biological sex.\n",
1756
+ "\\end{table}\n",
1757
+ "\"\"\"\n",
1758
+ "\n",
1759
+ "# Output LaTeX table\n",
1760
+ "print(\"\\nGenerated LaTeX Table:\")\n",
1761
+ "print(latex_table)\n",
1762
+ "\n"
1763
+ ]
1764
+ },
1765
+ {
1766
+ "cell_type": "code",
1767
+ "execution_count": null,
1768
+ "id": "3ef428be-856b-4c4c-b1b0-a052d181d03b",
1769
+ "metadata": {},
1770
+ "outputs": [],
1771
+ "source": []
1772
+ }
1773
+ ],
1774
+ "metadata": {
1775
+ "kernelspec": {
1776
+ "display_name": "HORDE",
1777
+ "language": "python",
1778
+ "name": "horde"
1779
+ },
1780
+ "language_info": {
1781
+ "codemirror_mode": {
1782
+ "name": "ipython",
1783
+ "version": 3
1784
+ },
1785
+ "file_extension": ".py",
1786
+ "mimetype": "text/x-python",
1787
+ "name": "python",
1788
+ "nbconvert_exporter": "python",
1789
+ "pygments_lexer": "ipython3",
1790
+ "version": "3.12.4"
1791
+ }
1792
+ },
1793
+ "nbformat": 4,
1794
+ "nbformat_minor": 5
1795
+ }
jupyter_notebooks/GEMMA_3.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
jupyter_notebooks/MISTRAL.ipynb ADDED
@@ -0,0 +1,3006 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "924fc9f0-95c1-44d5-871a-76d655306607",
6
+ "metadata": {},
7
+ "source": [
8
+ "# MISTRAL QUERY"
9
+ ]
10
+ },
11
+ {
12
+ "cell_type": "code",
13
+ "execution_count": null,
14
+ "id": "cfba5e1e-fe51-4fb3-876e-53e3909e87cc",
15
+ "metadata": {
16
+ "execution": {
17
+ "iopub.execute_input": "2025-11-29T10:08:31.471857Z",
18
+ "iopub.status.busy": "2025-11-29T10:08:31.471665Z"
19
+ }
20
+ },
21
+ "outputs": [
22
+ {
23
+ "name": "stdout",
24
+ "output_type": "stream",
25
+ "text": [
26
+ "Loading model: mistralai/Mistral-7B-Instruct-v0.3\n",
27
+ "Cache directory: /shares/weddigen.ki.uzh/laura_wagner/phase_01/pm-paper/data/models\n",
28
+ "This may take a while on first run (~65GB download)...\n",
29
+ "\n",
30
+ "Device: cuda\n",
31
+ "Loading tokenizer...\n",
32
+ "βœ… Tokenizer loaded\n",
33
+ "Loading model (this may take several minutes)...\n"
34
+ ]
35
+ },
36
+ {
37
+ "name": "stderr",
38
+ "output_type": "stream",
39
+ "text": [
40
+ "Loading checkpoint shards: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 3/3 [00:47<00:00, 15.76s/it]\n"
41
+ ]
42
+ },
43
+ {
44
+ "name": "stdout",
45
+ "output_type": "stream",
46
+ "text": [
47
+ "βœ… Model loaded\n",
48
+ "VRAM used: 13.50 GB\n",
49
+ "\n",
50
+ "Loading annotated CSV...\n"
51
+ ]
52
+ },
53
+ {
54
+ "name": "stderr",
55
+ "output_type": "stream",
56
+ "text": [
57
+ "/sctmp/lauwag/ipykernel_1207447/1621707066.py:102: DtypeWarning: Columns (53,54,55,56,57) have mixed types. Specify dtype option on import or set low_memory=False.\n",
58
+ " df = pd.read_csv(output_file)\n"
59
+ ]
60
+ },
61
+ {
62
+ "name": "stdout",
63
+ "output_type": "stream",
64
+ "text": [
65
+ "βœ… Loaded professions.csv\n",
66
+ "βœ… Loaded profession mapping with 9 categories\n",
67
+ "Loaded 50861 rows\n",
68
+ "\n",
69
+ "Profession categories (9):\n",
70
+ " - actor\n",
71
+ " - adult performer\n",
72
+ " - singer/musician\n",
73
+ " - model\n",
74
+ " - online personality\n",
75
+ " - public figure\n",
76
+ " - voice actor/ASMR\n",
77
+ " - sports professional\n",
78
+ " - tv personality\n",
79
+ "\n",
80
+ "Creating prompts...\n",
81
+ "βœ… Prompts created\n",
82
+ "Resuming from index 8790\n"
83
+ ]
84
+ },
85
+ {
86
+ "name": "stderr",
87
+ "output_type": "stream",
88
+ "text": [
89
+ "Mistral Local: 0%| | 10/42071 [00:22<31:33:16, 2.70s/it]"
90
+ ]
91
+ },
92
+ {
93
+ "name": "stdout",
94
+ "output_type": "stream",
95
+ "text": [
96
+ "πŸ’Ύ Progress saved after row 8800\n"
97
+ ]
98
+ },
99
+ {
100
+ "name": "stderr",
101
+ "output_type": "stream",
102
+ "text": [
103
+ "Mistral Local: 0%| | 20/42071 [00:45<30:10:33, 2.58s/it]"
104
+ ]
105
+ },
106
+ {
107
+ "name": "stdout",
108
+ "output_type": "stream",
109
+ "text": [
110
+ "πŸ’Ύ Progress saved after row 8810\n"
111
+ ]
112
+ },
113
+ {
114
+ "name": "stderr",
115
+ "output_type": "stream",
116
+ "text": [
117
+ "Mistral Local: 0%| | 30/42071 [01:04<28:01:14, 2.40s/it]"
118
+ ]
119
+ },
120
+ {
121
+ "name": "stdout",
122
+ "output_type": "stream",
123
+ "text": [
124
+ "πŸ’Ύ Progress saved after row 8820\n"
125
+ ]
126
+ },
127
+ {
128
+ "name": "stderr",
129
+ "output_type": "stream",
130
+ "text": [
131
+ "Mistral Local: 0%| | 40/42071 [01:24<27:18:50, 2.34s/it]"
132
+ ]
133
+ },
134
+ {
135
+ "name": "stdout",
136
+ "output_type": "stream",
137
+ "text": [
138
+ "πŸ’Ύ Progress saved after row 8830\n"
139
+ ]
140
+ },
141
+ {
142
+ "name": "stderr",
143
+ "output_type": "stream",
144
+ "text": [
145
+ "Mistral Local: 0%| | 50/42071 [01:45<27:35:09, 2.36s/it]"
146
+ ]
147
+ },
148
+ {
149
+ "name": "stdout",
150
+ "output_type": "stream",
151
+ "text": [
152
+ "πŸ’Ύ Progress saved after row 8840\n"
153
+ ]
154
+ },
155
+ {
156
+ "name": "stderr",
157
+ "output_type": "stream",
158
+ "text": [
159
+ "Mistral Local: 0%| | 60/42071 [02:03<26:10:45, 2.24s/it]"
160
+ ]
161
+ },
162
+ {
163
+ "name": "stdout",
164
+ "output_type": "stream",
165
+ "text": [
166
+ "πŸ’Ύ Progress saved after row 8850\n"
167
+ ]
168
+ },
169
+ {
170
+ "name": "stderr",
171
+ "output_type": "stream",
172
+ "text": [
173
+ "Mistral Local: 0%| | 70/42071 [02:23<28:07:48, 2.41s/it]"
174
+ ]
175
+ },
176
+ {
177
+ "name": "stdout",
178
+ "output_type": "stream",
179
+ "text": [
180
+ "πŸ’Ύ Progress saved after row 8860\n"
181
+ ]
182
+ },
183
+ {
184
+ "name": "stderr",
185
+ "output_type": "stream",
186
+ "text": [
187
+ "Mistral Local: 0%| | 80/42071 [02:44<28:23:23, 2.43s/it]"
188
+ ]
189
+ },
190
+ {
191
+ "name": "stdout",
192
+ "output_type": "stream",
193
+ "text": [
194
+ "πŸ’Ύ Progress saved after row 8870\n"
195
+ ]
196
+ },
197
+ {
198
+ "name": "stderr",
199
+ "output_type": "stream",
200
+ "text": [
201
+ "Mistral Local: 0%| | 90/42071 [03:05<29:35:43, 2.54s/it]"
202
+ ]
203
+ },
204
+ {
205
+ "name": "stdout",
206
+ "output_type": "stream",
207
+ "text": [
208
+ "πŸ’Ύ Progress saved after row 8880\n"
209
+ ]
210
+ },
211
+ {
212
+ "name": "stderr",
213
+ "output_type": "stream",
214
+ "text": [
215
+ "Mistral Local: 0%| | 100/42071 [03:26<29:13:37, 2.51s/it]"
216
+ ]
217
+ },
218
+ {
219
+ "name": "stdout",
220
+ "output_type": "stream",
221
+ "text": [
222
+ "πŸ’Ύ Progress saved after row 8890\n"
223
+ ]
224
+ },
225
+ {
226
+ "name": "stderr",
227
+ "output_type": "stream",
228
+ "text": [
229
+ "Mistral Local: 0%| | 110/42071 [03:47<28:09:35, 2.42s/it]"
230
+ ]
231
+ },
232
+ {
233
+ "name": "stdout",
234
+ "output_type": "stream",
235
+ "text": [
236
+ "πŸ’Ύ Progress saved after row 8900\n"
237
+ ]
238
+ },
239
+ {
240
+ "name": "stderr",
241
+ "output_type": "stream",
242
+ "text": [
243
+ "Mistral Local: 0%| | 120/42071 [04:08<29:11:22, 2.50s/it]"
244
+ ]
245
+ },
246
+ {
247
+ "name": "stdout",
248
+ "output_type": "stream",
249
+ "text": [
250
+ "πŸ’Ύ Progress saved after row 8910\n"
251
+ ]
252
+ },
253
+ {
254
+ "name": "stderr",
255
+ "output_type": "stream",
256
+ "text": [
257
+ "Mistral Local: 0%| | 130/42071 [04:31<35:26:12, 3.04s/it]"
258
+ ]
259
+ },
260
+ {
261
+ "name": "stdout",
262
+ "output_type": "stream",
263
+ "text": [
264
+ "πŸ’Ύ Progress saved after row 8920\n"
265
+ ]
266
+ },
267
+ {
268
+ "name": "stderr",
269
+ "output_type": "stream",
270
+ "text": [
271
+ "Mistral Local: 0%| | 140/42071 [04:54<31:01:14, 2.66s/it]"
272
+ ]
273
+ },
274
+ {
275
+ "name": "stdout",
276
+ "output_type": "stream",
277
+ "text": [
278
+ "πŸ’Ύ Progress saved after row 8930\n"
279
+ ]
280
+ },
281
+ {
282
+ "name": "stderr",
283
+ "output_type": "stream",
284
+ "text": [
285
+ "Mistral Local: 0%| | 150/42071 [05:14<28:32:42, 2.45s/it]"
286
+ ]
287
+ },
288
+ {
289
+ "name": "stdout",
290
+ "output_type": "stream",
291
+ "text": [
292
+ "πŸ’Ύ Progress saved after row 8940\n"
293
+ ]
294
+ },
295
+ {
296
+ "name": "stderr",
297
+ "output_type": "stream",
298
+ "text": [
299
+ "Mistral Local: 0%| | 160/42071 [05:36<28:37:48, 2.46s/it]"
300
+ ]
301
+ },
302
+ {
303
+ "name": "stdout",
304
+ "output_type": "stream",
305
+ "text": [
306
+ "πŸ’Ύ Progress saved after row 8950\n"
307
+ ]
308
+ },
309
+ {
310
+ "name": "stderr",
311
+ "output_type": "stream",
312
+ "text": [
313
+ "Mistral Local: 0%| | 170/42071 [05:56<29:47:28, 2.56s/it]"
314
+ ]
315
+ },
316
+ {
317
+ "name": "stdout",
318
+ "output_type": "stream",
319
+ "text": [
320
+ "πŸ’Ύ Progress saved after row 8960\n"
321
+ ]
322
+ },
323
+ {
324
+ "name": "stderr",
325
+ "output_type": "stream",
326
+ "text": [
327
+ "Mistral Local: 0%| | 180/42071 [06:14<24:59:54, 2.15s/it]"
328
+ ]
329
+ },
330
+ {
331
+ "name": "stdout",
332
+ "output_type": "stream",
333
+ "text": [
334
+ "πŸ’Ύ Progress saved after row 8970\n"
335
+ ]
336
+ },
337
+ {
338
+ "name": "stderr",
339
+ "output_type": "stream",
340
+ "text": [
341
+ "Mistral Local: 0%| | 190/42071 [06:39<36:14:58, 3.12s/it]"
342
+ ]
343
+ },
344
+ {
345
+ "name": "stdout",
346
+ "output_type": "stream",
347
+ "text": [
348
+ "πŸ’Ύ Progress saved after row 8980\n"
349
+ ]
350
+ },
351
+ {
352
+ "name": "stderr",
353
+ "output_type": "stream",
354
+ "text": [
355
+ "Mistral Local: 0%| | 200/42071 [07:01<27:25:15, 2.36s/it]"
356
+ ]
357
+ },
358
+ {
359
+ "name": "stdout",
360
+ "output_type": "stream",
361
+ "text": [
362
+ "πŸ’Ύ Progress saved after row 8990\n"
363
+ ]
364
+ },
365
+ {
366
+ "name": "stderr",
367
+ "output_type": "stream",
368
+ "text": [
369
+ "Mistral Local: 0%| | 210/42071 [07:20<29:50:27, 2.57s/it]"
370
+ ]
371
+ },
372
+ {
373
+ "name": "stdout",
374
+ "output_type": "stream",
375
+ "text": [
376
+ "πŸ’Ύ Progress saved after row 9000\n"
377
+ ]
378
+ },
379
+ {
380
+ "name": "stderr",
381
+ "output_type": "stream",
382
+ "text": [
383
+ "Mistral Local: 1%| | 220/42071 [07:39<28:15:01, 2.43s/it]"
384
+ ]
385
+ },
386
+ {
387
+ "name": "stdout",
388
+ "output_type": "stream",
389
+ "text": [
390
+ "πŸ’Ύ Progress saved after row 9010\n"
391
+ ]
392
+ },
393
+ {
394
+ "name": "stderr",
395
+ "output_type": "stream",
396
+ "text": [
397
+ "Mistral Local: 1%| | 230/42071 [08:00<29:22:05, 2.53s/it]"
398
+ ]
399
+ },
400
+ {
401
+ "name": "stdout",
402
+ "output_type": "stream",
403
+ "text": [
404
+ "πŸ’Ύ Progress saved after row 9020\n"
405
+ ]
406
+ },
407
+ {
408
+ "name": "stderr",
409
+ "output_type": "stream",
410
+ "text": [
411
+ "Mistral Local: 1%| | 240/42071 [08:21<30:00:58, 2.58s/it]"
412
+ ]
413
+ },
414
+ {
415
+ "name": "stdout",
416
+ "output_type": "stream",
417
+ "text": [
418
+ "πŸ’Ύ Progress saved after row 9030\n"
419
+ ]
420
+ },
421
+ {
422
+ "name": "stderr",
423
+ "output_type": "stream",
424
+ "text": [
425
+ "Mistral Local: 1%| | 250/42071 [08:41<26:54:22, 2.32s/it]"
426
+ ]
427
+ },
428
+ {
429
+ "name": "stdout",
430
+ "output_type": "stream",
431
+ "text": [
432
+ "πŸ’Ύ Progress saved after row 9040\n"
433
+ ]
434
+ },
435
+ {
436
+ "name": "stderr",
437
+ "output_type": "stream",
438
+ "text": [
439
+ "Mistral Local: 1%| | 260/42071 [09:03<32:51:56, 2.83s/it]"
440
+ ]
441
+ },
442
+ {
443
+ "name": "stdout",
444
+ "output_type": "stream",
445
+ "text": [
446
+ "πŸ’Ύ Progress saved after row 9050\n"
447
+ ]
448
+ },
449
+ {
450
+ "name": "stderr",
451
+ "output_type": "stream",
452
+ "text": [
453
+ "Mistral Local: 1%| | 270/42071 [09:23<28:50:25, 2.48s/it]"
454
+ ]
455
+ },
456
+ {
457
+ "name": "stdout",
458
+ "output_type": "stream",
459
+ "text": [
460
+ "πŸ’Ύ Progress saved after row 9060\n"
461
+ ]
462
+ },
463
+ {
464
+ "name": "stderr",
465
+ "output_type": "stream",
466
+ "text": [
467
+ "Mistral Local: 1%| | 280/42071 [09:43<25:37:13, 2.21s/it]"
468
+ ]
469
+ },
470
+ {
471
+ "name": "stdout",
472
+ "output_type": "stream",
473
+ "text": [
474
+ "πŸ’Ύ Progress saved after row 9070\n"
475
+ ]
476
+ },
477
+ {
478
+ "name": "stderr",
479
+ "output_type": "stream",
480
+ "text": [
481
+ "Mistral Local: 1%| | 290/42071 [10:04<28:16:26, 2.44s/it]"
482
+ ]
483
+ },
484
+ {
485
+ "name": "stdout",
486
+ "output_type": "stream",
487
+ "text": [
488
+ "πŸ’Ύ Progress saved after row 9080\n"
489
+ ]
490
+ },
491
+ {
492
+ "name": "stderr",
493
+ "output_type": "stream",
494
+ "text": [
495
+ "Mistral Local: 1%| | 300/42071 [10:26<29:36:56, 2.55s/it]"
496
+ ]
497
+ },
498
+ {
499
+ "name": "stdout",
500
+ "output_type": "stream",
501
+ "text": [
502
+ "πŸ’Ύ Progress saved after row 9090\n"
503
+ ]
504
+ },
505
+ {
506
+ "name": "stderr",
507
+ "output_type": "stream",
508
+ "text": [
509
+ "Mistral Local: 1%| | 310/42071 [10:47<27:13:03, 2.35s/it]"
510
+ ]
511
+ },
512
+ {
513
+ "name": "stdout",
514
+ "output_type": "stream",
515
+ "text": [
516
+ "πŸ’Ύ Progress saved after row 9100\n"
517
+ ]
518
+ },
519
+ {
520
+ "name": "stderr",
521
+ "output_type": "stream",
522
+ "text": [
523
+ "Mistral Local: 1%| | 320/42071 [11:08<27:56:12, 2.41s/it]"
524
+ ]
525
+ },
526
+ {
527
+ "name": "stdout",
528
+ "output_type": "stream",
529
+ "text": [
530
+ "πŸ’Ύ Progress saved after row 9110\n"
531
+ ]
532
+ },
533
+ {
534
+ "name": "stderr",
535
+ "output_type": "stream",
536
+ "text": [
537
+ "Mistral Local: 1%| | 330/42071 [11:26<28:24:37, 2.45s/it]"
538
+ ]
539
+ },
540
+ {
541
+ "name": "stdout",
542
+ "output_type": "stream",
543
+ "text": [
544
+ "πŸ’Ύ Progress saved after row 9120\n"
545
+ ]
546
+ },
547
+ {
548
+ "name": "stderr",
549
+ "output_type": "stream",
550
+ "text": [
551
+ "Mistral Local: 1%| | 340/42071 [11:46<28:02:33, 2.42s/it]"
552
+ ]
553
+ },
554
+ {
555
+ "name": "stdout",
556
+ "output_type": "stream",
557
+ "text": [
558
+ "πŸ’Ύ Progress saved after row 9130\n"
559
+ ]
560
+ },
561
+ {
562
+ "name": "stderr",
563
+ "output_type": "stream",
564
+ "text": [
565
+ "Mistral Local: 1%| | 350/42071 [12:10<30:51:36, 2.66s/it]"
566
+ ]
567
+ },
568
+ {
569
+ "name": "stdout",
570
+ "output_type": "stream",
571
+ "text": [
572
+ "πŸ’Ύ Progress saved after row 9140\n"
573
+ ]
574
+ },
575
+ {
576
+ "name": "stderr",
577
+ "output_type": "stream",
578
+ "text": [
579
+ "Mistral Local: 1%| | 360/42071 [12:30<27:10:53, 2.35s/it]"
580
+ ]
581
+ },
582
+ {
583
+ "name": "stdout",
584
+ "output_type": "stream",
585
+ "text": [
586
+ "πŸ’Ύ Progress saved after row 9150\n"
587
+ ]
588
+ },
589
+ {
590
+ "name": "stderr",
591
+ "output_type": "stream",
592
+ "text": [
593
+ "Mistral Local: 1%| | 370/42071 [12:51<27:30:42, 2.38s/it]"
594
+ ]
595
+ },
596
+ {
597
+ "name": "stdout",
598
+ "output_type": "stream",
599
+ "text": [
600
+ "πŸ’Ύ Progress saved after row 9160\n"
601
+ ]
602
+ },
603
+ {
604
+ "name": "stderr",
605
+ "output_type": "stream",
606
+ "text": [
607
+ "Mistral Local: 1%| | 380/42071 [13:10<26:18:09, 2.27s/it]"
608
+ ]
609
+ },
610
+ {
611
+ "name": "stdout",
612
+ "output_type": "stream",
613
+ "text": [
614
+ "πŸ’Ύ Progress saved after row 9170\n"
615
+ ]
616
+ },
617
+ {
618
+ "name": "stderr",
619
+ "output_type": "stream",
620
+ "text": [
621
+ "Mistral Local: 1%| | 390/42071 [13:31<29:09:59, 2.52s/it]"
622
+ ]
623
+ },
624
+ {
625
+ "name": "stdout",
626
+ "output_type": "stream",
627
+ "text": [
628
+ "πŸ’Ύ Progress saved after row 9180\n"
629
+ ]
630
+ },
631
+ {
632
+ "name": "stderr",
633
+ "output_type": "stream",
634
+ "text": [
635
+ "Mistral Local: 1%| | 400/42071 [13:51<28:30:21, 2.46s/it]"
636
+ ]
637
+ },
638
+ {
639
+ "name": "stdout",
640
+ "output_type": "stream",
641
+ "text": [
642
+ "πŸ’Ύ Progress saved after row 9190\n"
643
+ ]
644
+ },
645
+ {
646
+ "name": "stderr",
647
+ "output_type": "stream",
648
+ "text": [
649
+ "Mistral Local: 1%| | 410/42071 [14:11<28:16:34, 2.44s/it]"
650
+ ]
651
+ },
652
+ {
653
+ "name": "stdout",
654
+ "output_type": "stream",
655
+ "text": [
656
+ "πŸ’Ύ Progress saved after row 9200\n"
657
+ ]
658
+ },
659
+ {
660
+ "name": "stderr",
661
+ "output_type": "stream",
662
+ "text": [
663
+ "Mistral Local: 1%| | 420/42071 [14:31<28:40:48, 2.48s/it]"
664
+ ]
665
+ },
666
+ {
667
+ "name": "stdout",
668
+ "output_type": "stream",
669
+ "text": [
670
+ "πŸ’Ύ Progress saved after row 9210\n"
671
+ ]
672
+ },
673
+ {
674
+ "name": "stderr",
675
+ "output_type": "stream",
676
+ "text": [
677
+ "Mistral Local: 1%| | 430/42071 [14:50<27:36:54, 2.39s/it]"
678
+ ]
679
+ },
680
+ {
681
+ "name": "stdout",
682
+ "output_type": "stream",
683
+ "text": [
684
+ "πŸ’Ύ Progress saved after row 9220\n"
685
+ ]
686
+ },
687
+ {
688
+ "name": "stderr",
689
+ "output_type": "stream",
690
+ "text": [
691
+ "Mistral Local: 1%| | 440/42071 [15:12<29:55:01, 2.59s/it]"
692
+ ]
693
+ },
694
+ {
695
+ "name": "stdout",
696
+ "output_type": "stream",
697
+ "text": [
698
+ "πŸ’Ύ Progress saved after row 9230\n"
699
+ ]
700
+ },
701
+ {
702
+ "name": "stderr",
703
+ "output_type": "stream",
704
+ "text": [
705
+ "Mistral Local: 1%| | 450/42071 [15:34<29:02:10, 2.51s/it]"
706
+ ]
707
+ },
708
+ {
709
+ "name": "stdout",
710
+ "output_type": "stream",
711
+ "text": [
712
+ "πŸ’Ύ Progress saved after row 9240\n"
713
+ ]
714
+ },
715
+ {
716
+ "name": "stderr",
717
+ "output_type": "stream",
718
+ "text": [
719
+ "Mistral Local: 1%| | 460/42071 [15:55<30:21:48, 2.63s/it]"
720
+ ]
721
+ },
722
+ {
723
+ "name": "stdout",
724
+ "output_type": "stream",
725
+ "text": [
726
+ "πŸ’Ύ Progress saved after row 9250\n"
727
+ ]
728
+ },
729
+ {
730
+ "name": "stderr",
731
+ "output_type": "stream",
732
+ "text": [
733
+ "Mistral Local: 1%| | 470/42071 [16:14<25:51:25, 2.24s/it]"
734
+ ]
735
+ },
736
+ {
737
+ "name": "stdout",
738
+ "output_type": "stream",
739
+ "text": [
740
+ "πŸ’Ύ Progress saved after row 9260\n"
741
+ ]
742
+ },
743
+ {
744
+ "name": "stderr",
745
+ "output_type": "stream",
746
+ "text": [
747
+ "Mistral Local: 1%| | 480/42071 [16:34<28:45:04, 2.49s/it]"
748
+ ]
749
+ },
750
+ {
751
+ "name": "stdout",
752
+ "output_type": "stream",
753
+ "text": [
754
+ "πŸ’Ύ Progress saved after row 9270\n"
755
+ ]
756
+ },
757
+ {
758
+ "name": "stderr",
759
+ "output_type": "stream",
760
+ "text": [
761
+ "Mistral Local: 1%| | 490/42071 [16:55<31:28:55, 2.73s/it]"
762
+ ]
763
+ },
764
+ {
765
+ "name": "stdout",
766
+ "output_type": "stream",
767
+ "text": [
768
+ "πŸ’Ύ Progress saved after row 9280\n"
769
+ ]
770
+ },
771
+ {
772
+ "name": "stderr",
773
+ "output_type": "stream",
774
+ "text": [
775
+ "Mistral Local: 1%| | 500/42071 [17:15<27:51:29, 2.41s/it]"
776
+ ]
777
+ },
778
+ {
779
+ "name": "stdout",
780
+ "output_type": "stream",
781
+ "text": [
782
+ "πŸ’Ύ Progress saved after row 9290\n"
783
+ ]
784
+ },
785
+ {
786
+ "name": "stderr",
787
+ "output_type": "stream",
788
+ "text": [
789
+ "Mistral Local: 1%| | 510/42071 [17:35<25:41:11, 2.22s/it]"
790
+ ]
791
+ },
792
+ {
793
+ "name": "stdout",
794
+ "output_type": "stream",
795
+ "text": [
796
+ "πŸ’Ύ Progress saved after row 9300\n"
797
+ ]
798
+ },
799
+ {
800
+ "name": "stderr",
801
+ "output_type": "stream",
802
+ "text": [
803
+ "Mistral Local: 1%| | 520/42071 [17:54<26:36:23, 2.31s/it]"
804
+ ]
805
+ },
806
+ {
807
+ "name": "stdout",
808
+ "output_type": "stream",
809
+ "text": [
810
+ "πŸ’Ύ Progress saved after row 9310\n"
811
+ ]
812
+ },
813
+ {
814
+ "name": "stderr",
815
+ "output_type": "stream",
816
+ "text": [
817
+ "Mistral Local: 1%|▏ | 530/42071 [18:13<26:31:03, 2.30s/it]"
818
+ ]
819
+ },
820
+ {
821
+ "name": "stdout",
822
+ "output_type": "stream",
823
+ "text": [
824
+ "πŸ’Ύ Progress saved after row 9320\n"
825
+ ]
826
+ },
827
+ {
828
+ "name": "stderr",
829
+ "output_type": "stream",
830
+ "text": [
831
+ "Mistral Local: 1%|▏ | 540/42071 [18:33<29:41:27, 2.57s/it]"
832
+ ]
833
+ },
834
+ {
835
+ "name": "stdout",
836
+ "output_type": "stream",
837
+ "text": [
838
+ "πŸ’Ύ Progress saved after row 9330\n"
839
+ ]
840
+ },
841
+ {
842
+ "name": "stderr",
843
+ "output_type": "stream",
844
+ "text": [
845
+ "Mistral Local: 1%|▏ | 550/42071 [18:53<29:34:09, 2.56s/it]"
846
+ ]
847
+ },
848
+ {
849
+ "name": "stdout",
850
+ "output_type": "stream",
851
+ "text": [
852
+ "πŸ’Ύ Progress saved after row 9340\n"
853
+ ]
854
+ },
855
+ {
856
+ "name": "stderr",
857
+ "output_type": "stream",
858
+ "text": [
859
+ "Mistral Local: 1%|▏ | 560/42071 [19:15<30:45:00, 2.67s/it]"
860
+ ]
861
+ },
862
+ {
863
+ "name": "stdout",
864
+ "output_type": "stream",
865
+ "text": [
866
+ "πŸ’Ύ Progress saved after row 9350\n"
867
+ ]
868
+ },
869
+ {
870
+ "name": "stderr",
871
+ "output_type": "stream",
872
+ "text": [
873
+ "Mistral Local: 1%|▏ | 570/42071 [19:35<28:44:33, 2.49s/it]"
874
+ ]
875
+ },
876
+ {
877
+ "name": "stdout",
878
+ "output_type": "stream",
879
+ "text": [
880
+ "πŸ’Ύ Progress saved after row 9360\n"
881
+ ]
882
+ },
883
+ {
884
+ "name": "stderr",
885
+ "output_type": "stream",
886
+ "text": [
887
+ "Mistral Local: 1%|▏ | 580/42071 [19:54<28:12:08, 2.45s/it]"
888
+ ]
889
+ },
890
+ {
891
+ "name": "stdout",
892
+ "output_type": "stream",
893
+ "text": [
894
+ "πŸ’Ύ Progress saved after row 9370\n"
895
+ ]
896
+ },
897
+ {
898
+ "name": "stderr",
899
+ "output_type": "stream",
900
+ "text": [
901
+ "Mistral Local: 1%|▏ | 590/42071 [20:19<36:03:11, 3.13s/it]"
902
+ ]
903
+ },
904
+ {
905
+ "name": "stdout",
906
+ "output_type": "stream",
907
+ "text": [
908
+ "πŸ’Ύ Progress saved after row 9380\n"
909
+ ]
910
+ },
911
+ {
912
+ "name": "stderr",
913
+ "output_type": "stream",
914
+ "text": [
915
+ "Mistral Local: 1%|▏ | 600/42071 [20:40<30:45:13, 2.67s/it]"
916
+ ]
917
+ },
918
+ {
919
+ "name": "stdout",
920
+ "output_type": "stream",
921
+ "text": [
922
+ "πŸ’Ύ Progress saved after row 9390\n"
923
+ ]
924
+ },
925
+ {
926
+ "name": "stderr",
927
+ "output_type": "stream",
928
+ "text": [
929
+ "Mistral Local: 1%|▏ | 610/42071 [20:59<26:18:00, 2.28s/it]"
930
+ ]
931
+ },
932
+ {
933
+ "name": "stdout",
934
+ "output_type": "stream",
935
+ "text": [
936
+ "πŸ’Ύ Progress saved after row 9400\n"
937
+ ]
938
+ },
939
+ {
940
+ "name": "stderr",
941
+ "output_type": "stream",
942
+ "text": [
943
+ "Mistral Local: 1%|▏ | 620/42071 [21:20<27:15:41, 2.37s/it]"
944
+ ]
945
+ },
946
+ {
947
+ "name": "stdout",
948
+ "output_type": "stream",
949
+ "text": [
950
+ "πŸ’Ύ Progress saved after row 9410\n"
951
+ ]
952
+ },
953
+ {
954
+ "name": "stderr",
955
+ "output_type": "stream",
956
+ "text": [
957
+ "Mistral Local: 1%|▏ | 630/42071 [21:42<28:20:07, 2.46s/it]"
958
+ ]
959
+ },
960
+ {
961
+ "name": "stdout",
962
+ "output_type": "stream",
963
+ "text": [
964
+ "πŸ’Ύ Progress saved after row 9420\n"
965
+ ]
966
+ },
967
+ {
968
+ "name": "stderr",
969
+ "output_type": "stream",
970
+ "text": [
971
+ "Mistral Local: 2%|▏ | 640/42071 [22:03<34:02:41, 2.96s/it]"
972
+ ]
973
+ },
974
+ {
975
+ "name": "stdout",
976
+ "output_type": "stream",
977
+ "text": [
978
+ "πŸ’Ύ Progress saved after row 9430\n"
979
+ ]
980
+ },
981
+ {
982
+ "name": "stderr",
983
+ "output_type": "stream",
984
+ "text": [
985
+ "Mistral Local: 2%|▏ | 650/42071 [22:25<29:27:42, 2.56s/it]"
986
+ ]
987
+ },
988
+ {
989
+ "name": "stdout",
990
+ "output_type": "stream",
991
+ "text": [
992
+ "πŸ’Ύ Progress saved after row 9440\n"
993
+ ]
994
+ },
995
+ {
996
+ "name": "stderr",
997
+ "output_type": "stream",
998
+ "text": [
999
+ "Mistral Local: 2%|▏ | 660/42071 [22:44<30:01:06, 2.61s/it]"
1000
+ ]
1001
+ },
1002
+ {
1003
+ "name": "stdout",
1004
+ "output_type": "stream",
1005
+ "text": [
1006
+ "πŸ’Ύ Progress saved after row 9450\n"
1007
+ ]
1008
+ },
1009
+ {
1010
+ "name": "stderr",
1011
+ "output_type": "stream",
1012
+ "text": [
1013
+ "Mistral Local: 2%|▏ | 670/42071 [23:07<28:55:03, 2.51s/it]"
1014
+ ]
1015
+ },
1016
+ {
1017
+ "name": "stdout",
1018
+ "output_type": "stream",
1019
+ "text": [
1020
+ "πŸ’Ύ Progress saved after row 9460\n"
1021
+ ]
1022
+ },
1023
+ {
1024
+ "name": "stderr",
1025
+ "output_type": "stream",
1026
+ "text": [
1027
+ "Mistral Local: 2%|▏ | 680/42071 [23:28<29:29:57, 2.57s/it]"
1028
+ ]
1029
+ },
1030
+ {
1031
+ "name": "stdout",
1032
+ "output_type": "stream",
1033
+ "text": [
1034
+ "πŸ’Ύ Progress saved after row 9470\n"
1035
+ ]
1036
+ },
1037
+ {
1038
+ "name": "stderr",
1039
+ "output_type": "stream",
1040
+ "text": [
1041
+ "Mistral Local: 2%|▏ | 690/42071 [23:48<27:56:29, 2.43s/it]"
1042
+ ]
1043
+ },
1044
+ {
1045
+ "name": "stdout",
1046
+ "output_type": "stream",
1047
+ "text": [
1048
+ "πŸ’Ύ Progress saved after row 9480\n"
1049
+ ]
1050
+ },
1051
+ {
1052
+ "name": "stderr",
1053
+ "output_type": "stream",
1054
+ "text": [
1055
+ "Mistral Local: 2%|▏ | 700/42071 [24:09<28:46:20, 2.50s/it]"
1056
+ ]
1057
+ },
1058
+ {
1059
+ "name": "stdout",
1060
+ "output_type": "stream",
1061
+ "text": [
1062
+ "πŸ’Ύ Progress saved after row 9490\n"
1063
+ ]
1064
+ },
1065
+ {
1066
+ "name": "stderr",
1067
+ "output_type": "stream",
1068
+ "text": [
1069
+ "Mistral Local: 2%|▏ | 710/42071 [24:29<26:39:32, 2.32s/it]"
1070
+ ]
1071
+ },
1072
+ {
1073
+ "name": "stdout",
1074
+ "output_type": "stream",
1075
+ "text": [
1076
+ "πŸ’Ύ Progress saved after row 9500\n"
1077
+ ]
1078
+ },
1079
+ {
1080
+ "name": "stderr",
1081
+ "output_type": "stream",
1082
+ "text": [
1083
+ "Mistral Local: 2%|▏ | 720/42071 [24:51<28:42:54, 2.50s/it]"
1084
+ ]
1085
+ },
1086
+ {
1087
+ "name": "stdout",
1088
+ "output_type": "stream",
1089
+ "text": [
1090
+ "πŸ’Ύ Progress saved after row 9510\n"
1091
+ ]
1092
+ },
1093
+ {
1094
+ "name": "stderr",
1095
+ "output_type": "stream",
1096
+ "text": [
1097
+ "Mistral Local: 2%|▏ | 730/42071 [25:13<30:13:50, 2.63s/it]"
1098
+ ]
1099
+ },
1100
+ {
1101
+ "name": "stdout",
1102
+ "output_type": "stream",
1103
+ "text": [
1104
+ "πŸ’Ύ Progress saved after row 9520\n"
1105
+ ]
1106
+ },
1107
+ {
1108
+ "name": "stderr",
1109
+ "output_type": "stream",
1110
+ "text": [
1111
+ "Mistral Local: 2%|▏ | 740/42071 [25:32<25:45:45, 2.24s/it]"
1112
+ ]
1113
+ },
1114
+ {
1115
+ "name": "stdout",
1116
+ "output_type": "stream",
1117
+ "text": [
1118
+ "πŸ’Ύ Progress saved after row 9530\n"
1119
+ ]
1120
+ },
1121
+ {
1122
+ "name": "stderr",
1123
+ "output_type": "stream",
1124
+ "text": [
1125
+ "Mistral Local: 2%|▏ | 750/42071 [25:52<27:09:24, 2.37s/it]"
1126
+ ]
1127
+ },
1128
+ {
1129
+ "name": "stdout",
1130
+ "output_type": "stream",
1131
+ "text": [
1132
+ "πŸ’Ύ Progress saved after row 9540\n"
1133
+ ]
1134
+ },
1135
+ {
1136
+ "name": "stderr",
1137
+ "output_type": "stream",
1138
+ "text": [
1139
+ "Mistral Local: 2%|▏ | 760/42071 [26:11<25:37:54, 2.23s/it]"
1140
+ ]
1141
+ },
1142
+ {
1143
+ "name": "stdout",
1144
+ "output_type": "stream",
1145
+ "text": [
1146
+ "πŸ’Ύ Progress saved after row 9550\n"
1147
+ ]
1148
+ },
1149
+ {
1150
+ "name": "stderr",
1151
+ "output_type": "stream",
1152
+ "text": [
1153
+ "Mistral Local: 2%|▏ | 770/42071 [26:31<27:00:30, 2.35s/it]"
1154
+ ]
1155
+ },
1156
+ {
1157
+ "name": "stdout",
1158
+ "output_type": "stream",
1159
+ "text": [
1160
+ "πŸ’Ύ Progress saved after row 9560\n"
1161
+ ]
1162
+ },
1163
+ {
1164
+ "name": "stderr",
1165
+ "output_type": "stream",
1166
+ "text": [
1167
+ "Mistral Local: 2%|▏ | 780/42071 [26:49<24:59:54, 2.18s/it]"
1168
+ ]
1169
+ },
1170
+ {
1171
+ "name": "stdout",
1172
+ "output_type": "stream",
1173
+ "text": [
1174
+ "πŸ’Ύ Progress saved after row 9570\n"
1175
+ ]
1176
+ },
1177
+ {
1178
+ "name": "stderr",
1179
+ "output_type": "stream",
1180
+ "text": [
1181
+ "Mistral Local: 2%|▏ | 790/42071 [27:10<30:40:18, 2.67s/it]"
1182
+ ]
1183
+ },
1184
+ {
1185
+ "name": "stdout",
1186
+ "output_type": "stream",
1187
+ "text": [
1188
+ "πŸ’Ύ Progress saved after row 9580\n"
1189
+ ]
1190
+ },
1191
+ {
1192
+ "name": "stderr",
1193
+ "output_type": "stream",
1194
+ "text": [
1195
+ "Mistral Local: 2%|▏ | 800/42071 [27:31<30:25:14, 2.65s/it]"
1196
+ ]
1197
+ },
1198
+ {
1199
+ "name": "stdout",
1200
+ "output_type": "stream",
1201
+ "text": [
1202
+ "πŸ’Ύ Progress saved after row 9590\n"
1203
+ ]
1204
+ },
1205
+ {
1206
+ "name": "stderr",
1207
+ "output_type": "stream",
1208
+ "text": [
1209
+ "Mistral Local: 2%|▏ | 810/42071 [27:51<28:53:15, 2.52s/it]"
1210
+ ]
1211
+ },
1212
+ {
1213
+ "name": "stdout",
1214
+ "output_type": "stream",
1215
+ "text": [
1216
+ "πŸ’Ύ Progress saved after row 9600\n"
1217
+ ]
1218
+ },
1219
+ {
1220
+ "name": "stderr",
1221
+ "output_type": "stream",
1222
+ "text": [
1223
+ "Mistral Local: 2%|▏ | 820/42071 [28:11<28:19:57, 2.47s/it]"
1224
+ ]
1225
+ },
1226
+ {
1227
+ "name": "stdout",
1228
+ "output_type": "stream",
1229
+ "text": [
1230
+ "πŸ’Ύ Progress saved after row 9610\n"
1231
+ ]
1232
+ },
1233
+ {
1234
+ "name": "stderr",
1235
+ "output_type": "stream",
1236
+ "text": [
1237
+ "Mistral Local: 2%|▏ | 830/42071 [28:31<26:49:31, 2.34s/it]"
1238
+ ]
1239
+ },
1240
+ {
1241
+ "name": "stdout",
1242
+ "output_type": "stream",
1243
+ "text": [
1244
+ "πŸ’Ύ Progress saved after row 9620\n"
1245
+ ]
1246
+ },
1247
+ {
1248
+ "name": "stderr",
1249
+ "output_type": "stream",
1250
+ "text": [
1251
+ "Mistral Local: 2%|▏ | 840/42071 [28:53<31:16:04, 2.73s/it]"
1252
+ ]
1253
+ },
1254
+ {
1255
+ "name": "stdout",
1256
+ "output_type": "stream",
1257
+ "text": [
1258
+ "πŸ’Ύ Progress saved after row 9630\n"
1259
+ ]
1260
+ },
1261
+ {
1262
+ "name": "stderr",
1263
+ "output_type": "stream",
1264
+ "text": [
1265
+ "Mistral Local: 2%|▏ | 850/42071 [29:14<29:41:08, 2.59s/it]"
1266
+ ]
1267
+ },
1268
+ {
1269
+ "name": "stdout",
1270
+ "output_type": "stream",
1271
+ "text": [
1272
+ "πŸ’Ύ Progress saved after row 9640\n"
1273
+ ]
1274
+ },
1275
+ {
1276
+ "name": "stderr",
1277
+ "output_type": "stream",
1278
+ "text": [
1279
+ "Mistral Local: 2%|▏ | 860/42071 [29:33<27:24:08, 2.39s/it]"
1280
+ ]
1281
+ },
1282
+ {
1283
+ "name": "stdout",
1284
+ "output_type": "stream",
1285
+ "text": [
1286
+ "πŸ’Ύ Progress saved after row 9650\n"
1287
+ ]
1288
+ },
1289
+ {
1290
+ "name": "stderr",
1291
+ "output_type": "stream",
1292
+ "text": [
1293
+ "Mistral Local: 2%|▏ | 870/42071 [29:55<29:04:09, 2.54s/it]"
1294
+ ]
1295
+ },
1296
+ {
1297
+ "name": "stdout",
1298
+ "output_type": "stream",
1299
+ "text": [
1300
+ "πŸ’Ύ Progress saved after row 9660\n"
1301
+ ]
1302
+ },
1303
+ {
1304
+ "name": "stderr",
1305
+ "output_type": "stream",
1306
+ "text": [
1307
+ "Mistral Local: 2%|▏ | 880/42071 [30:15<28:15:42, 2.47s/it]"
1308
+ ]
1309
+ },
1310
+ {
1311
+ "name": "stdout",
1312
+ "output_type": "stream",
1313
+ "text": [
1314
+ "πŸ’Ύ Progress saved after row 9670\n"
1315
+ ]
1316
+ },
1317
+ {
1318
+ "name": "stderr",
1319
+ "output_type": "stream",
1320
+ "text": [
1321
+ "Mistral Local: 2%|▏ | 890/42071 [30:35<27:52:10, 2.44s/it]"
1322
+ ]
1323
+ },
1324
+ {
1325
+ "name": "stdout",
1326
+ "output_type": "stream",
1327
+ "text": [
1328
+ "πŸ’Ύ Progress saved after row 9680\n"
1329
+ ]
1330
+ },
1331
+ {
1332
+ "name": "stderr",
1333
+ "output_type": "stream",
1334
+ "text": [
1335
+ "Mistral Local: 2%|▏ | 900/42071 [30:56<28:28:41, 2.49s/it]"
1336
+ ]
1337
+ },
1338
+ {
1339
+ "name": "stdout",
1340
+ "output_type": "stream",
1341
+ "text": [
1342
+ "πŸ’Ύ Progress saved after row 9690\n"
1343
+ ]
1344
+ },
1345
+ {
1346
+ "name": "stderr",
1347
+ "output_type": "stream",
1348
+ "text": [
1349
+ "Mistral Local: 2%|▏ | 910/42071 [31:19<27:07:56, 2.37s/it]"
1350
+ ]
1351
+ },
1352
+ {
1353
+ "name": "stdout",
1354
+ "output_type": "stream",
1355
+ "text": [
1356
+ "πŸ’Ύ Progress saved after row 9700\n"
1357
+ ]
1358
+ },
1359
+ {
1360
+ "name": "stderr",
1361
+ "output_type": "stream",
1362
+ "text": [
1363
+ "Mistral Local: 2%|▏ | 920/42071 [31:53<39:26:22, 3.45s/it]"
1364
+ ]
1365
+ },
1366
+ {
1367
+ "name": "stdout",
1368
+ "output_type": "stream",
1369
+ "text": [
1370
+ "πŸ’Ύ Progress saved after row 9710\n"
1371
+ ]
1372
+ },
1373
+ {
1374
+ "name": "stderr",
1375
+ "output_type": "stream",
1376
+ "text": [
1377
+ "Mistral Local: 2%|▏ | 930/42071 [32:18<36:31:49, 3.20s/it]"
1378
+ ]
1379
+ },
1380
+ {
1381
+ "name": "stdout",
1382
+ "output_type": "stream",
1383
+ "text": [
1384
+ "πŸ’Ύ Progress saved after row 9720\n"
1385
+ ]
1386
+ },
1387
+ {
1388
+ "name": "stderr",
1389
+ "output_type": "stream",
1390
+ "text": [
1391
+ "Mistral Local: 2%|▏ | 940/42071 [32:39<29:56:19, 2.62s/it]"
1392
+ ]
1393
+ },
1394
+ {
1395
+ "name": "stdout",
1396
+ "output_type": "stream",
1397
+ "text": [
1398
+ "πŸ’Ύ Progress saved after row 9730\n"
1399
+ ]
1400
+ },
1401
+ {
1402
+ "name": "stderr",
1403
+ "output_type": "stream",
1404
+ "text": [
1405
+ "Mistral Local: 2%|▏ | 950/42071 [32:59<28:41:17, 2.51s/it]"
1406
+ ]
1407
+ },
1408
+ {
1409
+ "name": "stdout",
1410
+ "output_type": "stream",
1411
+ "text": [
1412
+ "πŸ’Ύ Progress saved after row 9740\n"
1413
+ ]
1414
+ },
1415
+ {
1416
+ "name": "stderr",
1417
+ "output_type": "stream",
1418
+ "text": [
1419
+ "Mistral Local: 2%|▏ | 960/42071 [33:17<26:33:39, 2.33s/it]"
1420
+ ]
1421
+ },
1422
+ {
1423
+ "name": "stdout",
1424
+ "output_type": "stream",
1425
+ "text": [
1426
+ "πŸ’Ύ Progress saved after row 9750\n"
1427
+ ]
1428
+ },
1429
+ {
1430
+ "name": "stderr",
1431
+ "output_type": "stream",
1432
+ "text": [
1433
+ "Mistral Local: 2%|▏ | 970/42071 [33:36<27:48:54, 2.44s/it]"
1434
+ ]
1435
+ },
1436
+ {
1437
+ "name": "stdout",
1438
+ "output_type": "stream",
1439
+ "text": [
1440
+ "πŸ’Ύ Progress saved after row 9760\n"
1441
+ ]
1442
+ },
1443
+ {
1444
+ "name": "stderr",
1445
+ "output_type": "stream",
1446
+ "text": [
1447
+ "Mistral Local: 2%|▏ | 980/42071 [33:55<27:49:27, 2.44s/it]"
1448
+ ]
1449
+ },
1450
+ {
1451
+ "name": "stdout",
1452
+ "output_type": "stream",
1453
+ "text": [
1454
+ "πŸ’Ύ Progress saved after row 9770\n"
1455
+ ]
1456
+ },
1457
+ {
1458
+ "name": "stderr",
1459
+ "output_type": "stream",
1460
+ "text": [
1461
+ "Mistral Local: 2%|▏ | 990/42071 [34:17<28:25:06, 2.49s/it]"
1462
+ ]
1463
+ },
1464
+ {
1465
+ "name": "stdout",
1466
+ "output_type": "stream",
1467
+ "text": [
1468
+ "πŸ’Ύ Progress saved after row 9780\n"
1469
+ ]
1470
+ },
1471
+ {
1472
+ "name": "stderr",
1473
+ "output_type": "stream",
1474
+ "text": [
1475
+ "Mistral Local: 2%|▏ | 1000/42071 [34:38<29:39:06, 2.60s/it]"
1476
+ ]
1477
+ },
1478
+ {
1479
+ "name": "stdout",
1480
+ "output_type": "stream",
1481
+ "text": [
1482
+ "πŸ’Ύ Progress saved after row 9790\n"
1483
+ ]
1484
+ },
1485
+ {
1486
+ "name": "stderr",
1487
+ "output_type": "stream",
1488
+ "text": [
1489
+ "Mistral Local: 2%|▏ | 1010/42071 [35:00<26:58:20, 2.36s/it]"
1490
+ ]
1491
+ },
1492
+ {
1493
+ "name": "stdout",
1494
+ "output_type": "stream",
1495
+ "text": [
1496
+ "πŸ’Ύ Progress saved after row 9800\n"
1497
+ ]
1498
+ },
1499
+ {
1500
+ "name": "stderr",
1501
+ "output_type": "stream",
1502
+ "text": [
1503
+ "Mistral Local: 2%|▏ | 1020/42071 [35:21<28:52:02, 2.53s/it]"
1504
+ ]
1505
+ },
1506
+ {
1507
+ "name": "stdout",
1508
+ "output_type": "stream",
1509
+ "text": [
1510
+ "πŸ’Ύ Progress saved after row 9810\n"
1511
+ ]
1512
+ },
1513
+ {
1514
+ "name": "stderr",
1515
+ "output_type": "stream",
1516
+ "text": [
1517
+ "Mistral Local: 2%|▏ | 1030/42071 [35:42<27:38:16, 2.42s/it]"
1518
+ ]
1519
+ },
1520
+ {
1521
+ "name": "stdout",
1522
+ "output_type": "stream",
1523
+ "text": [
1524
+ "πŸ’Ύ Progress saved after row 9820\n"
1525
+ ]
1526
+ },
1527
+ {
1528
+ "name": "stderr",
1529
+ "output_type": "stream",
1530
+ "text": [
1531
+ "Mistral Local: 2%|▏ | 1040/42071 [36:04<28:46:01, 2.52s/it]"
1532
+ ]
1533
+ },
1534
+ {
1535
+ "name": "stdout",
1536
+ "output_type": "stream",
1537
+ "text": [
1538
+ "πŸ’Ύ Progress saved after row 9830\n"
1539
+ ]
1540
+ },
1541
+ {
1542
+ "name": "stderr",
1543
+ "output_type": "stream",
1544
+ "text": [
1545
+ "Mistral Local: 2%|▏ | 1050/42071 [36:27<29:11:36, 2.56s/it]"
1546
+ ]
1547
+ },
1548
+ {
1549
+ "name": "stdout",
1550
+ "output_type": "stream",
1551
+ "text": [
1552
+ "πŸ’Ύ Progress saved after row 9840\n"
1553
+ ]
1554
+ },
1555
+ {
1556
+ "name": "stderr",
1557
+ "output_type": "stream",
1558
+ "text": [
1559
+ "Mistral Local: 3%|β–Ž | 1060/42071 [36:50<32:38:56, 2.87s/it]"
1560
+ ]
1561
+ },
1562
+ {
1563
+ "name": "stdout",
1564
+ "output_type": "stream",
1565
+ "text": [
1566
+ "πŸ’Ύ Progress saved after row 9850\n"
1567
+ ]
1568
+ },
1569
+ {
1570
+ "name": "stderr",
1571
+ "output_type": "stream",
1572
+ "text": [
1573
+ "Mistral Local: 3%|β–Ž | 1070/42071 [37:13<34:34:54, 3.04s/it]"
1574
+ ]
1575
+ },
1576
+ {
1577
+ "name": "stdout",
1578
+ "output_type": "stream",
1579
+ "text": [
1580
+ "πŸ’Ύ Progress saved after row 9860\n"
1581
+ ]
1582
+ },
1583
+ {
1584
+ "name": "stderr",
1585
+ "output_type": "stream",
1586
+ "text": [
1587
+ "Mistral Local: 3%|β–Ž | 1080/42071 [37:33<24:58:04, 2.19s/it]"
1588
+ ]
1589
+ },
1590
+ {
1591
+ "name": "stdout",
1592
+ "output_type": "stream",
1593
+ "text": [
1594
+ "πŸ’Ύ Progress saved after row 9870\n"
1595
+ ]
1596
+ },
1597
+ {
1598
+ "name": "stderr",
1599
+ "output_type": "stream",
1600
+ "text": [
1601
+ "Mistral Local: 3%|β–Ž | 1090/42071 [37:54<26:10:04, 2.30s/it]"
1602
+ ]
1603
+ },
1604
+ {
1605
+ "name": "stdout",
1606
+ "output_type": "stream",
1607
+ "text": [
1608
+ "πŸ’Ύ Progress saved after row 9880\n"
1609
+ ]
1610
+ },
1611
+ {
1612
+ "name": "stderr",
1613
+ "output_type": "stream",
1614
+ "text": [
1615
+ "Mistral Local: 3%|β–Ž | 1100/42071 [38:14<27:58:06, 2.46s/it]"
1616
+ ]
1617
+ },
1618
+ {
1619
+ "name": "stdout",
1620
+ "output_type": "stream",
1621
+ "text": [
1622
+ "πŸ’Ύ Progress saved after row 9890\n"
1623
+ ]
1624
+ },
1625
+ {
1626
+ "name": "stderr",
1627
+ "output_type": "stream",
1628
+ "text": [
1629
+ "Mistral Local: 3%|β–Ž | 1110/42071 [38:33<26:39:34, 2.34s/it]"
1630
+ ]
1631
+ },
1632
+ {
1633
+ "name": "stdout",
1634
+ "output_type": "stream",
1635
+ "text": [
1636
+ "πŸ’Ύ Progress saved after row 9900\n"
1637
+ ]
1638
+ },
1639
+ {
1640
+ "name": "stderr",
1641
+ "output_type": "stream",
1642
+ "text": [
1643
+ "Mistral Local: 3%|β–Ž | 1120/42071 [38:52<27:28:26, 2.42s/it]"
1644
+ ]
1645
+ },
1646
+ {
1647
+ "name": "stdout",
1648
+ "output_type": "stream",
1649
+ "text": [
1650
+ "πŸ’Ύ Progress saved after row 9910\n"
1651
+ ]
1652
+ },
1653
+ {
1654
+ "name": "stderr",
1655
+ "output_type": "stream",
1656
+ "text": [
1657
+ "Mistral Local: 3%|β–Ž | 1130/42071 [39:14<29:49:35, 2.62s/it]"
1658
+ ]
1659
+ },
1660
+ {
1661
+ "name": "stdout",
1662
+ "output_type": "stream",
1663
+ "text": [
1664
+ "πŸ’Ύ Progress saved after row 9920\n"
1665
+ ]
1666
+ },
1667
+ {
1668
+ "name": "stderr",
1669
+ "output_type": "stream",
1670
+ "text": [
1671
+ "Mistral Local: 3%|β–Ž | 1140/42071 [39:33<26:01:58, 2.29s/it]"
1672
+ ]
1673
+ },
1674
+ {
1675
+ "name": "stdout",
1676
+ "output_type": "stream",
1677
+ "text": [
1678
+ "πŸ’Ύ Progress saved after row 9930\n"
1679
+ ]
1680
+ },
1681
+ {
1682
+ "name": "stderr",
1683
+ "output_type": "stream",
1684
+ "text": [
1685
+ "Mistral Local: 3%|β–Ž | 1150/42071 [39:55<27:55:10, 2.46s/it]"
1686
+ ]
1687
+ },
1688
+ {
1689
+ "name": "stdout",
1690
+ "output_type": "stream",
1691
+ "text": [
1692
+ "πŸ’Ύ Progress saved after row 9940\n"
1693
+ ]
1694
+ },
1695
+ {
1696
+ "name": "stderr",
1697
+ "output_type": "stream",
1698
+ "text": [
1699
+ "Mistral Local: 3%|β–Ž | 1160/42071 [40:17<29:34:52, 2.60s/it]"
1700
+ ]
1701
+ },
1702
+ {
1703
+ "name": "stdout",
1704
+ "output_type": "stream",
1705
+ "text": [
1706
+ "πŸ’Ύ Progress saved after row 9950\n"
1707
+ ]
1708
+ },
1709
+ {
1710
+ "name": "stderr",
1711
+ "output_type": "stream",
1712
+ "text": [
1713
+ "Mistral Local: 3%|β–Ž | 1170/42071 [40:36<26:16:52, 2.31s/it]"
1714
+ ]
1715
+ },
1716
+ {
1717
+ "name": "stdout",
1718
+ "output_type": "stream",
1719
+ "text": [
1720
+ "πŸ’Ύ Progress saved after row 9960\n"
1721
+ ]
1722
+ },
1723
+ {
1724
+ "name": "stderr",
1725
+ "output_type": "stream",
1726
+ "text": [
1727
+ "Mistral Local: 3%|β–Ž | 1180/42071 [40:56<26:20:08, 2.32s/it]"
1728
+ ]
1729
+ },
1730
+ {
1731
+ "name": "stdout",
1732
+ "output_type": "stream",
1733
+ "text": [
1734
+ "πŸ’Ύ Progress saved after row 9970\n"
1735
+ ]
1736
+ },
1737
+ {
1738
+ "name": "stderr",
1739
+ "output_type": "stream",
1740
+ "text": [
1741
+ "Mistral Local: 3%|β–Ž | 1190/42071 [41:15<27:37:16, 2.43s/it]"
1742
+ ]
1743
+ },
1744
+ {
1745
+ "name": "stdout",
1746
+ "output_type": "stream",
1747
+ "text": [
1748
+ "πŸ’Ύ Progress saved after row 9980\n"
1749
+ ]
1750
+ },
1751
+ {
1752
+ "name": "stderr",
1753
+ "output_type": "stream",
1754
+ "text": [
1755
+ "Mistral Local: 3%|β–Ž | 1200/42071 [41:37<29:51:54, 2.63s/it]"
1756
+ ]
1757
+ },
1758
+ {
1759
+ "name": "stdout",
1760
+ "output_type": "stream",
1761
+ "text": [
1762
+ "πŸ’Ύ Progress saved after row 9990\n"
1763
+ ]
1764
+ },
1765
+ {
1766
+ "name": "stderr",
1767
+ "output_type": "stream",
1768
+ "text": [
1769
+ "Mistral Local: 3%|β–Ž | 1210/42071 [42:00<30:40:11, 2.70s/it]"
1770
+ ]
1771
+ },
1772
+ {
1773
+ "name": "stdout",
1774
+ "output_type": "stream",
1775
+ "text": [
1776
+ "πŸ’Ύ Progress saved after row 10000\n"
1777
+ ]
1778
+ },
1779
+ {
1780
+ "name": "stderr",
1781
+ "output_type": "stream",
1782
+ "text": [
1783
+ "Mistral Local: 3%|β–Ž | 1220/42071 [42:25<39:44:45, 3.50s/it]"
1784
+ ]
1785
+ },
1786
+ {
1787
+ "name": "stdout",
1788
+ "output_type": "stream",
1789
+ "text": [
1790
+ "πŸ’Ύ Progress saved after row 10010\n"
1791
+ ]
1792
+ },
1793
+ {
1794
+ "name": "stderr",
1795
+ "output_type": "stream",
1796
+ "text": [
1797
+ "Mistral Local: 3%|β–Ž | 1230/42071 [42:45<27:05:26, 2.39s/it]"
1798
+ ]
1799
+ },
1800
+ {
1801
+ "name": "stdout",
1802
+ "output_type": "stream",
1803
+ "text": [
1804
+ "πŸ’Ύ Progress saved after row 10020\n"
1805
+ ]
1806
+ },
1807
+ {
1808
+ "name": "stderr",
1809
+ "output_type": "stream",
1810
+ "text": [
1811
+ "Mistral Local: 3%|β–Ž | 1240/42071 [43:07<28:36:46, 2.52s/it]"
1812
+ ]
1813
+ },
1814
+ {
1815
+ "name": "stdout",
1816
+ "output_type": "stream",
1817
+ "text": [
1818
+ "πŸ’Ύ Progress saved after row 10030\n"
1819
+ ]
1820
+ },
1821
+ {
1822
+ "name": "stderr",
1823
+ "output_type": "stream",
1824
+ "text": [
1825
+ "Mistral Local: 3%|β–Ž | 1250/42071 [43:26<27:06:25, 2.39s/it]"
1826
+ ]
1827
+ },
1828
+ {
1829
+ "name": "stdout",
1830
+ "output_type": "stream",
1831
+ "text": [
1832
+ "πŸ’Ύ Progress saved after row 10040\n"
1833
+ ]
1834
+ },
1835
+ {
1836
+ "name": "stderr",
1837
+ "output_type": "stream",
1838
+ "text": [
1839
+ "Mistral Local: 3%|β–Ž | 1260/42071 [43:45<27:13:15, 2.40s/it]"
1840
+ ]
1841
+ },
1842
+ {
1843
+ "name": "stdout",
1844
+ "output_type": "stream",
1845
+ "text": [
1846
+ "πŸ’Ύ Progress saved after row 10050\n"
1847
+ ]
1848
+ },
1849
+ {
1850
+ "name": "stderr",
1851
+ "output_type": "stream",
1852
+ "text": [
1853
+ "Mistral Local: 3%|β–Ž | 1270/42071 [44:04<27:38:57, 2.44s/it]"
1854
+ ]
1855
+ },
1856
+ {
1857
+ "name": "stdout",
1858
+ "output_type": "stream",
1859
+ "text": [
1860
+ "πŸ’Ύ Progress saved after row 10060\n"
1861
+ ]
1862
+ },
1863
+ {
1864
+ "name": "stderr",
1865
+ "output_type": "stream",
1866
+ "text": [
1867
+ "Mistral Local: 3%|β–Ž | 1280/42071 [44:23<25:33:36, 2.26s/it]"
1868
+ ]
1869
+ },
1870
+ {
1871
+ "name": "stdout",
1872
+ "output_type": "stream",
1873
+ "text": [
1874
+ "πŸ’Ύ Progress saved after row 10070\n"
1875
+ ]
1876
+ },
1877
+ {
1878
+ "name": "stderr",
1879
+ "output_type": "stream",
1880
+ "text": [
1881
+ "Mistral Local: 3%|β–Ž | 1290/42071 [44:43<28:33:36, 2.52s/it]"
1882
+ ]
1883
+ },
1884
+ {
1885
+ "name": "stdout",
1886
+ "output_type": "stream",
1887
+ "text": [
1888
+ "πŸ’Ύ Progress saved after row 10080\n"
1889
+ ]
1890
+ },
1891
+ {
1892
+ "name": "stderr",
1893
+ "output_type": "stream",
1894
+ "text": [
1895
+ "Mistral Local: 3%|β–Ž | 1300/42071 [45:03<27:43:28, 2.45s/it]"
1896
+ ]
1897
+ },
1898
+ {
1899
+ "name": "stdout",
1900
+ "output_type": "stream",
1901
+ "text": [
1902
+ "πŸ’Ύ Progress saved after row 10090\n"
1903
+ ]
1904
+ },
1905
+ {
1906
+ "name": "stderr",
1907
+ "output_type": "stream",
1908
+ "text": [
1909
+ "Mistral Local: 3%|β–Ž | 1310/42071 [45:23<28:06:46, 2.48s/it]"
1910
+ ]
1911
+ },
1912
+ {
1913
+ "name": "stdout",
1914
+ "output_type": "stream",
1915
+ "text": [
1916
+ "πŸ’Ύ Progress saved after row 10100\n"
1917
+ ]
1918
+ },
1919
+ {
1920
+ "name": "stderr",
1921
+ "output_type": "stream",
1922
+ "text": [
1923
+ "Mistral Local: 3%|β–Ž | 1320/42071 [45:45<29:54:07, 2.64s/it]"
1924
+ ]
1925
+ },
1926
+ {
1927
+ "name": "stdout",
1928
+ "output_type": "stream",
1929
+ "text": [
1930
+ "πŸ’Ύ Progress saved after row 10110\n"
1931
+ ]
1932
+ },
1933
+ {
1934
+ "name": "stderr",
1935
+ "output_type": "stream",
1936
+ "text": [
1937
+ "Mistral Local: 3%|β–Ž | 1330/42071 [46:07<28:03:02, 2.48s/it]"
1938
+ ]
1939
+ },
1940
+ {
1941
+ "name": "stdout",
1942
+ "output_type": "stream",
1943
+ "text": [
1944
+ "πŸ’Ύ Progress saved after row 10120\n"
1945
+ ]
1946
+ },
1947
+ {
1948
+ "name": "stderr",
1949
+ "output_type": "stream",
1950
+ "text": [
1951
+ "Mistral Local: 3%|β–Ž | 1340/42071 [46:29<29:45:30, 2.63s/it]"
1952
+ ]
1953
+ },
1954
+ {
1955
+ "name": "stdout",
1956
+ "output_type": "stream",
1957
+ "text": [
1958
+ "πŸ’Ύ Progress saved after row 10130\n"
1959
+ ]
1960
+ },
1961
+ {
1962
+ "name": "stderr",
1963
+ "output_type": "stream",
1964
+ "text": [
1965
+ "Mistral Local: 3%|β–Ž | 1350/42071 [46:51<25:53:02, 2.29s/it]"
1966
+ ]
1967
+ },
1968
+ {
1969
+ "name": "stdout",
1970
+ "output_type": "stream",
1971
+ "text": [
1972
+ "πŸ’Ύ Progress saved after row 10140\n"
1973
+ ]
1974
+ },
1975
+ {
1976
+ "name": "stderr",
1977
+ "output_type": "stream",
1978
+ "text": [
1979
+ "Mistral Local: 3%|β–Ž | 1360/42071 [47:11<25:51:37, 2.29s/it]"
1980
+ ]
1981
+ },
1982
+ {
1983
+ "name": "stdout",
1984
+ "output_type": "stream",
1985
+ "text": [
1986
+ "πŸ’Ύ Progress saved after row 10150\n"
1987
+ ]
1988
+ },
1989
+ {
1990
+ "name": "stderr",
1991
+ "output_type": "stream",
1992
+ "text": [
1993
+ "Mistral Local: 3%|β–Ž | 1370/42071 [47:33<32:36:57, 2.88s/it]"
1994
+ ]
1995
+ },
1996
+ {
1997
+ "name": "stdout",
1998
+ "output_type": "stream",
1999
+ "text": [
2000
+ "πŸ’Ύ Progress saved after row 10160\n"
2001
+ ]
2002
+ },
2003
+ {
2004
+ "name": "stderr",
2005
+ "output_type": "stream",
2006
+ "text": [
2007
+ "Mistral Local: 3%|β–Ž | 1380/42071 [47:52<25:32:45, 2.26s/it]"
2008
+ ]
2009
+ },
2010
+ {
2011
+ "name": "stdout",
2012
+ "output_type": "stream",
2013
+ "text": [
2014
+ "πŸ’Ύ Progress saved after row 10170\n"
2015
+ ]
2016
+ },
2017
+ {
2018
+ "name": "stderr",
2019
+ "output_type": "stream",
2020
+ "text": [
2021
+ "Mistral Local: 3%|β–Ž | 1390/42071 [48:10<26:03:37, 2.31s/it]"
2022
+ ]
2023
+ },
2024
+ {
2025
+ "name": "stdout",
2026
+ "output_type": "stream",
2027
+ "text": [
2028
+ "πŸ’Ύ Progress saved after row 10180\n"
2029
+ ]
2030
+ },
2031
+ {
2032
+ "name": "stderr",
2033
+ "output_type": "stream",
2034
+ "text": [
2035
+ "Mistral Local: 3%|β–Ž | 1400/42071 [48:31<29:37:43, 2.62s/it]"
2036
+ ]
2037
+ },
2038
+ {
2039
+ "name": "stdout",
2040
+ "output_type": "stream",
2041
+ "text": [
2042
+ "πŸ’Ύ Progress saved after row 10190\n"
2043
+ ]
2044
+ },
2045
+ {
2046
+ "name": "stderr",
2047
+ "output_type": "stream",
2048
+ "text": [
2049
+ "Mistral Local: 3%|β–Ž | 1410/42071 [48:53<26:32:48, 2.35s/it]"
2050
+ ]
2051
+ },
2052
+ {
2053
+ "name": "stdout",
2054
+ "output_type": "stream",
2055
+ "text": [
2056
+ "πŸ’Ύ Progress saved after row 10200\n"
2057
+ ]
2058
+ },
2059
+ {
2060
+ "name": "stderr",
2061
+ "output_type": "stream",
2062
+ "text": [
2063
+ "Mistral Local: 3%|β–Ž | 1420/42071 [49:12<25:33:11, 2.26s/it]"
2064
+ ]
2065
+ },
2066
+ {
2067
+ "name": "stdout",
2068
+ "output_type": "stream",
2069
+ "text": [
2070
+ "πŸ’Ύ Progress saved after row 10210\n"
2071
+ ]
2072
+ },
2073
+ {
2074
+ "name": "stderr",
2075
+ "output_type": "stream",
2076
+ "text": [
2077
+ "Mistral Local: 3%|β–Ž | 1430/42071 [49:32<26:27:44, 2.34s/it]"
2078
+ ]
2079
+ },
2080
+ {
2081
+ "name": "stdout",
2082
+ "output_type": "stream",
2083
+ "text": [
2084
+ "πŸ’Ύ Progress saved after row 10220\n"
2085
+ ]
2086
+ },
2087
+ {
2088
+ "name": "stderr",
2089
+ "output_type": "stream",
2090
+ "text": [
2091
+ "Mistral Local: 3%|β–Ž | 1440/42071 [49:52<26:42:31, 2.37s/it]"
2092
+ ]
2093
+ },
2094
+ {
2095
+ "name": "stdout",
2096
+ "output_type": "stream",
2097
+ "text": [
2098
+ "πŸ’Ύ Progress saved after row 10230\n"
2099
+ ]
2100
+ },
2101
+ {
2102
+ "name": "stderr",
2103
+ "output_type": "stream",
2104
+ "text": [
2105
+ "Mistral Local: 3%|β–Ž | 1450/42071 [50:14<31:28:17, 2.79s/it]"
2106
+ ]
2107
+ },
2108
+ {
2109
+ "name": "stdout",
2110
+ "output_type": "stream",
2111
+ "text": [
2112
+ "πŸ’Ύ Progress saved after row 10240\n"
2113
+ ]
2114
+ },
2115
+ {
2116
+ "name": "stderr",
2117
+ "output_type": "stream",
2118
+ "text": [
2119
+ "Mistral Local: 3%|β–Ž | 1460/42071 [50:34<28:30:12, 2.53s/it]"
2120
+ ]
2121
+ },
2122
+ {
2123
+ "name": "stdout",
2124
+ "output_type": "stream",
2125
+ "text": [
2126
+ "πŸ’Ύ Progress saved after row 10250\n"
2127
+ ]
2128
+ },
2129
+ {
2130
+ "name": "stderr",
2131
+ "output_type": "stream",
2132
+ "text": [
2133
+ "Mistral Local: 3%|β–Ž | 1470/42071 [50:53<25:55:24, 2.30s/it]"
2134
+ ]
2135
+ },
2136
+ {
2137
+ "name": "stdout",
2138
+ "output_type": "stream",
2139
+ "text": [
2140
+ "πŸ’Ύ Progress saved after row 10260\n"
2141
+ ]
2142
+ },
2143
+ {
2144
+ "name": "stderr",
2145
+ "output_type": "stream",
2146
+ "text": [
2147
+ "Mistral Local: 4%|β–Ž | 1480/42071 [51:13<26:01:28, 2.31s/it]"
2148
+ ]
2149
+ },
2150
+ {
2151
+ "name": "stdout",
2152
+ "output_type": "stream",
2153
+ "text": [
2154
+ "πŸ’Ύ Progress saved after row 10270\n"
2155
+ ]
2156
+ },
2157
+ {
2158
+ "name": "stderr",
2159
+ "output_type": "stream",
2160
+ "text": [
2161
+ "Mistral Local: 4%|β–Ž | 1490/42071 [51:31<26:06:37, 2.32s/it]"
2162
+ ]
2163
+ },
2164
+ {
2165
+ "name": "stdout",
2166
+ "output_type": "stream",
2167
+ "text": [
2168
+ "πŸ’Ύ Progress saved after row 10280\n"
2169
+ ]
2170
+ },
2171
+ {
2172
+ "name": "stderr",
2173
+ "output_type": "stream",
2174
+ "text": [
2175
+ "Mistral Local: 4%|β–Ž | 1500/42071 [51:50<25:25:45, 2.26s/it]"
2176
+ ]
2177
+ },
2178
+ {
2179
+ "name": "stdout",
2180
+ "output_type": "stream",
2181
+ "text": [
2182
+ "πŸ’Ύ Progress saved after row 10290\n"
2183
+ ]
2184
+ },
2185
+ {
2186
+ "name": "stderr",
2187
+ "output_type": "stream",
2188
+ "text": [
2189
+ "Mistral Local: 4%|β–Ž | 1510/42071 [52:11<27:24:03, 2.43s/it]"
2190
+ ]
2191
+ },
2192
+ {
2193
+ "name": "stdout",
2194
+ "output_type": "stream",
2195
+ "text": [
2196
+ "πŸ’Ύ Progress saved after row 10300\n"
2197
+ ]
2198
+ },
2199
+ {
2200
+ "name": "stderr",
2201
+ "output_type": "stream",
2202
+ "text": [
2203
+ "Mistral Local: 4%|β–Ž | 1520/42071 [52:31<27:24:13, 2.43s/it]"
2204
+ ]
2205
+ },
2206
+ {
2207
+ "name": "stdout",
2208
+ "output_type": "stream",
2209
+ "text": [
2210
+ "πŸ’Ύ Progress saved after row 10310\n"
2211
+ ]
2212
+ },
2213
+ {
2214
+ "name": "stderr",
2215
+ "output_type": "stream",
2216
+ "text": [
2217
+ "Mistral Local: 4%|β–Ž | 1530/42071 [52:53<25:51:08, 2.30s/it]"
2218
+ ]
2219
+ },
2220
+ {
2221
+ "name": "stdout",
2222
+ "output_type": "stream",
2223
+ "text": [
2224
+ "πŸ’Ύ Progress saved after row 10320\n"
2225
+ ]
2226
+ },
2227
+ {
2228
+ "name": "stderr",
2229
+ "output_type": "stream",
2230
+ "text": [
2231
+ "Mistral Local: 4%|β–Ž | 1540/42071 [53:15<27:53:16, 2.48s/it]"
2232
+ ]
2233
+ },
2234
+ {
2235
+ "name": "stdout",
2236
+ "output_type": "stream",
2237
+ "text": [
2238
+ "πŸ’Ύ Progress saved after row 10330\n"
2239
+ ]
2240
+ },
2241
+ {
2242
+ "name": "stderr",
2243
+ "output_type": "stream",
2244
+ "text": [
2245
+ "Mistral Local: 4%|β–Ž | 1550/42071 [53:35<28:24:31, 2.52s/it]"
2246
+ ]
2247
+ },
2248
+ {
2249
+ "name": "stdout",
2250
+ "output_type": "stream",
2251
+ "text": [
2252
+ "πŸ’Ύ Progress saved after row 10340\n"
2253
+ ]
2254
+ },
2255
+ {
2256
+ "name": "stderr",
2257
+ "output_type": "stream",
2258
+ "text": [
2259
+ "Mistral Local: 4%|β–Ž | 1560/42071 [53:53<24:07:14, 2.14s/it]"
2260
+ ]
2261
+ },
2262
+ {
2263
+ "name": "stdout",
2264
+ "output_type": "stream",
2265
+ "text": [
2266
+ "πŸ’Ύ Progress saved after row 10350\n"
2267
+ ]
2268
+ },
2269
+ {
2270
+ "name": "stderr",
2271
+ "output_type": "stream",
2272
+ "text": [
2273
+ "Mistral Local: 4%|β–Ž | 1570/42071 [54:14<29:19:36, 2.61s/it]"
2274
+ ]
2275
+ },
2276
+ {
2277
+ "name": "stdout",
2278
+ "output_type": "stream",
2279
+ "text": [
2280
+ "πŸ’Ύ Progress saved after row 10360\n"
2281
+ ]
2282
+ },
2283
+ {
2284
+ "name": "stderr",
2285
+ "output_type": "stream",
2286
+ "text": [
2287
+ "Mistral Local: 4%|▍ | 1580/42071 [54:35<27:11:59, 2.42s/it]"
2288
+ ]
2289
+ },
2290
+ {
2291
+ "name": "stdout",
2292
+ "output_type": "stream",
2293
+ "text": [
2294
+ "πŸ’Ύ Progress saved after row 10370\n"
2295
+ ]
2296
+ },
2297
+ {
2298
+ "name": "stderr",
2299
+ "output_type": "stream",
2300
+ "text": [
2301
+ "Mistral Local: 4%|▍ | 1590/42071 [54:56<27:59:16, 2.49s/it]"
2302
+ ]
2303
+ },
2304
+ {
2305
+ "name": "stdout",
2306
+ "output_type": "stream",
2307
+ "text": [
2308
+ "πŸ’Ύ Progress saved after row 10380\n"
2309
+ ]
2310
+ },
2311
+ {
2312
+ "name": "stderr",
2313
+ "output_type": "stream",
2314
+ "text": [
2315
+ "Mistral Local: 4%|▍ | 1600/42071 [55:15<27:38:15, 2.46s/it]"
2316
+ ]
2317
+ },
2318
+ {
2319
+ "name": "stdout",
2320
+ "output_type": "stream",
2321
+ "text": [
2322
+ "πŸ’Ύ Progress saved after row 10390\n"
2323
+ ]
2324
+ },
2325
+ {
2326
+ "name": "stderr",
2327
+ "output_type": "stream",
2328
+ "text": [
2329
+ "Mistral Local: 4%|▍ | 1610/42071 [55:39<29:13:06, 2.60s/it]"
2330
+ ]
2331
+ },
2332
+ {
2333
+ "name": "stdout",
2334
+ "output_type": "stream",
2335
+ "text": [
2336
+ "πŸ’Ύ Progress saved after row 10400\n"
2337
+ ]
2338
+ },
2339
+ {
2340
+ "name": "stderr",
2341
+ "output_type": "stream",
2342
+ "text": [
2343
+ "Mistral Local: 4%|▍ | 1620/42071 [55:58<27:14:23, 2.42s/it]"
2344
+ ]
2345
+ },
2346
+ {
2347
+ "name": "stdout",
2348
+ "output_type": "stream",
2349
+ "text": [
2350
+ "πŸ’Ύ Progress saved after row 10410\n"
2351
+ ]
2352
+ },
2353
+ {
2354
+ "name": "stderr",
2355
+ "output_type": "stream",
2356
+ "text": [
2357
+ "Mistral Local: 4%|▍ | 1630/42071 [56:20<29:34:50, 2.63s/it]"
2358
+ ]
2359
+ },
2360
+ {
2361
+ "name": "stdout",
2362
+ "output_type": "stream",
2363
+ "text": [
2364
+ "πŸ’Ύ Progress saved after row 10420\n"
2365
+ ]
2366
+ },
2367
+ {
2368
+ "name": "stderr",
2369
+ "output_type": "stream",
2370
+ "text": [
2371
+ "Mistral Local: 4%|▍ | 1640/42071 [56:41<28:50:48, 2.57s/it]"
2372
+ ]
2373
+ },
2374
+ {
2375
+ "name": "stdout",
2376
+ "output_type": "stream",
2377
+ "text": [
2378
+ "πŸ’Ύ Progress saved after row 10430\n"
2379
+ ]
2380
+ },
2381
+ {
2382
+ "name": "stderr",
2383
+ "output_type": "stream",
2384
+ "text": [
2385
+ "Mistral Local: 4%|▍ | 1650/42071 [57:01<27:25:49, 2.44s/it]"
2386
+ ]
2387
+ },
2388
+ {
2389
+ "name": "stdout",
2390
+ "output_type": "stream",
2391
+ "text": [
2392
+ "πŸ’Ύ Progress saved after row 10440\n"
2393
+ ]
2394
+ },
2395
+ {
2396
+ "name": "stderr",
2397
+ "output_type": "stream",
2398
+ "text": [
2399
+ "Mistral Local: 4%|▍ | 1660/42071 [57:24<29:58:02, 2.67s/it]"
2400
+ ]
2401
+ },
2402
+ {
2403
+ "name": "stdout",
2404
+ "output_type": "stream",
2405
+ "text": [
2406
+ "πŸ’Ύ Progress saved after row 10450\n"
2407
+ ]
2408
+ },
2409
+ {
2410
+ "name": "stderr",
2411
+ "output_type": "stream",
2412
+ "text": [
2413
+ "Mistral Local: 4%|▍ | 1670/42071 [57:45<30:44:36, 2.74s/it]"
2414
+ ]
2415
+ },
2416
+ {
2417
+ "name": "stdout",
2418
+ "output_type": "stream",
2419
+ "text": [
2420
+ "πŸ’Ύ Progress saved after row 10460\n"
2421
+ ]
2422
+ },
2423
+ {
2424
+ "name": "stderr",
2425
+ "output_type": "stream",
2426
+ "text": [
2427
+ "Mistral Local: 4%|▍ | 1680/42071 [58:05<27:03:06, 2.41s/it]"
2428
+ ]
2429
+ },
2430
+ {
2431
+ "name": "stdout",
2432
+ "output_type": "stream",
2433
+ "text": [
2434
+ "πŸ’Ύ Progress saved after row 10470\n"
2435
+ ]
2436
+ },
2437
+ {
2438
+ "name": "stderr",
2439
+ "output_type": "stream",
2440
+ "text": [
2441
+ "Mistral Local: 4%|▍ | 1690/42071 [58:26<27:52:00, 2.48s/it]"
2442
+ ]
2443
+ },
2444
+ {
2445
+ "name": "stdout",
2446
+ "output_type": "stream",
2447
+ "text": [
2448
+ "πŸ’Ύ Progress saved after row 10480\n"
2449
+ ]
2450
+ },
2451
+ {
2452
+ "name": "stderr",
2453
+ "output_type": "stream",
2454
+ "text": [
2455
+ "Mistral Local: 4%|▍ | 1700/42071 [58:47<28:32:42, 2.55s/it]"
2456
+ ]
2457
+ },
2458
+ {
2459
+ "name": "stdout",
2460
+ "output_type": "stream",
2461
+ "text": [
2462
+ "πŸ’Ύ Progress saved after row 10490\n"
2463
+ ]
2464
+ },
2465
+ {
2466
+ "name": "stderr",
2467
+ "output_type": "stream",
2468
+ "text": [
2469
+ "Mistral Local: 4%|▍ | 1710/42071 [59:08<29:30:02, 2.63s/it]"
2470
+ ]
2471
+ },
2472
+ {
2473
+ "name": "stdout",
2474
+ "output_type": "stream",
2475
+ "text": [
2476
+ "πŸ’Ύ Progress saved after row 10500\n"
2477
+ ]
2478
+ },
2479
+ {
2480
+ "name": "stderr",
2481
+ "output_type": "stream",
2482
+ "text": [
2483
+ "Mistral Local: 4%|▍ | 1720/42071 [59:30<29:16:09, 2.61s/it]"
2484
+ ]
2485
+ },
2486
+ {
2487
+ "name": "stdout",
2488
+ "output_type": "stream",
2489
+ "text": [
2490
+ "πŸ’Ύ Progress saved after row 10510\n"
2491
+ ]
2492
+ },
2493
+ {
2494
+ "name": "stderr",
2495
+ "output_type": "stream",
2496
+ "text": [
2497
+ "Mistral Local: 4%|▍ | 1730/42071 [59:50<28:16:11, 2.52s/it]"
2498
+ ]
2499
+ },
2500
+ {
2501
+ "name": "stdout",
2502
+ "output_type": "stream",
2503
+ "text": [
2504
+ "πŸ’Ύ Progress saved after row 10520\n"
2505
+ ]
2506
+ },
2507
+ {
2508
+ "name": "stderr",
2509
+ "output_type": "stream",
2510
+ "text": [
2511
+ "Mistral Local: 4%|▍ | 1740/42071 [1:00:11<28:16:09, 2.52s/it]"
2512
+ ]
2513
+ },
2514
+ {
2515
+ "name": "stdout",
2516
+ "output_type": "stream",
2517
+ "text": [
2518
+ "πŸ’Ύ Progress saved after row 10530\n"
2519
+ ]
2520
+ },
2521
+ {
2522
+ "name": "stderr",
2523
+ "output_type": "stream",
2524
+ "text": [
2525
+ "Mistral Local: 4%|▍ | 1750/42071 [1:00:32<28:29:43, 2.54s/it]"
2526
+ ]
2527
+ },
2528
+ {
2529
+ "name": "stdout",
2530
+ "output_type": "stream",
2531
+ "text": [
2532
+ "πŸ’Ύ Progress saved after row 10540\n"
2533
+ ]
2534
+ },
2535
+ {
2536
+ "name": "stderr",
2537
+ "output_type": "stream",
2538
+ "text": [
2539
+ "Mistral Local: 4%|▍ | 1760/42071 [1:00:55<30:12:43, 2.70s/it]"
2540
+ ]
2541
+ },
2542
+ {
2543
+ "name": "stdout",
2544
+ "output_type": "stream",
2545
+ "text": [
2546
+ "πŸ’Ύ Progress saved after row 10550\n"
2547
+ ]
2548
+ },
2549
+ {
2550
+ "name": "stderr",
2551
+ "output_type": "stream",
2552
+ "text": [
2553
+ "Mistral Local: 4%|▍ | 1770/42071 [1:01:15<27:06:18, 2.42s/it]"
2554
+ ]
2555
+ },
2556
+ {
2557
+ "name": "stdout",
2558
+ "output_type": "stream",
2559
+ "text": [
2560
+ "πŸ’Ύ Progress saved after row 10560\n"
2561
+ ]
2562
+ },
2563
+ {
2564
+ "name": "stderr",
2565
+ "output_type": "stream",
2566
+ "text": [
2567
+ "Mistral Local: 4%|▍ | 1780/42071 [1:01:34<26:16:20, 2.35s/it]"
2568
+ ]
2569
+ },
2570
+ {
2571
+ "name": "stdout",
2572
+ "output_type": "stream",
2573
+ "text": [
2574
+ "πŸ’Ύ Progress saved after row 10570\n"
2575
+ ]
2576
+ },
2577
+ {
2578
+ "name": "stderr",
2579
+ "output_type": "stream",
2580
+ "text": [
2581
+ "Mistral Local: 4%|▍ | 1790/42071 [1:01:59<27:50:05, 2.49s/it]"
2582
+ ]
2583
+ },
2584
+ {
2585
+ "name": "stdout",
2586
+ "output_type": "stream",
2587
+ "text": [
2588
+ "πŸ’Ύ Progress saved after row 10580\n"
2589
+ ]
2590
+ },
2591
+ {
2592
+ "name": "stderr",
2593
+ "output_type": "stream",
2594
+ "text": [
2595
+ "Mistral Local: 4%|▍ | 1800/42071 [1:02:20<26:56:05, 2.41s/it]"
2596
+ ]
2597
+ },
2598
+ {
2599
+ "name": "stdout",
2600
+ "output_type": "stream",
2601
+ "text": [
2602
+ "πŸ’Ύ Progress saved after row 10590\n"
2603
+ ]
2604
+ },
2605
+ {
2606
+ "name": "stderr",
2607
+ "output_type": "stream",
2608
+ "text": [
2609
+ "Mistral Local: 4%|▍ | 1810/42071 [1:02:39<26:25:22, 2.36s/it]"
2610
+ ]
2611
+ },
2612
+ {
2613
+ "name": "stdout",
2614
+ "output_type": "stream",
2615
+ "text": [
2616
+ "πŸ’Ύ Progress saved after row 10600\n"
2617
+ ]
2618
+ },
2619
+ {
2620
+ "name": "stderr",
2621
+ "output_type": "stream",
2622
+ "text": [
2623
+ "Mistral Local: 4%|▍ | 1816/42071 [1:02:51<21:34:08, 1.93s/it]"
2624
+ ]
2625
+ }
2626
+ ],
2627
+ "source": [
2628
+ "import pandas as pd\n",
2629
+ "import json\n",
2630
+ "import time\n",
2631
+ "import re\n",
2632
+ "from pathlib import Path\n",
2633
+ "from tqdm import tqdm\n",
2634
+ "import torch\n",
2635
+ "from transformers import AutoModelForCausalLM, AutoTokenizer\n",
2636
+ "\n",
2637
+ "current_dir = Path.cwd()\n",
2638
+ "input_file = current_dir.parent / \"data/CSV/model_adapter/real_person_adapter_step_02_NER.csv\"\n",
2639
+ "professions_file = current_dir.parent / \"misc/lists/professions.csv\"\n",
2640
+ "professions_mapped_file = current_dir.parent / \"misc/lists/professions_mapped.csv\"\n",
2641
+ "# === PROCESS DATA ===\n",
2642
+ "\n",
2643
+ "\n",
2644
+ "# === CONFIGURATION ===\n",
2645
+ "TEST_MODE = False\n",
2646
+ "TEST_SIZE = 100\n",
2647
+ "MAX_ROWS = 50862\n",
2648
+ "SAVE_INTERVAL = 10\n",
2649
+ "\n",
2650
+ "output_file = current_dir.parent / f\"data/CSV/mistral_local_annotated_POI{'_test' if TEST_MODE else ''}.csv\"\n",
2651
+ "index_file = current_dir.parent / \"misc/query_indicies/mistral_local_query_index.txt\"\n",
2652
+ "\n",
2653
+ "\n",
2654
+ "# Model settings\n",
2655
+ "#MODEL_NAME = \"mistralai/Mistral-Small-3.1-24B-Instruct-2503\"\n",
2656
+ "MODEL_NAME = \"mistralai/Mistral-7B-Instruct-v0.3\"\n",
2657
+ "#MODEL_NAME = \"mistralai/Mistral-7B-Instruct-v0.3\"\n",
2658
+ "CACHE_DIR = current_dir.parent / \"data/models\"\n",
2659
+ "CACHE_DIR.mkdir(parents=True, exist_ok=True)\n",
2660
+ "\n",
2661
+ "# Define the SPECIFIC profession categories\n",
2662
+ "PROFESSION_CATEGORIES = [\n",
2663
+ " \"actor\",\n",
2664
+ " \"adult performer\",\n",
2665
+ " \"singer/musician\",\n",
2666
+ " \"model\",\n",
2667
+ " \"online personality\",\n",
2668
+ " \"public figure\",\n",
2669
+ " \"voice actor/ASMR\",\n",
2670
+ " \"sports professional\",\n",
2671
+ " \"tv personality\"\n",
2672
+ "]\n",
2673
+ "\n",
2674
+ "# === LOAD MODEL ===\n",
2675
+ "print(f\"Loading model: {MODEL_NAME}\")\n",
2676
+ "print(f\"Cache directory: {CACHE_DIR}\")\n",
2677
+ "print(f\"This may take a while on first run (~65GB download)...\\n\")\n",
2678
+ "\n",
2679
+ "# Check GPU availability\n",
2680
+ "device = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n",
2681
+ "print(f\"Device: {device}\")\n",
2682
+ "\n",
2683
+ "if device == \"cpu\":\n",
2684
+ " print(\"⚠️ WARNING: No GPU detected! Inference will be VERY slow.\")\n",
2685
+ " print(\" Consider using a GPU or reducing model size.\")\n",
2686
+ "\n",
2687
+ "# Load tokenizer\n",
2688
+ "print(\"Loading tokenizer...\")\n",
2689
+ "try:\n",
2690
+ " tokenizer = AutoTokenizer.from_pretrained(\n",
2691
+ " MODEL_NAME,\n",
2692
+ " cache_dir=str(CACHE_DIR),\n",
2693
+ " use_fast=True\n",
2694
+ " )\n",
2695
+ "except Exception as e:\n",
2696
+ " print(f\"Failed with use_fast=True, trying use_fast=False...\")\n",
2697
+ " tokenizer = AutoTokenizer.from_pretrained(\n",
2698
+ " MODEL_NAME,\n",
2699
+ " cache_dir=str(CACHE_DIR),\n",
2700
+ " use_fast=False\n",
2701
+ " )\n",
2702
+ "\n",
2703
+ "# Ensure pad token is set\n",
2704
+ "if tokenizer.pad_token is None:\n",
2705
+ " tokenizer.pad_token = tokenizer.eos_token\n",
2706
+ "\n",
2707
+ "print(\"βœ… Tokenizer loaded\")\n",
2708
+ "\n",
2709
+ "# Load model with optimizations\n",
2710
+ "print(\"Loading model (this may take several minutes)...\")\n",
2711
+ "model = AutoModelForCausalLM.from_pretrained(\n",
2712
+ " MODEL_NAME,\n",
2713
+ " cache_dir=str(CACHE_DIR),\n",
2714
+ " torch_dtype=torch.bfloat16,\n",
2715
+ " device_map=\"auto\",\n",
2716
+ " trust_remote_code=False\n",
2717
+ ")\n",
2718
+ "model.eval()\n",
2719
+ "print(\"βœ… Model loaded\")\n",
2720
+ "\n",
2721
+ "# Check VRAM usage\n",
2722
+ "if torch.cuda.is_available():\n",
2723
+ " vram_gb = torch.cuda.max_memory_allocated() / 1024**3\n",
2724
+ " print(f\"VRAM used: {vram_gb:.2f} GB\\n\")\n",
2725
+ "\n",
2726
+ "# === LOAD DATA ===\n",
2727
+ "if output_file.exists():\n",
2728
+ " print(\"Loading annotated CSV...\")\n",
2729
+ " df = pd.read_csv(output_file)\n",
2730
+ "else:\n",
2731
+ " print(\"Loading raw input CSV...\")\n",
2732
+ " df = pd.read_csv(input_file)\n",
2733
+ "\n",
2734
+ "\n",
2735
+ "# Try to load profession mapping files\n",
2736
+ "try:\n",
2737
+ " professions_df = pd.read_csv(professions_file)\n",
2738
+ " print(f\"βœ… Loaded professions.csv\")\n",
2739
+ "except:\n",
2740
+ " print(\"⚠️ Warning: professions.csv not found\")\n",
2741
+ "\n",
2742
+ "try:\n",
2743
+ " prof_mapped_df = pd.read_csv(professions_mapped_file)\n",
2744
+ " print(f\"βœ… Loaded profession mapping with {len(prof_mapped_df)} categories\")\n",
2745
+ "except:\n",
2746
+ " print(\"⚠️ Warning: professions_mapped.csv not found, using default categories\")\n",
2747
+ "\n",
2748
+ "profession_str = \", \".join(PROFESSION_CATEGORIES)\n",
2749
+ "\n",
2750
+ "print(f\"Loaded {len(df)} rows\")\n",
2751
+ "print(f\"\\nProfession categories ({len(PROFESSION_CATEGORIES)}):\")\n",
2752
+ "for cat in PROFESSION_CATEGORIES:\n",
2753
+ " print(f\" - {cat}\")\n",
2754
+ "\n",
2755
+ "if TEST_MODE:\n",
2756
+ " print(f\"\\nRunning in TEST MODE with {TEST_SIZE} samples\")\n",
2757
+ " df = df.head(TEST_SIZE).copy()\n",
2758
+ "elif MAX_ROWS:\n",
2759
+ " df = df.head(MAX_ROWS).copy()\n",
2760
+ "\n",
2761
+ "# === CREATE PROMPTS (DEEPSEEK STYLE) ===\n",
2762
+ "def create_prompt(row):\n",
2763
+ " \"\"\"Create prompt for Mistral annotation with specific profession categories.\"\"\"\n",
2764
+ " name = row['real_name'] if pd.notna(row.get('real_name')) else row.get('name', '')\n",
2765
+ " \n",
2766
+ " # Gather hints\n",
2767
+ " hints = []\n",
2768
+ " if pd.notna(row.get('likely_profession')):\n",
2769
+ " hints.append(str(row['likely_profession']))\n",
2770
+ " if pd.notna(row.get('likely_nationality')):\n",
2771
+ " hints.append(str(row['likely_nationality']))\n",
2772
+ " if pd.notna(row.get('likely_country')):\n",
2773
+ " hints.append(str(row['likely_country']))\n",
2774
+ " \n",
2775
+ " # Add tags if we don't have enough hints\n",
2776
+ " if len(hints) < 3:\n",
2777
+ " for i in range(1, 8):\n",
2778
+ " tag_col = f'tag_{i}'\n",
2779
+ " if tag_col in row and pd.notna(row[tag_col]):\n",
2780
+ " tag_val = str(row[tag_col])\n",
2781
+ " if tag_val not in hints:\n",
2782
+ " hints.append(tag_val)\n",
2783
+ " if len(hints) >= 5:\n",
2784
+ " break\n",
2785
+ " \n",
2786
+ " hint_text = \", \".join(hints[:5]) if hints else \"none\"\n",
2787
+ " \n",
2788
+ " return f\"\"\"Given '{name}' ({hint_text}), provide:\n",
2789
+ "1. Full legal name (Western order if non-latin script)\n",
2790
+ "2. Any stage names/aliases (comma separated)\n",
2791
+ "3. Gender (Male/Female/Other/Unknown)\n",
2792
+ "4. Top 3 most likely professions from ONLY these categories:\n",
2793
+ " - actor\n",
2794
+ " - adult performer\n",
2795
+ " - singer/musician\n",
2796
+ " - model\n",
2797
+ " - online personality (includes streamers, cosplayers, influencers)\n",
2798
+ " - public figure (includes politicians, activists, journalists, authors)\n",
2799
+ " - voice actor/ASMR\n",
2800
+ " - sports professional\n",
2801
+ " - tv personality (includes hosts, presenters, reality TV)\n",
2802
+ "\n",
2803
+ "5. Primary country associated\n",
2804
+ "\n",
2805
+ "IMPORTANT:\n",
2806
+ "- Choose professions ONLY from the 9 categories above\n",
2807
+ "- Provide up to 3 professions, comma-separated, ordered by relevance\n",
2808
+ "- Be SPECIFIC: choose the most accurate category for each role\n",
2809
+ "- \"online personality\" includes: streamers, cosplayers, YouTubers, influencers, content creators\n",
2810
+ "- Use 'Unknown' when uncertain or for fictional characters/places\n",
2811
+ "- For multi-role people, list all relevant categories (e.g., \"actor, singer/musician, online personality\")\n",
2812
+ "- For country respond with one word only, for example China or Columbia\n",
2813
+ "- actress = actor\n",
2814
+ "\n",
2815
+ "Respond with exactly 5 numbered lines.\"\"\"\n",
2816
+ "\n",
2817
+ "# Create prompts\n",
2818
+ "print(\"\\nCreating prompts...\")\n",
2819
+ "df['prompt'] = df.apply(create_prompt, axis=1)\n",
2820
+ "print(\"βœ… Prompts created\")\n",
2821
+ "\n",
2822
+ "# === QUERY MISTRAL LOCAL ===\n",
2823
+ "def query_mistral_local(prompt: str) -> str:\n",
2824
+ " \"\"\"Query Mistral locally via transformers.\"\"\"\n",
2825
+ " try:\n",
2826
+ " # Format as chat message for Mistral\n",
2827
+ " messages = [\n",
2828
+ " {\"role\": \"system\", \"content\": \"You are an assistant that extracts key data on a person based on the name. Respond with exactly 5 numbered lines. For professions, choose ONLY from these categories: actor, adult performer, singer/musician, model, online personality, public figure, voice actor/ASMR, sports professional, tv personality.\"},\n",
2829
+ " {\"role\": \"user\", \"content\": prompt}\n",
2830
+ " ]\n",
2831
+ " \n",
2832
+ " # Tokenize\n",
2833
+ " if hasattr(tokenizer, 'apply_chat_template'):\n",
2834
+ " text = tokenizer.apply_chat_template(\n",
2835
+ " messages,\n",
2836
+ " tokenize=False,\n",
2837
+ " add_generation_prompt=True\n",
2838
+ " )\n",
2839
+ " else:\n",
2840
+ " # Fallback for older tokenizers\n",
2841
+ " text = f\"[INST] {prompt} [/INST]\"\n",
2842
+ " \n",
2843
+ " inputs = tokenizer([text], return_tensors=\"pt\", padding=True).to(device)\n",
2844
+ " \n",
2845
+ " # Generate\n",
2846
+ " with torch.no_grad():\n",
2847
+ " outputs = model.generate(\n",
2848
+ " **inputs,\n",
2849
+ " max_new_tokens=512,\n",
2850
+ " temperature=0.05,\n",
2851
+ " do_sample=True,\n",
2852
+ " top_p=0.8,\n",
2853
+ " pad_token_id=tokenizer.pad_token_id if tokenizer.pad_token_id else tokenizer.eos_token_id\n",
2854
+ " )\n",
2855
+ " \n",
2856
+ " # Decode\n",
2857
+ " generated_ids = outputs[0][inputs['input_ids'].shape[1]:]\n",
2858
+ " response = tokenizer.decode(generated_ids, skip_special_tokens=True)\n",
2859
+ " \n",
2860
+ " return response.strip()\n",
2861
+ " \n",
2862
+ " except Exception as e:\n",
2863
+ " print(f\"Generation error: {e}\")\n",
2864
+ " return None\n",
2865
+ "\n",
2866
+ "# === PARSE RESPONSE (DEEPSEEK STYLE) ===\n",
2867
+ "def parse_response(response):\n",
2868
+ " \"\"\"Parse Mistral response into structured fields.\"\"\"\n",
2869
+ " if not response:\n",
2870
+ " return {\n",
2871
+ " 'full_name': 'Unknown',\n",
2872
+ " 'aliases': 'Unknown',\n",
2873
+ " 'gender': 'Unknown',\n",
2874
+ " 'profession_llm': 'Unknown',\n",
2875
+ " 'country': 'Unknown'\n",
2876
+ " }\n",
2877
+ " \n",
2878
+ " # Split into lines and clean\n",
2879
+ " lines = [line.strip() for line in response.split('\\n') if line.strip()]\n",
2880
+ " \n",
2881
+ " # Initialize with Unknown values\n",
2882
+ " fields = {\n",
2883
+ " 'full_name': 'Unknown',\n",
2884
+ " 'aliases': 'Unknown',\n",
2885
+ " 'gender': 'Unknown',\n",
2886
+ " 'profession_llm': 'Unknown',\n",
2887
+ " 'country': 'Unknown'\n",
2888
+ " }\n",
2889
+ " \n",
2890
+ " # Extract information from each numbered line\n",
2891
+ " for line in lines:\n",
2892
+ " if line.startswith('1.'):\n",
2893
+ " fields['full_name'] = line[2:].strip()\n",
2894
+ " elif line.startswith('2.'):\n",
2895
+ " fields['aliases'] = line[2:].strip()\n",
2896
+ " elif line.startswith('3.'):\n",
2897
+ " fields['gender'] = line[2:].strip()\n",
2898
+ " elif line.startswith('4.'):\n",
2899
+ " fields['profession_llm'] = line[2:].strip()\n",
2900
+ " elif line.startswith('5.'):\n",
2901
+ " fields['country'] = line[2:].strip()\n",
2902
+ " \n",
2903
+ " return fields\n",
2904
+ "\n",
2905
+ "# === PROCESS DATA ===\n",
2906
+ "output_file = current_dir.parent / f\"data/CSV/mistral_local_annotated_POI{'_test' if TEST_MODE else ''}.csv\"\n",
2907
+ "index_file = current_dir.parent / \"misc/query_indicies/mistral_local_query_index.txt\"\n",
2908
+ "\n",
2909
+ "index_file.parent.mkdir(parents=True, exist_ok=True)\n",
2910
+ "\n",
2911
+ "# Load index\n",
2912
+ "current_index = 0\n",
2913
+ "if index_file.exists():\n",
2914
+ " try:\n",
2915
+ " current_index = int(index_file.read_text().strip())\n",
2916
+ " except:\n",
2917
+ " current_index = 0\n",
2918
+ "\n",
2919
+ "print(f\"Resuming from index {current_index}\")\n",
2920
+ "\n",
2921
+ "start_time = time.time()\n",
2922
+ "\n",
2923
+ "for i in tqdm(range(current_index, len(df)), desc=\"Mistral Local\"):\n",
2924
+ "\n",
2925
+ " prompt = df.at[i, \"prompt\"]\n",
2926
+ "\n",
2927
+ " # -------- MODEL QUERY WITH RETRIES --------\n",
2928
+ " response = None\n",
2929
+ " for attempt in range(3):\n",
2930
+ " response = query_mistral_local(prompt)\n",
2931
+ " \n",
2932
+ " # Valid response?\n",
2933
+ " if response and len(response.strip()) > 10:\n",
2934
+ " break\n",
2935
+ " \n",
2936
+ " print(f\"⚠️ Row {i}: Empty or invalid response, retry {attempt+1}/3\")\n",
2937
+ " time.sleep(0.5)\n",
2938
+ "\n",
2939
+ " # If still invalid β†’ DO NOT overwrite previous data\n",
2940
+ " if not response or len(response.strip()) <= 10:\n",
2941
+ " print(f\"❌ Row {i}: failed after retries, not writing, not advancing index\")\n",
2942
+ " continue\n",
2943
+ "\n",
2944
+ " parsed = parse_response(response)\n",
2945
+ "\n",
2946
+ " # Additional safety: skip rows that parsed as all 'Unknown'\n",
2947
+ " if all(v == \"Unknown\" for v in parsed.values()):\n",
2948
+ " print(f\"❌ Row {i}: parsed as all Unknown (likely model crash); skipping.\")\n",
2949
+ " continue\n",
2950
+ "\n",
2951
+ " # -------- WRITE PARSED FIELDS SAFELY --------\n",
2952
+ " for key, value in parsed.items():\n",
2953
+ " df.at[i, key] = value\n",
2954
+ "\n",
2955
+ " # Advance progress ONLY after successful write\n",
2956
+ " current_index = i + 1\n",
2957
+ "\n",
2958
+ " # -------- GPU MEMORY CLEANUP --------\n",
2959
+ " if torch.cuda.is_available():\n",
2960
+ " torch.cuda.empty_cache()\n",
2961
+ " torch.cuda.synchronize()\n",
2962
+ "\n",
2963
+ " # -------- SAVE LIKE YOUR DEEPSEEK VERSION --------\n",
2964
+ " if (i + 1) % SAVE_INTERVAL == 0 or (i + 1) == len(df):\n",
2965
+ " df.to_csv(output_file, index=False)\n",
2966
+ " with open(index_file, \"w\") as f:\n",
2967
+ " f.write(str(current_index))\n",
2968
+ " print(f\"πŸ’Ύ Progress saved after row {i+1}\")\n",
2969
+ "\n",
2970
+ "# Final save\n",
2971
+ "df.to_csv(output_file, index=False)\n",
2972
+ "index_file.write_text(str(current_index))\n",
2973
+ "print(\"βœ… Finished full dataset.\")\n"
2974
+ ]
2975
+ },
2976
+ {
2977
+ "cell_type": "code",
2978
+ "execution_count": null,
2979
+ "id": "8ad48edb-b136-46a4-9277-c1de58f00093",
2980
+ "metadata": {},
2981
+ "outputs": [],
2982
+ "source": []
2983
+ }
2984
+ ],
2985
+ "metadata": {
2986
+ "kernelspec": {
2987
+ "display_name": "pm-paper",
2988
+ "language": "python",
2989
+ "name": "pm-paper"
2990
+ },
2991
+ "language_info": {
2992
+ "codemirror_mode": {
2993
+ "name": "ipython",
2994
+ "version": 3
2995
+ },
2996
+ "file_extension": ".py",
2997
+ "mimetype": "text/x-python",
2998
+ "name": "python",
2999
+ "nbconvert_exporter": "python",
3000
+ "pygments_lexer": "ipython3",
3001
+ "version": "3.11.13"
3002
+ }
3003
+ },
3004
+ "nbformat": 4,
3005
+ "nbformat_minor": 5
3006
+ }
jupyter_notebooks/QWEN.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
jupyter_notebooks/Section_2-2-2_Figure_4_Demographic_patterns_in_gen_images.ipynb CHANGED
@@ -1773,9 +1773,9 @@
1773
  ],
1774
  "metadata": {
1775
  "kernelspec": {
1776
- "display_name": "HORDE",
1777
  "language": "python",
1778
- "name": "horde"
1779
  },
1780
  "language_info": {
1781
  "codemirror_mode": {
@@ -1787,7 +1787,7 @@
1787
  "name": "python",
1788
  "nbconvert_exporter": "python",
1789
  "pygments_lexer": "ipython3",
1790
- "version": "3.12.4"
1791
  }
1792
  },
1793
  "nbformat": 4,
 
1773
  ],
1774
  "metadata": {
1775
  "kernelspec": {
1776
+ "display_name": "Python 3 (ipykernel)",
1777
  "language": "python",
1778
+ "name": "python3"
1779
  },
1780
  "language_info": {
1781
  "codemirror_mode": {
 
1787
  "name": "python",
1788
  "nbconvert_exporter": "python",
1789
  "pygments_lexer": "ipython3",
1790
+ "version": "3.12.10"
1791
  }
1792
  },
1793
  "nbformat": 4,
jupyter_notebooks/Section_2-3-4_Figure_8_deepfake_adapters.ipynb CHANGED
@@ -4294,12 +4294,586 @@
4294
  },
4295
  {
4296
  "cell_type": "code",
4297
- "execution_count": null,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4298
  "id": "4gb2vta3w5g",
4299
  "metadata": {
4300
  "execution": {
4301
  "iopub.execute_input": "2025-11-28T21:20:20.130202Z",
4302
- "iopub.status.busy": "2025-11-28T21:20:20.130008Z"
 
 
 
4303
  }
4304
  },
4305
  "outputs": [
@@ -4321,7 +4895,64 @@
4321
  "name": "stderr",
4322
  "output_type": "stream",
4323
  "text": [
4324
- "Loading checkpoint shards: 25%|β–ˆβ–ˆβ–Œ | 3/12 [00:46<02:18, 15.38s/it]"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4325
  ]
4326
  }
4327
  ],
 
4294
  },
4295
  {
4296
  "cell_type": "code",
4297
+ "execution_count": 6,
4298
+ "id": "601d840a-45f3-4679-be84-ebdb7951c2a8",
4299
+ "metadata": {
4300
+ "execution": {
4301
+ "iopub.execute_input": "2025-11-28T21:37:19.929686Z",
4302
+ "iopub.status.busy": "2025-11-28T21:37:19.928739Z",
4303
+ "iopub.status.idle": "2025-11-28T21:43:25.222061Z",
4304
+ "shell.execute_reply": "2025-11-28T21:43:25.221487Z",
4305
+ "shell.execute_reply.started": "2025-11-28T21:37:19.929296Z"
4306
+ }
4307
+ },
4308
+ "outputs": [
4309
+ {
4310
+ "name": "stdout",
4311
+ "output_type": "stream",
4312
+ "text": [
4313
+ "Loading model: google/gemma-3-27b-it\n",
4314
+ "Cache directory: /shares/weddigen.ki.uzh/laura_wagner/phase_01/pm-paper/data/models\n",
4315
+ "This may take a while on first run (~65GB download)...\n",
4316
+ "\n",
4317
+ "Device: cuda\n",
4318
+ "Loading tokenizer...\n",
4319
+ "βœ… Tokenizer loaded\n",
4320
+ "Loading model (this may take several minutes)...\n"
4321
+ ]
4322
+ },
4323
+ {
4324
+ "name": "stderr",
4325
+ "output_type": "stream",
4326
+ "text": [
4327
+ "Loading checkpoint shards: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 12/12 [01:13<00:00, 6.12s/it]\n"
4328
+ ]
4329
+ },
4330
+ {
4331
+ "name": "stdout",
4332
+ "output_type": "stream",
4333
+ "text": [
4334
+ "βœ… Model loaded\n",
4335
+ "VRAM used: 76.27 GB\n",
4336
+ "\n",
4337
+ "Loading raw input CSV...\n",
4338
+ "βœ… Loaded professions.csv\n",
4339
+ "βœ… Loaded profession mapping with 9 categories\n",
4340
+ "Loaded 50861 rows\n",
4341
+ "\n",
4342
+ "Profession categories (9):\n",
4343
+ " - actor\n",
4344
+ " - adult performer\n",
4345
+ " - singer/musician\n",
4346
+ " - model\n",
4347
+ " - online personality\n",
4348
+ " - public figure\n",
4349
+ " - voice actor/ASMR\n",
4350
+ " - sports professional\n",
4351
+ " - tv personality\n",
4352
+ "\n",
4353
+ "Running in TEST MODE with 100 samples\n",
4354
+ "\n",
4355
+ "Creating prompts...\n",
4356
+ "βœ… Prompts created\n",
4357
+ "Resuming from index 0\n"
4358
+ ]
4359
+ },
4360
+ {
4361
+ "name": "stderr",
4362
+ "output_type": "stream",
4363
+ "text": [
4364
+ "Gemma Local: 10%|β–ˆ | 10/100 [00:27<03:51, 2.57s/it]"
4365
+ ]
4366
+ },
4367
+ {
4368
+ "name": "stdout",
4369
+ "output_type": "stream",
4370
+ "text": [
4371
+ "πŸ’Ύ Progress saved after row 10\n"
4372
+ ]
4373
+ },
4374
+ {
4375
+ "name": "stderr",
4376
+ "output_type": "stream",
4377
+ "text": [
4378
+ "Gemma Local: 20%|β–ˆβ–ˆ | 20/100 [00:55<03:46, 2.83s/it]"
4379
+ ]
4380
+ },
4381
+ {
4382
+ "name": "stdout",
4383
+ "output_type": "stream",
4384
+ "text": [
4385
+ "πŸ’Ύ Progress saved after row 20\n"
4386
+ ]
4387
+ },
4388
+ {
4389
+ "name": "stderr",
4390
+ "output_type": "stream",
4391
+ "text": [
4392
+ "Gemma Local: 24%|β–ˆβ–ˆβ– | 24/100 [01:08<04:01, 3.18s/it]"
4393
+ ]
4394
+ },
4395
+ {
4396
+ "name": "stdout",
4397
+ "output_type": "stream",
4398
+ "text": [
4399
+ "❌ Row 23: parsed as all Unknown (likely model crash); skipping.\n"
4400
+ ]
4401
+ },
4402
+ {
4403
+ "name": "stderr",
4404
+ "output_type": "stream",
4405
+ "text": [
4406
+ "Gemma Local: 30%|β–ˆβ–ˆβ–ˆ | 30/100 [01:24<03:01, 2.60s/it]"
4407
+ ]
4408
+ },
4409
+ {
4410
+ "name": "stdout",
4411
+ "output_type": "stream",
4412
+ "text": [
4413
+ "πŸ’Ύ Progress saved after row 30\n"
4414
+ ]
4415
+ },
4416
+ {
4417
+ "name": "stderr",
4418
+ "output_type": "stream",
4419
+ "text": [
4420
+ "Gemma Local: 40%|β–ˆβ–ˆβ–ˆβ–ˆ | 40/100 [01:50<02:50, 2.84s/it]"
4421
+ ]
4422
+ },
4423
+ {
4424
+ "name": "stdout",
4425
+ "output_type": "stream",
4426
+ "text": [
4427
+ "πŸ’Ύ Progress saved after row 40\n"
4428
+ ]
4429
+ },
4430
+ {
4431
+ "name": "stderr",
4432
+ "output_type": "stream",
4433
+ "text": [
4434
+ "Gemma Local: 50%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ | 50/100 [02:22<02:34, 3.10s/it]"
4435
+ ]
4436
+ },
4437
+ {
4438
+ "name": "stdout",
4439
+ "output_type": "stream",
4440
+ "text": [
4441
+ "πŸ’Ύ Progress saved after row 50\n"
4442
+ ]
4443
+ },
4444
+ {
4445
+ "name": "stderr",
4446
+ "output_type": "stream",
4447
+ "text": [
4448
+ "Gemma Local: 60%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ | 60/100 [02:54<02:04, 3.11s/it]"
4449
+ ]
4450
+ },
4451
+ {
4452
+ "name": "stdout",
4453
+ "output_type": "stream",
4454
+ "text": [
4455
+ "πŸ’Ύ Progress saved after row 60\n"
4456
+ ]
4457
+ },
4458
+ {
4459
+ "name": "stderr",
4460
+ "output_type": "stream",
4461
+ "text": [
4462
+ "Gemma Local: 70%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ | 70/100 [03:20<01:23, 2.77s/it]"
4463
+ ]
4464
+ },
4465
+ {
4466
+ "name": "stdout",
4467
+ "output_type": "stream",
4468
+ "text": [
4469
+ "πŸ’Ύ Progress saved after row 70\n"
4470
+ ]
4471
+ },
4472
+ {
4473
+ "name": "stderr",
4474
+ "output_type": "stream",
4475
+ "text": [
4476
+ "Gemma Local: 80%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ | 80/100 [03:49<00:56, 2.83s/it]"
4477
+ ]
4478
+ },
4479
+ {
4480
+ "name": "stdout",
4481
+ "output_type": "stream",
4482
+ "text": [
4483
+ "πŸ’Ύ Progress saved after row 80\n"
4484
+ ]
4485
+ },
4486
+ {
4487
+ "name": "stderr",
4488
+ "output_type": "stream",
4489
+ "text": [
4490
+ "Gemma Local: 90%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ | 90/100 [04:17<00:27, 2.75s/it]"
4491
+ ]
4492
+ },
4493
+ {
4494
+ "name": "stdout",
4495
+ "output_type": "stream",
4496
+ "text": [
4497
+ "πŸ’Ύ Progress saved after row 90\n"
4498
+ ]
4499
+ },
4500
+ {
4501
+ "name": "stderr",
4502
+ "output_type": "stream",
4503
+ "text": [
4504
+ "Gemma Local: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 100/100 [04:48<00:00, 2.88s/it]"
4505
+ ]
4506
+ },
4507
+ {
4508
+ "name": "stdout",
4509
+ "output_type": "stream",
4510
+ "text": [
4511
+ "πŸ’Ύ Progress saved after row 100\n",
4512
+ "βœ… Finished full dataset.\n"
4513
+ ]
4514
+ },
4515
+ {
4516
+ "name": "stderr",
4517
+ "output_type": "stream",
4518
+ "text": [
4519
+ "\n"
4520
+ ]
4521
+ }
4522
+ ],
4523
+ "source": [
4524
+ "import pandas as pd\n",
4525
+ "import json\n",
4526
+ "import time\n",
4527
+ "import re\n",
4528
+ "from pathlib import Path\n",
4529
+ "from tqdm import tqdm\n",
4530
+ "import torch\n",
4531
+ "from transformers import AutoModelForCausalLM, AutoTokenizer\n",
4532
+ "\n",
4533
+ "current_dir = Path.cwd()\n",
4534
+ "input_file = current_dir.parent / \"data/CSV/model_adapter/real_person_adapter_step_02_NER.csv\"\n",
4535
+ "professions_file = current_dir.parent / \"misc/lists/professions.csv\"\n",
4536
+ "professions_mapped_file = current_dir.parent / \"misc/lists/professions_mapped.csv\"\n",
4537
+ "# === PROCESS DATA ===\n",
4538
+ "output_file = current_dir.parent / f\"data/CSV/gemma_local_annotated_POI{'_test' if TEST_MODE else ''}.csv\"\n",
4539
+ "index_file = current_dir.parent / \"misc/query_indicies/gemma_local_query_index.txt\"\n",
4540
+ "\n",
4541
+ "\n",
4542
+ "# === CONFIGURATION ===\n",
4543
+ "TEST_MODE = True\n",
4544
+ "TEST_SIZE = 100\n",
4545
+ "MAX_ROWS = 50862\n",
4546
+ "SAVE_INTERVAL = 10\n",
4547
+ "\n",
4548
+ "# Model settings\n",
4549
+ "MODEL_NAME = MODEL_NAME = \"google/gemma-3-27b-it\"\n",
4550
+ "#MODEL_NAME = \"mistralai/Mistral-7B-Instruct-v0.3\"\n",
4551
+ "CACHE_DIR = current_dir.parent / \"data/models\"\n",
4552
+ "CACHE_DIR.mkdir(parents=True, exist_ok=True)\n",
4553
+ "\n",
4554
+ "# Define the SPECIFIC profession categories\n",
4555
+ "PROFESSION_CATEGORIES = [\n",
4556
+ " \"actor\",\n",
4557
+ " \"adult performer\",\n",
4558
+ " \"singer/musician\",\n",
4559
+ " \"model\",\n",
4560
+ " \"online personality\",\n",
4561
+ " \"public figure\",\n",
4562
+ " \"voice actor/ASMR\",\n",
4563
+ " \"sports professional\",\n",
4564
+ " \"tv personality\"\n",
4565
+ "]\n",
4566
+ "\n",
4567
+ "# === LOAD MODEL ===\n",
4568
+ "print(f\"Loading model: {MODEL_NAME}\")\n",
4569
+ "print(f\"Cache directory: {CACHE_DIR}\")\n",
4570
+ "print(f\"This may take a while on first run (~65GB download)...\\n\")\n",
4571
+ "\n",
4572
+ "# Check GPU availability\n",
4573
+ "device = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n",
4574
+ "print(f\"Device: {device}\")\n",
4575
+ "\n",
4576
+ "if device == \"cpu\":\n",
4577
+ " print(\"⚠️ WARNING: No GPU detected! Inference will be VERY slow.\")\n",
4578
+ " print(\" Consider using a GPU or reducing model size.\")\n",
4579
+ "\n",
4580
+ "# Load tokenizer\n",
4581
+ "print(\"Loading tokenizer...\")\n",
4582
+ "try:\n",
4583
+ " tokenizer = AutoTokenizer.from_pretrained(\n",
4584
+ " MODEL_NAME,\n",
4585
+ " cache_dir=str(CACHE_DIR),\n",
4586
+ " use_fast=True\n",
4587
+ " )\n",
4588
+ "except Exception as e:\n",
4589
+ " print(f\"Failed with use_fast=True, trying use_fast=False...\")\n",
4590
+ " tokenizer = AutoTokenizer.from_pretrained(\n",
4591
+ " MODEL_NAME,\n",
4592
+ " cache_dir=str(CACHE_DIR),\n",
4593
+ " use_fast=False\n",
4594
+ " )\n",
4595
+ "\n",
4596
+ "# Ensure pad token is set\n",
4597
+ "if tokenizer.pad_token is None:\n",
4598
+ " tokenizer.pad_token = tokenizer.eos_token\n",
4599
+ "\n",
4600
+ "print(\"βœ… Tokenizer loaded\")\n",
4601
+ "\n",
4602
+ "# Load model with optimizations\n",
4603
+ "print(\"Loading model (this may take several minutes)...\")\n",
4604
+ "model = AutoModelForCausalLM.from_pretrained(\n",
4605
+ " MODEL_NAME,\n",
4606
+ " cache_dir=str(CACHE_DIR),\n",
4607
+ " torch_dtype=torch.bfloat16,\n",
4608
+ " device_map=\"auto\",\n",
4609
+ " trust_remote_code=False\n",
4610
+ ")\n",
4611
+ "model.eval()\n",
4612
+ "print(\"βœ… Model loaded\")\n",
4613
+ "\n",
4614
+ "# Check VRAM usage\n",
4615
+ "if torch.cuda.is_available():\n",
4616
+ " vram_gb = torch.cuda.max_memory_allocated() / 1024**3\n",
4617
+ " print(f\"VRAM used: {vram_gb:.2f} GB\\n\")\n",
4618
+ "\n",
4619
+ "# === LOAD DATA ===\n",
4620
+ "if output_file.exists():\n",
4621
+ " print(\"Loading annotated CSV...\")\n",
4622
+ " df = pd.read_csv(output_file)\n",
4623
+ "else:\n",
4624
+ " print(\"Loading raw input CSV...\")\n",
4625
+ " df = pd.read_csv(input_file)\n",
4626
+ "\n",
4627
+ "\n",
4628
+ "# Try to load profession mapping files\n",
4629
+ "try:\n",
4630
+ " professions_df = pd.read_csv(professions_file)\n",
4631
+ " print(f\"βœ… Loaded professions.csv\")\n",
4632
+ "except:\n",
4633
+ " print(\"⚠️ Warning: professions.csv not found\")\n",
4634
+ "\n",
4635
+ "try:\n",
4636
+ " prof_mapped_df = pd.read_csv(professions_mapped_file)\n",
4637
+ " print(f\"βœ… Loaded profession mapping with {len(prof_mapped_df)} categories\")\n",
4638
+ "except:\n",
4639
+ " print(\"⚠️ Warning: professions_mapped.csv not found, using default categories\")\n",
4640
+ "\n",
4641
+ "profession_str = \", \".join(PROFESSION_CATEGORIES)\n",
4642
+ "\n",
4643
+ "print(f\"Loaded {len(df)} rows\")\n",
4644
+ "print(f\"\\nProfession categories ({len(PROFESSION_CATEGORIES)}):\")\n",
4645
+ "for cat in PROFESSION_CATEGORIES:\n",
4646
+ " print(f\" - {cat}\")\n",
4647
+ "\n",
4648
+ "if TEST_MODE:\n",
4649
+ " print(f\"\\nRunning in TEST MODE with {TEST_SIZE} samples\")\n",
4650
+ " df = df.head(TEST_SIZE).copy()\n",
4651
+ "elif MAX_ROWS:\n",
4652
+ " df = df.head(MAX_ROWS).copy()\n",
4653
+ "\n",
4654
+ "# === CREATE PROMPTS ===\n",
4655
+ "def create_prompt(row):\n",
4656
+ " \"\"\"Create prompt for Gemma annotation with specific profession categories.\"\"\"\n",
4657
+ " name = row['real_name'] if pd.notna(row.get('real_name')) else row.get('name', '')\n",
4658
+ " \n",
4659
+ " # Gather hints\n",
4660
+ " hints = []\n",
4661
+ " if pd.notna(row.get('likely_profession')):\n",
4662
+ " hints.append(str(row['likely_profession']))\n",
4663
+ " if pd.notna(row.get('likely_nationality')):\n",
4664
+ " hints.append(str(row['likely_nationality']))\n",
4665
+ " if pd.notna(row.get('likely_country')):\n",
4666
+ " hints.append(str(row['likely_country']))\n",
4667
+ " \n",
4668
+ " # Add tags if we don't have enough hints\n",
4669
+ " if len(hints) < 3:\n",
4670
+ " for i in range(1, 8):\n",
4671
+ " tag_col = f'tag_{i}'\n",
4672
+ " if tag_col in row and pd.notna(row[tag_col]):\n",
4673
+ " tag_val = str(row[tag_col])\n",
4674
+ " if tag_val not in hints:\n",
4675
+ " hints.append(tag_val)\n",
4676
+ " if len(hints) >= 5:\n",
4677
+ " break\n",
4678
+ " \n",
4679
+ " hint_text = \", \".join(hints[:5]) if hints else \"none\"\n",
4680
+ " \n",
4681
+ " return f\"\"\"Given '{name}' ({hint_text}), provide:\n",
4682
+ "1. Full legal name (Western order if non-latin script)\n",
4683
+ "2. Any stage names/aliases (comma separated)\n",
4684
+ "3. Gender (Male/Female/Other/Unknown)\n",
4685
+ "4. Top 3 most likely professions from ONLY these categories:\n",
4686
+ " - actor\n",
4687
+ " - adult performer\n",
4688
+ " - singer/musician\n",
4689
+ " - model\n",
4690
+ " - online personality (includes streamers, cosplayers, influencers)\n",
4691
+ " - public figure (includes politicians, activists, journalists, authors)\n",
4692
+ " - voice actor/ASMR\n",
4693
+ " - sports professional\n",
4694
+ " - tv personality (includes hosts, presenters, reality TV)\n",
4695
+ "\n",
4696
+ "5. Primary country associated\n",
4697
+ "\n",
4698
+ "IMPORTANT:\n",
4699
+ "- Choose professions ONLY from the 9 categories above\n",
4700
+ "- Provide up to 3 professions, comma-separated, ordered by relevance\n",
4701
+ "- Be SPECIFIC: choose the most accurate category for each role\n",
4702
+ "- \"online personality\" includes: streamers, cosplayers, YouTubers, influencers, content creators\n",
4703
+ "- Use 'Unknown' when uncertain or for fictional characters/places\n",
4704
+ "- For multi-role people, list all relevant categories (e.g., \"actor, singer/musician, online personality\")\n",
4705
+ "- For country respond with one word only, for example China or Columbia\n",
4706
+ "- actress = actor\n",
4707
+ "\n",
4708
+ "Respond with exactly 5 numbered lines.\"\"\"\n",
4709
+ "\n",
4710
+ "# Create prompts\n",
4711
+ "print(\"\\nCreating prompts...\")\n",
4712
+ "df['prompt'] = df.apply(create_prompt, axis=1)\n",
4713
+ "print(\"βœ… Prompts created\")\n",
4714
+ "\n",
4715
+ "# === QUERY Gemma LOCAL ===\n",
4716
+ "def query_gemma_local(prompt: str) -> str:\n",
4717
+ " \"\"\"Query Gemma locally via transformers.\"\"\"\n",
4718
+ " try:\n",
4719
+ " # Format as chat message for Qwen\n",
4720
+ " messages = [\n",
4721
+ " {\"role\": \"system\", \"content\": \"You are an assistant that extracts key data on a person based on the name. Respond with exactly 5 numbered lines. For professions, choose ONLY from these categories: actor, adult performer, singer/musician, model, online personality, public figure, voice actor/ASMR, sports professional, tv personality.\"},\n",
4722
+ " {\"role\": \"user\", \"content\": prompt}\n",
4723
+ " ]\n",
4724
+ " \n",
4725
+ " # Tokenize\n",
4726
+ " if hasattr(tokenizer, 'apply_chat_template'):\n",
4727
+ " text = tokenizer.apply_chat_template(\n",
4728
+ " messages,\n",
4729
+ " tokenize=False,\n",
4730
+ " add_generation_prompt=True\n",
4731
+ " )\n",
4732
+ " else:\n",
4733
+ " # Fallback for older tokenizers\n",
4734
+ " text = f\"[INST] {prompt} [/INST]\"\n",
4735
+ " \n",
4736
+ " inputs = tokenizer([text], return_tensors=\"pt\", padding=True).to(device)\n",
4737
+ " \n",
4738
+ " # Generate\n",
4739
+ " with torch.no_grad():\n",
4740
+ " outputs = model.generate(\n",
4741
+ " **inputs,\n",
4742
+ " max_new_tokens=512,\n",
4743
+ " temperature=0.1,\n",
4744
+ " do_sample=True,\n",
4745
+ " top_p=0.9,\n",
4746
+ " pad_token_id=tokenizer.eos_token_id\n",
4747
+ " )\n",
4748
+ " \n",
4749
+ " # Decode\n",
4750
+ " generated_ids = outputs[0][inputs['input_ids'].shape[1]:]\n",
4751
+ " response = tokenizer.decode(generated_ids, skip_special_tokens=True)\n",
4752
+ " \n",
4753
+ " return response.strip()\n",
4754
+ " \n",
4755
+ " except Exception as e:\n",
4756
+ " print(f\"Generation error: {e}\")\n",
4757
+ " return None\n",
4758
+ "\n",
4759
+ "# === PARSE RESPONSE ===\n",
4760
+ "def parse_response(response):\n",
4761
+ " \"\"\"Parse Gemma response into structured fields.\"\"\"\n",
4762
+ " if not response:\n",
4763
+ " return {\n",
4764
+ " 'full_name': 'Unknown',\n",
4765
+ " 'aliases': 'Unknown',\n",
4766
+ " 'gender': 'Unknown',\n",
4767
+ " 'profession_llm': 'Unknown',\n",
4768
+ " 'country': 'Unknown'\n",
4769
+ " }\n",
4770
+ " \n",
4771
+ " # Split into lines and clean\n",
4772
+ " lines = [line.strip() for line in response.split('\\n') if line.strip()]\n",
4773
+ " \n",
4774
+ " # Initialize with Unknown values\n",
4775
+ " fields = {\n",
4776
+ " 'full_name': 'Unknown',\n",
4777
+ " 'aliases': 'Unknown',\n",
4778
+ " 'gender': 'Unknown',\n",
4779
+ " 'profession_llm': 'Unknown',\n",
4780
+ " 'country': 'Unknown'\n",
4781
+ " }\n",
4782
+ " \n",
4783
+ " # Extract information from each numbered line\n",
4784
+ " for line in lines:\n",
4785
+ " if line.startswith('1.'):\n",
4786
+ " fields['full_name'] = line[2:].strip()\n",
4787
+ " elif line.startswith('2.'):\n",
4788
+ " fields['aliases'] = line[2:].strip()\n",
4789
+ " elif line.startswith('3.'):\n",
4790
+ " fields['gender'] = line[2:].strip()\n",
4791
+ " elif line.startswith('4.'):\n",
4792
+ " fields['profession_llm'] = line[2:].strip()\n",
4793
+ " elif line.startswith('5.'):\n",
4794
+ " fields['country'] = line[2:].strip()\n",
4795
+ " \n",
4796
+ " return fields\n",
4797
+ "\n",
4798
+ "# === PROCESS DATA ===\n",
4799
+ "index_file.parent.mkdir(parents=True, exist_ok=True)\n",
4800
+ "\n",
4801
+ "# Load index\n",
4802
+ "current_index = 0\n",
4803
+ "if index_file.exists():\n",
4804
+ " try:\n",
4805
+ " current_index = int(index_file.read_text().strip())\n",
4806
+ " except:\n",
4807
+ " current_index = 0\n",
4808
+ "\n",
4809
+ "print(f\"Resuming from index {current_index}\")\n",
4810
+ "\n",
4811
+ "start_time = time.time()\n",
4812
+ "\n",
4813
+ "for i in tqdm(range(current_index, len(df)), desc=\"Gemma Local\"):\n",
4814
+ "\n",
4815
+ " prompt = df.at[i, \"prompt\"]\n",
4816
+ "\n",
4817
+ " # -------- MODEL QUERY WITH RETRIES --------\n",
4818
+ " response = None\n",
4819
+ " for attempt in range(3):\n",
4820
+ " response = query_gemma_local(prompt)\n",
4821
+ " \n",
4822
+ " # Valid response?\n",
4823
+ " if response and len(response.strip()) > 10:\n",
4824
+ " break\n",
4825
+ " \n",
4826
+ " print(f\"⚠️ Row {i}: Empty or invalid response, retry {attempt+1}/3\")\n",
4827
+ " time.sleep(0.5)\n",
4828
+ "\n",
4829
+ " # If still invalid β†’ DO NOT overwrite previous data\n",
4830
+ " if not response or len(response.strip()) <= 10:\n",
4831
+ " print(f\"❌ Row {i}: failed after retries, not writing, not advancing index\")\n",
4832
+ " continue\n",
4833
+ "\n",
4834
+ " parsed = parse_response(response)\n",
4835
+ "\n",
4836
+ " # Additional safety: skip rows that parsed as all 'Unknown'\n",
4837
+ " if all(v == \"Unknown\" for v in parsed.values()):\n",
4838
+ " print(f\"❌ Row {i}: parsed as all Unknown (likely model crash); skipping.\")\n",
4839
+ " continue\n",
4840
+ "\n",
4841
+ " # -------- WRITE PARSED FIELDS SAFELY --------\n",
4842
+ " for key, value in parsed.items():\n",
4843
+ " df.at[i, key] = value\n",
4844
+ "\n",
4845
+ " # Advance progress ONLY after successful write\n",
4846
+ " current_index = i + 1\n",
4847
+ "\n",
4848
+ " # -------- GPU MEMORY CLEANUP --------\n",
4849
+ " if torch.cuda.is_available():\n",
4850
+ " torch.cuda.empty_cache()\n",
4851
+ " torch.cuda.synchronize()\n",
4852
+ "\n",
4853
+ " # -------- SAVE LIKE YOUR DEEPSEEK VERSION --------\n",
4854
+ " if (i + 1) % SAVE_INTERVAL == 0 or (i + 1) == len(df):\n",
4855
+ " df.to_csv(output_file, index=False)\n",
4856
+ " with open(index_file, \"w\") as f:\n",
4857
+ " f.write(str(current_index))\n",
4858
+ " print(f\"πŸ’Ύ Progress saved after row {i+1}\")\n",
4859
+ "\n",
4860
+ "# Final save\n",
4861
+ "df.to_csv(output_file, index=False)\n",
4862
+ "index_file.write_text(str(current_index))\n",
4863
+ "print(\"βœ… Finished full dataset.\")\n"
4864
+ ]
4865
+ },
4866
+ {
4867
+ "cell_type": "code",
4868
+ "execution_count": 4,
4869
  "id": "4gb2vta3w5g",
4870
  "metadata": {
4871
  "execution": {
4872
  "iopub.execute_input": "2025-11-28T21:20:20.130202Z",
4873
+ "iopub.status.busy": "2025-11-28T21:20:20.130008Z",
4874
+ "iopub.status.idle": "2025-11-28T21:24:01.683721Z",
4875
+ "shell.execute_reply": "2025-11-28T21:24:01.683179Z",
4876
+ "shell.execute_reply.started": "2025-11-28T21:20:20.130186Z"
4877
  }
4878
  },
4879
  "outputs": [
 
4895
  "name": "stderr",
4896
  "output_type": "stream",
4897
  "text": [
4898
+ "Loading checkpoint shards: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 12/12 [02:51<00:00, 14.26s/it]\n"
4899
+ ]
4900
+ },
4901
+ {
4902
+ "name": "stdout",
4903
+ "output_type": "stream",
4904
+ "text": [
4905
+ "βœ… Model loaded\n",
4906
+ "VRAM used: 64.66 GB\n",
4907
+ "\n",
4908
+ "Loaded 50861 rows\n",
4909
+ "Running in TEST MODE with 10 samples\n",
4910
+ "\n",
4911
+ "Annotating with GEMMA-3-27B LOCAL - rows 0 to 10...\n",
4912
+ "Model: google/gemma-3-27b-it\n",
4913
+ "This may take a while (~250-600 samples/hour on A100)\n",
4914
+ "\n"
4915
+ ]
4916
+ },
4917
+ {
4918
+ "name": "stderr",
4919
+ "output_type": "stream",
4920
+ "text": [
4921
+ "Gemma Local: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 10/10 [00:45<00:00, 4.59s/it]"
4922
+ ]
4923
+ },
4924
+ {
4925
+ "name": "stdout",
4926
+ "output_type": "stream",
4927
+ "text": [
4928
+ "βœ… Saved after 10 rows (~0.0 samples/hour)\n",
4929
+ "\n",
4930
+ "βœ… Done! Results: /shares/weddigen.ki.uzh/laura_wagner/phase_01/pm-paper/data/CSV/gemma_local_annotated_POI_test.csv\n",
4931
+ "Total time: 0.8 minutes\n",
4932
+ "Average speed: 784.9 samples/hour\n",
4933
+ "\n",
4934
+ "Top professions:\n",
4935
+ "profession_llm\n",
4936
+ "singer/musician, actor, model 1\n",
4937
+ "model, online personality, adult performer 1\n",
4938
+ "singer/musician, voice actor/ASMR, online personality 1\n",
4939
+ "model, online personality, public figure 1\n",
4940
+ "singer/musician, model, public figure 1\n",
4941
+ "model, adult performer, online personality 1\n",
4942
+ "actor, singer/musician, model 1\n",
4943
+ "actress, idol, model 1\n",
4944
+ "actor, public figure, model 1\n",
4945
+ "actor, model, public figure 1\n",
4946
+ "Name: count, dtype: int64\n",
4947
+ "\n",
4948
+ "Final VRAM usage: 64.79 GB\n"
4949
+ ]
4950
+ },
4951
+ {
4952
+ "name": "stderr",
4953
+ "output_type": "stream",
4954
+ "text": [
4955
+ "\n"
4956
  ]
4957
  }
4958
  ],
misc/query_indicies/gemma_local_query_index.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ 22720
misc/query_indicies/mistral_local_query_index.txt CHANGED
@@ -1 +1 @@
1
- 8790
 
1
+ 25820