File size: 2,555 Bytes
10d1254 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | {
"cells": [
{
"cell_type": "markdown",
"id": "dc629106",
"metadata": {},
"source": [
"# Face verification prototype: run in Google Colab\n",
"\n",
"IE University · AI/ML group project · *How lighting, occlusion and ageing affect face verification*\n",
"\n",
"**How to use it (about 3 minutes):**\n",
"1. Click **Runtime → Run all** (accept the \"not authored by Google\" warning).\n",
"2. Wait for the last cell to print a link like `https://xxxx.gradio.live`.\n",
"3. Open the link, upload two face photos, pick a condition and a strength.\n",
"\n",
"The link works while this Colab session is open (up to about 72 hours). Close the tab or restart to stop it. Anyone can run this notebook again for a new link.\n",
"\n",
"*Research prototype, not an identity-check system. Uploaded photos are used only for the comparison and are deleted from the server within an hour. Please only upload photos you have the right to use.*"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a5e8c917",
"metadata": {},
"outputs": [],
"source": [
"# 1. Install the exact versions the model was saved with (about 1 minute)\n",
"!pip install -q scikit-learn==1.9.1 gradio==6.31.0\n",
"# The face detector pins old library versions, so it is installed without them\n",
"!pip install -q --no-deps facenet-pytorch==2.6.0"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "917c7c2a",
"metadata": {},
"outputs": [],
"source": [
"# 2. Download the app code and trained model (no dataset images)\n",
"import os, sys\n",
"from huggingface_hub import snapshot_download\n",
"\n",
"# local_dir = real files (the code finds its model relative to its own location)\n",
"app_dir = snapshot_download(\"Jadebks/face-verification-prototype\", local_dir=\"face-verification-app\")\n",
"os.chdir(app_dir)\n",
"sys.path.insert(0, app_dir)\n",
"print(\"Downloaded to\", app_dir)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3a069bf0",
"metadata": {},
"outputs": [],
"source": [
"# 3. Start the app and print the public link\n",
"import app\n",
"demo = app.build()\n",
"demo.launch(share=True)"
]
}
],
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|