{ "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": [ "
" ], "text/plain": [ "" ] }, "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 }