Spaces:
Runtime error
Runtime error
File size: 3,159 Bytes
bd82901 8d316a5 bd82901 8d316a5 bd82901 8d316a5 bd82901 8d316a5 bd82901 8d316a5 bd82901 8d316a5 bd82901 8d316a5 bd82901 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"c:\\Users\\pshre\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\gradio\\deprecation.py:43: UserWarning: You have unused kwarg parameters in Interface, please remove them: {'output_description': 'Result'}\n",
" warnings.warn(\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Running on local URL: http://127.0.0.1:7866\n",
"\n",
"To create a public link, set `share=True` in `launch()`.\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"http://127.0.0.1:7866/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": []
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import hashlib\n",
"import gradio as gr\n",
"css = \"\"\"\n",
"footer {visibility: hidden}\n",
"body {\n",
" background-color: #f8f8f8;\n",
" font-family: Arial, sans-serif;\n",
"}\n",
"\"\"\"\n",
"\n",
"\n",
"def check(original_image, verified_image):\n",
" # Compute the hash code of the original image\n",
" original_hash = hashlib.sha256(original_image).hexdigest()\n",
"\n",
" # Compute the hash code of the image to be verified\n",
" verified_hash = hashlib.sha256(verified_image).hexdigest()\n",
"\n",
" # Compare the two hash codes\n",
" if original_hash == verified_hash:\n",
" result = \"The image is authentic.\"\n",
" return result, original_hash, verified_hash\n",
" else:\n",
" result = \"The image has been modified or corrupted.\"\n",
" return result, original_hash, verified_hash\n",
"\n",
"iface = gr.Interface(fn=check, inputs=[\"image\", \"image\"], outputs=[\"text\", \"text\", \"text\"],\n",
" title=\"Image Hash Checker\", description=\"Check if an image has been modified or corrupted.\",\n",
" css=css,\n",
" output_description=\"Result\", )\n",
"\n",
"iface.launch()\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.1"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "40bd2957300f66fe63234e30f44f8921bf0b182c128448cf140e100eb5232263"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
|